示例#1
0
void GridComponent::on_render(clan::Canvas &canvas, const clan::Rect &update_rect)
{
	set_cliprect(canvas, get_size());
	clan::Rect g = get_geometry().get_size();

	bool tab_parent = (get_parent_component()->get_tag_name() == "tabpage");

	if (tab_parent)
	{
		canvas.fill_rect( g, clan::Colorf::whitesmoke);
	}
	else
	{
		//canvas.fill_rect( g, clan::Colorf::darkgray);
		canvas.fill_rect( g, clan::Colorf(199/255.0f, 209/255.0f, 224/255.0f));
		canvas.fill_rect( boundary, clan::Colorf::lightgrey/*clan::Colorf("E0DFE3")*/);
	}
/*
	if (!tab_parent)
	{
		clan::Draw::line(canvas, (float)boundary.left, (float)boundary.bottom, (float)boundary.right, (float)boundary.bottom, clan::Colorf::black);
		clan::Draw::line(canvas, (float)boundary.right, (float)boundary.top, (float)boundary.right, (float)boundary.bottom, clan::Colorf::black);
		// canvas.fill_rect( get_boundary_grabber_se(), clan::Colorf::darkslategray);
	}
*/
	clan::Rect framebox = part_windowframe.get_content_box(boundary);
	framebox.translate(-framebox.left, -framebox.top);
	part_windowframe.render_box(canvas, framebox);

	reset_cliprect(canvas);
}
示例#2
0
文件: why_app.cpp 项目: vdell/inertia
void why::Application::draw_info_box(clan::Canvas &c)
{
	c.fill_rect(m_world_area, clan::Colorf(0.0f, 0.0f, 0.0f, 0.6f));

	static clan:: Colorf linec(clan::Colorf::white);
	linec.set_alpha(0.3f);
	c.draw_box(m_world_area, linec);
}
示例#3
0
void GridComponent::on_render_overlay(clan::Canvas &canvas, const clan::Rect &update_rect)
{
	set_cliprect(canvas, get_size());
	std::vector<GridObject *> selection = main_window->get_selection()->get_selection();
	for (size_t i = 0; i < selection.size(); i++)
	{
		clan::Rect grabbers[8] =
		{
			selection[i]->get_grabber_e(),
			selection[i]->get_grabber_se(),
			selection[i]->get_grabber_s(),
			selection[i]->get_grabber_sw(),
			selection[i]->get_grabber_w(),
			selection[i]->get_grabber_nw(),
			selection[i]->get_grabber_n(),
			selection[i]->get_grabber_ne()
		};

		for (int j=0; j<8; j++)
			grabbers[j] = window_to_component_coords(selection[i]->component_to_window_coords(grabbers[j]));

		clan::Rect pos = window_to_component_coords(selection[i]->component_to_window_coords(selection[i]->get_size()));
		pos.expand(4,4,3,3);
		canvas.draw_box( pos, clan::Colorf(100.0f/255.0f, 100.0f/255.0f, 100.0f/255.0f, 0.25f));

		for (int j=0; j<8; j++)
		{
			canvas.fill_rect( grabbers[j], clan::Colorf::white);
			canvas.draw_box( grabbers[j], clan::Colorf::black);
		}
	}

	if (netselect_box.get_size() != clan::Size(0,0))
	{
		clan::Rect box = netselect_box;
		box.translate(component_container->get_geometry().left, component_container->get_geometry().top);

		clan::Colorf c = clan::Colorf::blue;
		c.set_alpha(0.1f);
		canvas.fill_rect( box, c);
		canvas.draw_box( box, clan::Colorf::blue);
	}

	reset_cliprect(canvas);
}
示例#4
0
void Alpha::draw_section(clan::Canvas &canvas, clan::Font &font, int yoffset, const clan::Colorf &background, const clan::Colorf &vertex_colour, const clan::Colorf &image_colour)
{
	// Draw the background without blending to set the specified RGBA

	canvas.set_blend_state(blend_disabled);

	const int outer_area_size = 32;
	const int outer_xoffset = 8;
	canvas.fill_rect( outer_xoffset, yoffset, outer_xoffset + outer_area_size, yoffset + outer_area_size, background);

	canvas.set_blend_state(blend_enabled);

	// Create the image
	clan::Image image = create_block(canvas, image_colour);

	// Draw the image
	image.set_color(vertex_colour);
	image.draw(canvas, outer_xoffset + (outer_area_size - image.get_width())/2, yoffset + (outer_area_size - image.get_height())/2);

	// Get the composited pixel buffer
	clan::Rect rect(outer_xoffset + outer_area_size / 2, (yoffset + outer_area_size / 2), clan::Size(64,64));
	clan::PixelBuffer pbuff = canvas.get_pixeldata(rect, clan::tf_rgba8);
	pbuff.lock(canvas, clan::access_read_only);

	clan::ImageProviderFactory::save(pbuff, "test.png");

 	clan::Colorf output = pbuff.get_pixel(0,0);
	pbuff.unlock();
 
	// Create the information string
	std::string info(clan::string_format("Initial Destination Colour: RGBA = %1, %2, %3, %4", background.r , background.g, background.b, background.a));
	int xpos = outer_xoffset + outer_area_size + 8;
	int ypos = yoffset - 4;
	font.draw_text(canvas, xpos, ypos, info, clan::Colorf::black);

	info = std::string(clan::string_format("Vertex Colour: RGBA = %1, %2, %3, %4", vertex_colour.r , vertex_colour.g, vertex_colour.b, vertex_colour.a));
	ypos += 16;
	font.draw_text(canvas, xpos, ypos, info, clan::Colorf::black);

	info = std::string(clan::string_format("Image Colour: RGBA = %1, %2, %3, %4", image_colour.r , image_colour.g, image_colour.b, image_colour.a));
	ypos += 16;
	font.draw_text(canvas, xpos, ypos, info, clan::Colorf::black);

	info = std::string(clan::string_format("Destination Colour: RGBA = %1, %2, %3, %4", output.r , output.g, output.b, output.a));
	ypos += 16;
	font.draw_text(canvas, xpos, ypos, info, clan::Colorf::black);

}
示例#5
0
void Note_Single::render(UI::Tracker const &tracker, clan::Canvas &canvas) const
{
    if (this->getScore().rank != EJRank::NONE) return;

    rectf p = tracker.getNoteRect(this->getKey(), this->getTick());

    if (p.left > tracker.get_width () || p.right  < 0)
        return;
    if (p.top  > tracker.get_height())
        return;

    p.top    = tracker.get_height() - p.top;
    p.bottom = tracker.get_height() - p.bottom;

    // Clip note to edge of tracker
    if (p.bottom > tracker.get_height()) {
        p.top       = tracker.get_height() - std::abs(p.bottom - p.top);
        p.bottom    = tracker.get_height();
    }

    clan::Colorf color;

    switch (getKey())
    {
        case ENKey::NOTE_P1_1:
        case ENKey::NOTE_P1_3:
        case ENKey::NOTE_P1_5:
        case ENKey::NOTE_P1_7:
            color = clan::Colorf::white;
            break;
        case ENKey::NOTE_P1_2:
        case ENKey::NOTE_P1_6:
            color = clan::Colorf::cyan;
            break;
        case ENKey::NOTE_P1_4:
            color = clan::Colorf::gold;
            break;
        default:
            color = clan::Colorf::white;
    }

    canvas.fill_rect(p, color);
}
示例#6
0
void Note_Long::render(UI::Tracker const &tracker, clan::Canvas &canvas) const
{
    recti pb = tracker.getNoteRect(this->getKey(), mBTick);
    recti pe = tracker.getNoteRect(this->getKey(), mETick);

    // Skip unused
    if (pb.left > tracker.get_width () || pb.right  < 0 ||
        pe.left > tracker.get_width () || pe.right  < 0)
        return;
    if (pb.top  > tracker.get_height() || pe.bottom < 0)
        return;

    // Flip around
    pb.top    = tracker.get_height() - pb.top;
    pb.bottom = tracker.get_height() - pb.bottom;
    pe.top    = tracker.get_height() - pe.top;
    pe.bottom = tracker.get_height() - pe.bottom;

    // Clip beginning note to edge of target
    if (pb.bottom > tracker.get_height()) {
        pb.top      = tracker.get_height() - std::abs(pb.bottom - pb.top);
        pb.bottom   = tracker.get_height();
    }

    clan::Colorf color;

    switch (getKey())
    {
        case ENKey::NOTE_P1_1:
        case ENKey::NOTE_P1_3:
        case ENKey::NOTE_P1_5:
        case ENKey::NOTE_P1_7:
            color = clan::Colorf::white;
            break;
        case ENKey::NOTE_P1_2:
        case ENKey::NOTE_P1_6:
            color = clan::Colorf::cyan;
            break;
        case ENKey::NOTE_P1_4:
            color = clan::Colorf::gold;
            break;
        default:
            color = clan::Colorf::white;
    }

    clan::Colorf body, head;

    if (mBScore.rank == EJRank::AUTO) {
        body = head = clan::Colorf::purple;
        body.a = 0.8f;
    } else if (mBScore.rank == EJRank::MISS || mEScore.rank == EJRank::MISS) {
        body = head = clan::Colorf::red;
        body.a = 0.4f;
        head.a = 0.8f;
    } else if (mBScore.rank == EJRank::NONE) {
        body = head = color;
        body.a = 0.8f;
    } else if (mEScore.rank == EJRank::NONE) {
        body = head = clan::Colorf::green;
        body.a = 0.8f;
    } else {
        // Release a little too early
        body = head = clan::Colorf::lightblue;
        body.a = 0.2f;
        head.a = 0.4f;
    }

    canvas.fill_rect(pe.left, pe.top, pb.right, pb.bottom, body);
    canvas.fill_rect(pb, head);
    canvas.fill_rect(pe, head);
}
示例#7
0
void Options::on_render(clan::Canvas &canvas, const clan::Rect &update_rect)
{
	clan::Rect rect = get_geometry();
	canvas.fill_rect(update_rect, clan::Colorf(0.6f, 0.6f, 0.2f, 1.0f));
}
示例#8
0
void Alpha::draw_section(clan::Canvas &canvas, clan::Font &font, int yoffset, const clan::Colorf &background, const clan::Colorf &vertex_colour, const clan::Colorf &image_colour)
{
	// Draw the background without blending to set the specified RGBA

	canvas.set_blend_state(blend_disabled);

	const int outer_area_size = 32;
	const int outer_xoffset = 8;
	canvas.fill_rect( outer_xoffset, yoffset, outer_xoffset + outer_area_size, yoffset + outer_area_size, background);

	canvas.set_blend_state(blend_enabled);

	// Create the image
	clan::Image image = create_block(canvas, image_colour);

	// Draw the image
	image.set_color(vertex_colour);
	image.draw(canvas, outer_xoffset + (outer_area_size - image.get_width())/2, yoffset + (outer_area_size - image.get_height())/2);

	clan::Colorf output;
	// Get the composited pixel buffer
	clan::Rectf rect(outer_xoffset + outer_area_size / 2, (yoffset + outer_area_size / 2), clan::Sizef(64,64));
	if (rect.is_inside(canvas.get_size()))
	{
		clan::PixelBuffer pbuff = canvas.get_pixeldata(rect, clan::tf_rgba8);
		pbuff.lock(canvas, clan::access_read_only);

		//clan::ImageProviderFactory::save(pbuff, "test.png");

		clan::Colorf output = pbuff.get_pixel(0, 0);
		pbuff.unlock();
	}
 
	// Create the information string
	std::string info(clan::string_format("Background = %1, %2, %3, %4", get_text(background.r), get_text(background.g), get_text(background.b), get_text(background.a)));
	int xpos = outer_xoffset + outer_area_size + 8;
	int ypos = yoffset + 12;
	font.draw_text(canvas, xpos, ypos, info, clan::Colorf::black);

	info = std::string(clan::string_format("Vertex = %1, %2, %3, %4", get_text(vertex_colour.r), get_text(vertex_colour.g), get_text(vertex_colour.b), get_text(vertex_colour.a)));
	font.draw_text(canvas, xpos + 250, ypos, info, clan::Colorf::black);

	info = std::string(clan::string_format("Image = %1, %2, %3, %4", get_text(image_colour.r), get_text(image_colour.g), get_text(image_colour.b), get_text(image_colour.a)));
	font.draw_text(canvas, xpos + 500, ypos, info, clan::Colorf::black);

	ypos += 20;
	clan::Colorf source(vertex_colour * image_colour);
	clan::Colorf calculated;
	calculated.r = source.a * source.r + (1.0f - source.a) * background.r;
	calculated.g = source.a * source.g + (1.0f - source.a) * background.g;
	calculated.b = source.a * source.b + (1.0f - source.a) * background.b;
	calculated.a = source.a + (1.0f - source.a) * background.a;

	info = std::string(clan::string_format("Source = %1, %2, %3, %4", get_text(source.r), get_text(source.g), get_text(source.b), get_text(source.a)));
	font.draw_text(canvas, xpos, ypos, info, clan::Colorf::black);

	info = std::string(clan::string_format("Calculated = %1, %2, %3, %4", get_text(calculated.r), get_text(calculated.g), get_text(calculated.b), get_text(calculated.a)));
	font.draw_text(canvas, xpos +  250, ypos, info, clan::Colorf::black);

	info = std::string(clan::string_format("Actual = %1, %2, %3, %4", get_text(output.r), get_text(output.g), get_text(output.b), get_text(output.a)));
	font.draw_text(canvas, xpos + 500, ypos, info, clan::Colorf::black);
}