本文整理汇总了C++中LayerImage::isVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerImage::isVisible方法的具体用法?C++ LayerImage::isVisible怎么用?C++ LayerImage::isVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerImage
的用法示例。
在下文中一共展示了LayerImage::isVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onExecute
void FlattenLayers::onExecute()
{
Sprite* sprite = this->sprite();
auto doc = static_cast<Doc*>(sprite->document());
// Create a temporary image.
ImageRef image(Image::create(sprite->pixelFormat(),
sprite->width(),
sprite->height()));
LayerImage* flatLayer; // The layer onto which everything will be flattened.
color_t bgcolor; // The background color to use for flatLayer.
flatLayer = sprite->backgroundLayer();
if (flatLayer && flatLayer->isVisible()) {
// There exists a visible background layer, so we will flatten onto that.
bgcolor = doc->bgColor(flatLayer);
}
else {
// Create a new transparent layer to flatten everything onto.
flatLayer = new LayerImage(sprite);
ASSERT(flatLayer->isVisible());
executeAndAdd(new cmd::AddLayer(sprite->root(), flatLayer, nullptr));
executeAndAdd(new cmd::SetLayerName(flatLayer, "Flattened"));
bgcolor = sprite->transparentColor();
}
render::Render render;
render.setBgType(render::BgType::NONE);
// Copy all frames to the background.
for (frame_t frame(0); frame<sprite->totalFrames(); ++frame) {
// Clear the image and render this frame.
clear_image(image.get(), bgcolor);
render.renderSprite(image.get(), sprite, frame);
// TODO Keep cel links when possible
ImageRef cel_image;
Cel* cel = flatLayer->cel(frame);
if (cel) {
if (cel->links())
executeAndAdd(new cmd::UnlinkCel(cel));
cel_image = cel->imageRef();
ASSERT(cel_image);
executeAndAdd(new cmd::CopyRect(cel_image.get(), image.get(),
gfx::Clip(0, 0, image->bounds())));
}
else {
cel_image.reset(Image::createCopy(image.get()));
cel = new Cel(frame, cel_image);
flatLayer->addCel(cel);
}
}
// Delete old layers.
LayerList layers = sprite->root()->layers();
for (Layer* layer : layers)
if (layer != flatLayer)
executeAndAdd(new cmd::RemoveLayer(layer));
}