Exemplo n.º 1
0
// -----------------------------------------------------------------------------
// Creates a mask texture of the brush to preview its effect
// -----------------------------------------------------------------------------
void GfxCanvas::generateBrushShadow()
{
	if (brush_ == nullptr)
		return;

	// Generate image
	SImage img;
	img.create(image_.width(), image_.height(), SImage::Type::RGBA);
	for (int i = -4; i < 5; ++i)
		for (int j = -4; j < 5; ++j)
			if (brush_->pixel(i, j))
			{
				auto col = paint_colour_;
				if (editing_mode_ == EditMode::Translate && translation_)
					col = translation_->translate(
						image_.pixelAt(cursor_pos_.x + i, cursor_pos_.y + j, &palette_), &palette_);
				// Not sure what's the best way to preview cutting out
				// Mimicking the checkerboard pattern perhaps?
				// Cyan will do for now
				else if (editing_mode_ == EditMode::Erase)
					col = ColRGBA::CYAN;
				img.setPixel(cursor_pos_.x + i, cursor_pos_.y + j, col);
			}

	// Load it as a GL texture
	OpenGL::Texture::clear(tex_brush_);
	tex_brush_ = OpenGL::Texture::createFromImage(img);
}
Exemplo n.º 2
0
/* GfxCanvas::generateBrushShadow
 * Creates a mask texture of the brush to preview its effect
 *******************************************************************/
void GfxCanvas::generateBrushShadow()
{
	if (brush == nullptr) return;

	// Generate image
	SImage img;
	img.create(image->getWidth(), image->getHeight(), SIType::RGBA);
	for (int i = -4; i < 5; ++i)
		for (int j = -4; j < 5; ++j)
			if (brush->getPixel(i, j))
			{
				rgba_t col = paint_colour;
				if (editing_mode == 3 && translation)
					col = translation->translate(image->getPixel(cursor_pos.x + i,
						cursor_pos.y + j, getPalette()), getPalette());
				// Not sure what's the best way to preview cutting out
				// Mimicking the checkerboard pattern perhaps?
				// Cyan will do for now
				else if (editing_mode == 2)
					col = COL_CYAN;
				img.setPixel(cursor_pos.x + i, cursor_pos.y + j, col);
			}

	// Load it as a GL texture
	tex_brush->loadImage(&img);
}