2015-04-20 19:27:09 +00:00
|
|
|
// Aseprite Document Library
|
|
|
|
// Copyright (c) 2001-2015 David Capello
|
2015-02-12 15:16:25 +00:00
|
|
|
//
|
2015-04-20 19:27:09 +00:00
|
|
|
// This file is released under the terms of the MIT license.
|
|
|
|
// Read LICENSE.txt for more information.
|
2013-03-11 23:29:45 +00:00
|
|
|
|
2013-08-06 00:20:19 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2013-03-11 23:29:45 +00:00
|
|
|
#include "config.h"
|
2013-08-06 00:20:19 +00:00
|
|
|
#endif
|
2013-03-11 23:29:45 +00:00
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
#include "doc/site.h"
|
2013-03-11 23:29:45 +00:00
|
|
|
|
2014-10-21 01:21:31 +00:00
|
|
|
#include "doc/cel.h"
|
|
|
|
#include "doc/layer.h"
|
|
|
|
#include "doc/sprite.h"
|
2013-03-11 23:29:45 +00:00
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
namespace doc {
|
2013-08-06 00:20:19 +00:00
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
LayerIndex Site::layerIndex() const
|
2013-03-11 23:29:45 +00:00
|
|
|
{
|
|
|
|
return (m_sprite && m_layer ?
|
|
|
|
m_sprite->layerToIndex(m_layer): LayerIndex());
|
|
|
|
}
|
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
void Site::layerIndex(LayerIndex layerIndex)
|
2013-03-11 23:29:45 +00:00
|
|
|
{
|
|
|
|
ASSERT(m_sprite != NULL);
|
|
|
|
m_layer = m_sprite->indexToLayer(layerIndex);
|
|
|
|
}
|
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
Palette* Site::palette()
|
2013-03-11 23:29:45 +00:00
|
|
|
{
|
2014-12-28 23:39:11 +00:00
|
|
|
return (m_sprite ? m_sprite->palette(m_frame): NULL);
|
2013-03-11 23:29:45 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
const Cel* Site::cel() const
|
2013-03-11 23:29:45 +00:00
|
|
|
{
|
2014-12-29 00:04:08 +00:00
|
|
|
if (m_layer)
|
|
|
|
return m_layer->cel(m_frame);
|
2013-03-11 23:29:45 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
Cel* Site::cel()
|
2013-03-11 23:29:45 +00:00
|
|
|
{
|
2014-12-29 00:04:08 +00:00
|
|
|
if (m_layer)
|
|
|
|
return m_layer->cel(m_frame);
|
2013-03-11 23:29:45 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
Image* Site::image(int* x, int* y, int* opacity) const
|
2013-03-11 23:29:45 +00:00
|
|
|
{
|
|
|
|
Image* image = NULL;
|
2015-02-12 15:16:25 +00:00
|
|
|
|
2013-03-11 23:29:45 +00:00
|
|
|
if (m_sprite) {
|
|
|
|
if (const Cel* cel = this->cel()) {
|
2014-07-30 04:28:15 +00:00
|
|
|
image = cel->image();
|
|
|
|
if (x) *x = cel->x();
|
|
|
|
if (y) *y = cel->y();
|
|
|
|
if (opacity) *opacity = MID(0, cel->opacity(), 255);
|
2013-03-11 23:29:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
2013-08-06 00:20:19 +00:00
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
Palette* Site::palette() const
|
2014-06-01 21:10:26 +00:00
|
|
|
{
|
2014-12-28 23:39:11 +00:00
|
|
|
return (m_sprite ? m_sprite->palette(m_frame): NULL);
|
2014-06-01 21:10:26 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 19:27:09 +00:00
|
|
|
} // namespace doc
|