void Sprite::render(Image* image, int x, int y, FrameNumber frame) const { image_rectfill(image, x, y, x+m_width-1, y+m_height-1, (m_format == IMAGE_INDEXED ? getTransparentColor(): 0)); layer_render(getFolder(), image, x, y, frame); }
void InvertMaskCommand::onExecute(Context* context) { bool hasMask = false; { const ActiveDocumentReader document(context); if (document->isMaskVisible()) hasMask = true; } // without mask?... if (!hasMask) { // so we select all Command* mask_all_cmd = CommandsModule::instance()->getCommandByName(CommandId::MaskAll); context->executeCommand(mask_all_cmd); } // invert the current mask else { ActiveDocumentWriter document(context); Sprite* sprite(document->getSprite()); UndoTransaction undo(document, "Mask Invert", undo::DoesntModifyDocument); if (undo.isEnabled()) undo.pushUndoer(new undoers::SetMask(undo.getObjects(), document)); /* create a new mask */ UniquePtr<Mask> mask(new Mask()); /* select all the sprite area */ mask->replace(0, 0, sprite->getWidth(), sprite->getHeight()); /* remove in the new mask the current sprite marked region */ const gfx::Rect& maskBounds = document->getMask()->getBounds(); image_rectfill(mask->getBitmap(), maskBounds.x, maskBounds.y, maskBounds.x + maskBounds.w-1, maskBounds.y + maskBounds.h-1, 0); // Invert the current mask in the sprite document->getMask()->invert(); if (document->getMask()->getBitmap()) { // Copy the inverted region in the new mask image_copy(mask->getBitmap(), document->getMask()->getBitmap(), document->getMask()->getBounds().x, document->getMask()->getBounds().y); } // We need only need the area inside the sprite mask->intersect(0, 0, sprite->getWidth(), sprite->getHeight()); // Set the new mask document->setMask(mask); undo.commit(); document->generateMaskBoundaries(); update_screen_for_document(document); } }
void render(v2d_t actor_position, v2d_t camera_position, int x1, int y1, int x2, int y2, uint32 color) { x1 += (int)actor_position.x; y1 += (int)actor_position.y; x2 += (int)actor_position.x; y2 += (int)actor_position.y; x1 -= (int)(camera_position.x - VIDEO_SCREEN_W/2); y1 -= (int)(camera_position.y - VIDEO_SCREEN_H/2); x2 -= (int)(camera_position.x - VIDEO_SCREEN_W/2); y2 -= (int)(camera_position.y - VIDEO_SCREEN_H/2); image_rectfill(video_get_backbuffer(), min(x1,x2), min(y1,y2), max(x1,x2), max(y1,y2), color); }
void image_putpen(Image* image, Pen* pen, int x, int y, int fg_color, int bg_color) { Image* pen_image = pen->get_image(); int u, v, size = pen->get_size(); x -= size/2; y -= size/2; if (fg_color == bg_color) { image_rectfill(image, x, y, x+pen_image->w-1, y+pen_image->h-1, bg_color); } else { for (v=0; v<pen_image->h; v++) { for (u=0; u<pen_image->w; u++) { if (image_getpixel(pen_image, u, v)) image_putpixel(image, x+u, y+v, fg_color); else image_putpixel(image, x+u, y+v, bg_color); } } } }