Beispiel #1
0
	void Border::DoPaint(RenderContext* painter, const Rect& dest)
	{
		//ио->вС->об->ср
		painter->FillRect(Rect(0, 0, dest.width(), top()), top_color());
		painter->FillRect(Rect(0, 0, left(), dest.height()), left_color());
		painter->FillRect(Rect(0, dest.height() - bottom(), dest.width(),
			bottom()), bottom_color());
		painter->FillRect(Rect(dest.width() - right(), 0, right(),
			dest.height()), right_color());
	}
Beispiel #2
0
void Canvas_Impl::get_gradient_colors(const Vec2f *triangles, int num_vertex, const Gradient &gradient, std::vector<Colorf> &out_colors)
{
	out_colors.clear();
	out_colors.reserve(num_vertex);
	if (num_vertex)
	{
		Rectf bounding_box = get_triangles_bounding_box(triangles, num_vertex);
		Sizef bounding_box_size = bounding_box.get_size();
		if (bounding_box_size.width <= 0.0f)
			bounding_box_size.width = 1.0f;
		if (bounding_box_size.height <= 0.0f)
			bounding_box_size.height = 1.0f;

		Sizef bounding_box_invert_size( 1.0f / bounding_box_size.width, 1.0f / bounding_box_size.height );

		for(;num_vertex>0; --num_vertex)
		{
			Vec2f point = *(triangles++);
			point.x -= bounding_box.left;
			point.y -= bounding_box.top;
			point.x *= bounding_box_invert_size.width;
			point.y *= bounding_box_invert_size.height;

			Colorf top_color(
				(gradient.top_right.r * point.x) + (gradient.top_left.r * (1.0f - point.x)),
				(gradient.top_right.g * point.x) + (gradient.top_left.g * (1.0f - point.x)),
				(gradient.top_right.b * point.x) + (gradient.top_left.b * (1.0f - point.x)),
				(gradient.top_right.a * point.x) + (gradient.top_left.a * (1.0f - point.x)) );

			Colorf bottom_color(
				(gradient.bottom_right.r * point.x) + (gradient.bottom_left.r * (1.0f - point.x)),
				(gradient.bottom_right.g * point.x) + (gradient.bottom_left.g * (1.0f - point.x)),
				(gradient.bottom_right.b * point.x) + (gradient.bottom_left.b * (1.0f - point.x)),
				(gradient.bottom_right.a * point.x) + (gradient.bottom_left.a * (1.0f - point.x)) );

			Colorf color(
				(bottom_color.r * point.y) + (top_color.r * (1.0f - point.y)),
				(bottom_color.g * point.y) + (top_color.g * (1.0f - point.y)),
				(bottom_color.b * point.y) + (top_color.b * (1.0f - point.y)),
				(bottom_color.a * point.y) + (top_color.a * (1.0f - point.y)) );

			out_colors.push_back(color);
		}
	}
}
Beispiel #3
0
   void PlayScene::drawBackground(Engine& ctx)
   {
      graphics::Color upper_color = m_upperScreenColorScale.getColor(0, 300, m_player->x()-m_threat->x());
      graphics::Color middle_color = m_midScreenColorScale.getColor(0, 300, m_player->x()-m_threat->x());
      graphics::Color bottom_color(middle_color.r - 0x0f, middle_color.g - 0x0f, middle_color.b - 0x0f);

      ctx.graphics().resetBoundImage();
      ctx.graphics().pushMatrix();
      ctx.graphics().resetMatrix();

      ctx.graphics().drawGradient(upper_color, middle_color,  0, 0, m_screen -> width(), m_screen -> height()/2);
      ctx.graphics().drawGradient(middle_color, bottom_color, 0, m_screen -> height()/2, m_screen -> width(), m_screen -> height()/2);

      ctx.graphics().setColor(0xff, 0xff, 0xff);

      m_mountains.draw(0, m_screen->height()/2 - m_mountains.height(), graphics::AlignedQuad((m_cam -> x() / 3) % m_mountains.width(), 0, m_screen->width(), m_mountains.height()));
      ctx.graphics().resetBoundImage();
      ctx.graphics().drawGradient(graphics::Color(0xff, 0xff, 0xff, 0x00), middle_color, 0, 0, m_screen -> width(), m_screen -> height()/2);
      ctx.graphics().setColor(0xff, 0xff, 0xff);
      ctx.graphics().popMatrix();
   }