void draw_clock_hand( HELEMENT he, graphics& gx, UINT sx, UINT sy, double angle_degree, int hand ) { dom::element self(he); color c(255,0,0,0); int hand_width_px; double radians = (2.0 * PI * (angle_degree - 90.0)) / 360.0 ; int radius = min( sy, sx ) / 2 - 16; gx.line_cap(LINE_CAP_ROUND); switch(hand) { case 0: // hours radius -= 24 ; c = self.attribute("-hand-hours", c); if(c.transparent()) return; hand_width_px = self.attribute("-hand-hours-width", 5); gx.line_color(c); gx.line_width( hand_width_px ); break; case 1: // minutes radius -= 12 ; c = self.attribute("-hand-minutes", c); if(c.transparent()) return; hand_width_px = self.attribute("-hand-minutes-width", 3); gx.line_color(c); gx.line_width( hand_width_px ); break; case 2: // seconds c = self.attribute("-hand-seconds", c); if(c.transparent()) return; hand_width_px = self.attribute("-hand-seconds-width", 1); gx.line_color( c ); gx.line_width( hand_width_px ); break; default: assert(false); } double y = (sy / 2) + 0.5; // + 0.5 is to move it to the center of the pixel. double x = (sy / 2) + 0.5; double xe = x + int(cos(radians) * radius) + 0.5; double ye = y + int(sin(radians) * radius) + 0.5; gx.line( x, y, xe, ye ); if( hand == 2 ) { // circle on the end of seconds hand if(pimage) { int w = pimage->width(); int h = pimage->height(); gx.draw_image(pimage,xe - double(w)/2,ye - double(h)/2,w,h,0,0,w,h); } else // no image gx.circle( xe, ye, 4 ); } }
void draw_bar( graphics& gx, UINT width, UINT height, int n_bar, int total_bars, color c, double val ) { double bar_width = double(width) / (2*total_bars); double bar_height = double(height - 2) * val * (double(step)/double(steps-1)); double bar_x1 = bar_width/2 + n_bar * 2 * bar_width; double bar_x2 = bar_x1 + bar_width; double bar_y2 = height - 0.5; double bar_y1 = bar_y2 - bar_height; color c_outline(0,0,0,0); gx.line_color(c_outline); gx.line_width(3); COLOR_STOP cs[3] = { { gcolor(c) , 0.0f }, { gcolor(0xff,0xff,0xff), 0.33f }, { gcolor(c), 1.0f } }; gx.fill_linear_gradient( bar_x1,bar_y1,bar_x2,bar_y1, cs, 3); gx.rectangle(bar_x1,bar_y1,bar_x2,bar_y2,6,6,0,0); }