Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
    // canvas::draw overridable
    virtual void draw( HELEMENT he, graphics& gx, UINT width, UINT height )
    { 
      if( !data.is_array() )
      {
        draw_message( gx, width, height, const_wchars(L"Data not found") );
        return; 
      }

      color black(0,0,0);

       // x axis
      gx.line_cap(LINE_CAP_BUTT);
      gx.line_color(black);
      gx.line( 0.5, height - 0.5, width - 0.5, height - 0.5 ); // 0.5 - to draw line in the middle of the pixel

      for( int n = 0; n < data.length(); ++n )
      {
        json::value bar_def = data[n];
        json::value color_v = bar_def.k2v(L"color"); 
        json::value value_v = bar_def.k2v(L"value");
        if( color_v.is_undefined() || value_v.is_undefined())
        {
          draw_message( gx, width, height, const_wchars(L"Bad data structure") );
          return; 
        }
        draw_bar(gx, width, height, n, data.length(), color(color_v.get(0)), value_v.get(1.0));
      }
    }
    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 );
       }
    }
Ejemplo n.º 4
0
 virtual void draw_message( graphics& gx, UINT width, UINT height, aux::wchars text )
 {
     gx.text_alignment(TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
     gx.font("Arial", 17);
     gx.no_line();
     gx.fill_color(color(0xFF,0,0));
     gx.text(width / 2, height / 2, text);
 }
Ejemplo n.º 5
0
		void image::stretch(const nana::rectangle& r_src, graphics& dst, const nana::rectangle & r_dst) const
		{
			if (image_ptr_)
			{
				if (dst.empty())
					dst.make({ r_src.width, r_src.height });	//throws if failed to create

				image_ptr_->stretch(r_src, dst, r_dst);
			}
			else
				throw std::runtime_error("image is empty");
		}
Ejemplo n.º 6
0
	void cross(graphics& graph, int x, int y, uint32_t size, uint32_t thickness, nana::color_t color)
	{
		if(thickness + 2 <= size)
		{
			int gap = (size - thickness) / 2;

			nana::point ps[12];
			ps[0].x = x + gap;
			ps[1].x = ps[0].x + thickness - 1;
			ps[1].y = ps[0].y = y;

			ps[2].x = ps[1].x;
			ps[2].y = y + gap;

			ps[3].x = ps[2].x + gap;
			ps[3].y = ps[2].y;

			ps[4].x = ps[3].x;
			ps[4].y = ps[3].y + thickness - 1;

			ps[5].x = ps[1].x;
			ps[5].y = ps[4].y;

			ps[6].x = ps[5].x;
			ps[6].y = ps[5].y + gap;

			ps[7].x = x + gap;
			ps[7].y = ps[6].y;

			ps[8].x = ps[7].x;
			ps[8].y = ps[4].y;

			ps[9].x = x;
			ps[9].y = ps[4].y;

			ps[10].x = x;
			ps[10].y = y + gap;

			ps[11].x = x + gap;
			ps[11].y = y + gap;

			nana::color_t dkcolor = graph.mix(color, 0x0, 0.5);
			for(int i = 0; i < 11; ++i)
				graph.line(ps[i], ps[i + 1], dkcolor);
			graph.line(ps[11], ps[0], dkcolor);

			graph.rectangle(ps[10].x + 1, ps[10].y + 1, (gap << 1) + thickness - 2, thickness - 2, color, true);
			graph.rectangle(ps[0].x + 1, ps[0].y + 1, thickness - 2, (gap << 1) + thickness - 2, color, true);

		}
	}
Ejemplo n.º 7
0
void printout::paint( graphics &g )
{
#if 0
	g.setColor( Color.black );
	for (int i=0; i < _list_cnt; ++i)
		g.drawString( _list[i], _off_x + 1, _off_y + (i+1) * 14 + 1 );

	g.setColor( _c1 );
	for (int i=0; i < _list_cnt; ++i)
		g.drawString( _list[i], _off_x, _off_y + (i+1) * 14 );
#endif

	_list_cnt = 0;
}
Ejemplo n.º 8
0
void ImageWrapper::clear()
{
    m_image.reset();
    m_texture.reset();
    m_fbo.reset();

    m_source = NONE;

    m_buffer.clear();
    m_size = Size();
}
 void draw_caption( HELEMENT he, graphics& gx, UINT width, UINT height, aux::wchars text )
 {
     gx.state_save();
       //gx.rotate(3.1415926 / 2, width / 2, height / 3); // for text rotation testing.
       gx.text_alignment(TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
       gx.font("Times New Roman", 18);
       gx.no_line();
       gx.fill_linear_gradient( width/3,0,(2*width)/3, 0, color(0xDF,0,0), color(0,0,0x7F));
       gx.text(width / 2, height / 3, text);
       //gx.rectangle(0,0,width / 2, height / 3);
     gx.state_restore();
 }