bool Alpha::update() { canvas.clear(clan::Colorf(1.0f,1.0f,1.0f, 1.0f)); // White background font.draw_text(canvas, 8, 20, "Standard Equation:", clan::Colorf::black); font.draw_text(canvas, 8, 40, "Destination Color = AlphaSource * ColorSource + ( 1 - AlphaSource ) * ColorDestination", clan::Colorf::black); font.draw_text(canvas, 8, 60, "Destination Alpha = AlphaSource + ( 1 - AlphaSource ) * AlphaDestination", clan::Colorf::black); font.draw_text(canvas, 8, 100, "ColorSource = Vertex Color * Image Color", clan::Colorf::black); font.draw_text(canvas, 8, 120, "AlphaSource = Vertex Alpha * Image Alpha", clan::Colorf::black); int ypos = 160; int ygap = 80; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.5f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 0.5f), clan::Colorf(1.0f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 0.5f), clan::Colorf(1.0f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(0.2f, 0.0f, 0.0f, 1.0f), clan::Colorf(0.9f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.2f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.9f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 0.5f), clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.5f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 0.5f), clan::Colorf(1.0f, 0.5f, 0.0f, 1.0f), clan::Colorf(0.0f, 0.5f, 0.0f, 1.0f)); ypos += ygap; window.flip(1); return !quit; }
// The start of the Application int Alpha::start(const std::vector<std::string> &args) { quit = false; // Set the window clan::DisplayWindowDescription desc; desc.set_title("Standard Compositing using the Alpha Channel"); desc.set_size(clan::Size(800, 800), true); desc.set_allow_resize(true); clan::DisplayWindow window(desc); // Connect the Window close event clan::Slot slot_quit = window.sig_window_close().connect(this, &Alpha::on_window_close); // Connect a keyboard handler to on_key_up() clan::Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &Alpha::on_input_up); // Get the graphic context clan::Canvas canvas(window); clan::BlendStateDescription blend_desc; blend_desc.enable_blending(false); blend_disabled = clan::BlendState(canvas, blend_desc); blend_desc.enable_blending(true); blend_enabled = clan::BlendState(canvas, blend_desc); clan::Font font(canvas, "tahoma", 16); // Run until someone presses escape while (!quit) { canvas.clear(clan::Colorf(1.0f,1.0f,1.0f, 1.0f)); // White background font.draw_text(canvas, 8, 20, "Standard Equation:", clan::Colorf::black); font.draw_text(canvas, 8, 40, "Destination Color = AlphaSource * ColorSource + ( 1 - AlphaSource ) * ColorDestination", clan::Colorf::black); font.draw_text(canvas, 8, 60, "Destination Alpha = AlphaSource + ( 1 - AlphaSource ) * AlphaDestination", clan::Colorf::black); font.draw_text(canvas, 8, 100, "ColorSource = Vertex Color * Image Color", clan::Colorf::black); font.draw_text(canvas, 8, 120, "AlphaSource = Vertex Alpha * Image Alpha", clan::Colorf::black); int ypos = 160; int ygap = 80; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.5f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 0.5f), clan::Colorf(1.0f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 0.5f), clan::Colorf(1.0f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(0.2f, 0.0f, 0.0f, 1.0f), clan::Colorf(0.9f, 0.0f, 0.0f, 1.0f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.2f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.9f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.0f, 0.0f, 1.0f, 0.5f), clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f), clan::Colorf(1.0f, 0.0f, 0.0f, 0.5f)); ypos += ygap; draw_section(canvas, font, ypos, clan::Colorf(0.5f, 0.5f, 1.0f, 1.0f), clan::Colorf(1.0f, 1.0f, 1.0f, 1.0f), clan::Colorf(0.0f, 0.0f, 0.0f, 0.3f)); ypos += ygap; window.flip(1); // This call processes user input and other events clan::KeepAlive::process(0); } return 0; }
void LxDcViCtl::usr_mouse_move(CDC* pDC, int x, int y) { if (!section.trace) return; LxCommand* locate_cmd = new LxCommand(); locate_cmd->add_child_cmd(new LxLocateCmd(x, y)); locate_cmd->set_dvctl(this); locate_cmd->Excute(pDC); lx_command_mgr.insert_cmd(locate_cmd); if (section.cursor_end == cursor) return; if (section.cursor_end > section.cursor_begin) { if (cursor > section.cursor_end) { Section _section; _section.cursor_begin = section.cursor_end; _section.cursor_end = cursor; draw_section(pDC, &_section); section.cursor_end = cursor; } else if (cursor < section.cursor_begin) { clear_section(pDC, §ion); section.cursor_end = cursor; draw_section(pDC, §ion); } else { Section _section; _section.cursor_begin = cursor; _section.cursor_end = section.cursor_end; clear_section(pDC, &_section); section.cursor_end = cursor; } } else if (section.cursor_end < section.cursor_begin) { if (cursor < section.cursor_end) { Section _section; _section.cursor_begin = cursor; _section.cursor_end = section.cursor_end; draw_section(pDC, &_section); section.cursor_end = cursor; } else if (cursor > section.cursor_begin) { clear_section(pDC, §ion); section.cursor_end = cursor; draw_section(pDC, §ion); } else { Section _section; _section.cursor_begin = section.cursor_end; _section.cursor_end = cursor; clear_section(pDC, &_section); section.cursor_end = cursor; } } else { section.cursor_end = cursor; draw_section(pDC, §ion); } }