static
| 87 | |
| 88 | // static |
| 89 | Sprite* Sprite::createBasicSprite(doc::PixelFormat format, int width, int height, int ncolors) |
| 90 | { |
| 91 | // Create the sprite. |
| 92 | std::unique_ptr<doc::Sprite> sprite(new doc::Sprite(format, width, height, ncolors)); |
| 93 | sprite->setTotalFrames(doc::frame_t(1)); |
| 94 | |
| 95 | // Create the main image. |
| 96 | doc::ImageRef image(doc::Image::create(format, width, height)); |
| 97 | doc::clear_image(image.get(), 0); |
| 98 | |
| 99 | // Create the first transparent layer. |
| 100 | { |
| 101 | std::unique_ptr<doc::LayerImage> layer(new doc::LayerImage(sprite.get())); |
| 102 | layer->setName("Layer 1"); |
| 103 | |
| 104 | // Create the cel. |
| 105 | { |
| 106 | auto cel = std::make_shared<doc::Cel>(doc::frame_t(0), image); |
| 107 | cel->setPosition(0, 0); |
| 108 | |
| 109 | // Add the cel in the layer. |
| 110 | layer->addCel(cel); |
| 111 | } |
| 112 | |
| 113 | // Add the layer in the sprite. |
| 114 | sprite->folder()->addLayer(layer.release()); // Release the layer because it's owned by the sprite |
| 115 | } |
| 116 | |
| 117 | return sprite.release(); |
| 118 | } |
| 119 | |
| 120 | ////////////////////////////////////////////////////////////////////// |
| 121 | // Main properties |
nothing calls this directly
no test coverage detected