Esempio n. 1
0
int   	FreeFormDrawing::draw 		(	)
{
	Control::draw();
	list<vector<VGuint>>::iterator   SCiter    = m_stroke_color.begin();
	list<vector<VGufloat>>::iterator SWiter    = m_stroke_widths.begin();
	list<vector<VGubyte>>::iterator  Cmditer   = m_commands.begin();
	list<vector<VGufloat>>::iterator Coorditer = m_coords.begin();

	for ( ; Coorditer!=m_coords.end(); )
	{
		int numCmds   = Cmditer.size();
		int numCoords = Coorditer.size();		
		VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
							VG_PATH_DATATYPE_F,
							1.0f, 0.0f, 		// scale,bias
							numCmds, numCoords,
							VG_PATH_CAPABILITY_ALL);
		StrokeWidth	( *SWiter 	 );
		Stroke_l	( 0xFFFF00FF );

		vgAppendPathData(path, numCmds, commands, Coorditer->data() );
		vgDrawPath		(path, VG_STROKE_PATH			);		

		SCiter++;		SWiter++;
		Cmditer++;		Coorditer++;
	}
}
Esempio n. 2
0
// Start begins the picture, clearing a rectangular region with a specified color
void Start(int width, int height) {
	VGfloat color[4] = { 1, 1, 1, 1 };
	vgSetfv(VG_CLEAR_COLOR, 4, color);
	vgClear(0, 0, width, height);
	color[0] = 0, color[1] = 0, color[2] = 0;
	setfill(color);
	setstroke(color);
	StrokeWidth(0);
	vgLoadIdentity();
}
Esempio n. 3
0
int StickLeg::draw()
{
	Control::draw();
	
	float angles[3];
	if (mp==NULL) return 0;
	mp->get_angle_vector( angles, 3 );
	//printf("StickLeg:a0=%6.1f a1=%6.1f a2=%6.1f\n", angles[0], angles[1], angles[2]);
	
	Fill_l  ( Leg_color );
	Stroke_l( Leg_color );
	StrokeWidth(3);	
		 
	//printf("================%s: width=%6.1f  height=%6.1f \n", text, AbdominBox.width, AbdominBox.height  );
	//AbdominBox.width  = 10.0;	// these get clobbered if only inited in constructor.
	//AbdominBox.height = 15.0;

	// ABDOMIN:
	// center of abdomin is 3/4 height of control.
	// Add Tilt Sensor AccelAngularPosition.rx rotation here.	
	AbdominBox.bottom = bottom + 3.0*height/4.0 - AbdominBox.height/2.0;
	AbdominBox.left   = left + width/2.0;

	Translate(AbdominBox.left+AbdominBox.width/2.0, AbdominBox.bottom);
	Rotate   (AbAngle);	
	Roundrect(0., 0., AbdominBox.width, AbdominBox.height, 2.0, 2.0);
	
	// UPPER LEG:
	//Translate(AbdominBox.left+AbdominBox.width/2.0,AbdominBox.bottom);					
	Rotate(angles[0]);			// hip
	float y = -height/4.0;
	Line(0., 0., 0., y);

	// LOWER LEG:
	Translate(0, y);			// relative
	Rotate(angles[1]);			// knee
	Line(0., 0., 0., y);

	// FOOT:	
	Translate(0,y);	
	Rotate(angles[2]+M_PI/2);		// ankle
	Line(0., 0., AbdominBox.width, 0.);

	// need VG help on a translate to revert all the way back to normal.
	Rotate(-angles[2]-M_PI/2);	
	Translate(0,-y);		
	Rotate(-angles[1]);	
	Translate(0,-y);		
	Rotate(-angles[0]);
	
	Rotate(-AbAngle);
	Translate(-(AbdominBox.left+AbdominBox.width/2.0),-(AbdominBox.bottom));	
	return 0;
}
Esempio n. 4
0
// grid draws a grid
void grid(VGfloat x, VGfloat y, int n, int w, int h) {
	VGfloat ix, iy;
	Stroke(128, 128, 128, 0.5);
	StrokeWidth(2);
	for (ix = x; ix <= x + w; ix += n) {
		Line(ix, y, ix, y + h);
	}

	for (iy = y; iy <= y + h; iy += n) {
		Line(x, iy, x + w, iy);
	}
}
Esempio n. 5
0
void Leveler::draw_vertical_line( )
{
	Stroke(255, 128, 128, 0.5);
	StrokeWidth(4);

	VGfloat alpha = 1.0;				// start solid
	//VGfloat x_spacing = (width) / 10.0;	
	
	// VERTICAL
	Fill(255, 0, 125, alpha);
	Line(left, bottom+height, left, bottom);
}
Esempio n. 6
0
int Leveler::draw() 
{	
	Stroke		(255, 128, 128, 0.5);
	StrokeWidth (2);

	draw_l_title		(  );
	draw_horizontal_tics(  );
	draw_vertical_line  (  );
	draw_x_label	 	(  );
	draw_y_label	 	(  );

	draw_marker(  );
}
Esempio n. 7
0
void Leveler::draw_vertical_line( )
{
	Stroke(255, 128, 128, 0.5);
	StrokeWidth(4);

	int i;
	VGfloat x;
	VGfloat alpha = 1.0;				// start solid
	VGfloat x_spacing = (right-left) / 10.0;	
	
	// VERTICAL
	Fill(255, 0, 125, alpha);
	Line(left, top, left, bottom);
}
Esempio n. 8
0
void Leveler::draw_horizontal_tics(  ) 
{
	Stroke(255, 128, 128, 0.5);
	StrokeWidth(2);

	float alpha = 1.0;
	float y_spacing = ((float)(top - bottom)) / 10.0;	
	// HORIZONTAL
	Fill(255, 0, 125, alpha);
	for (VGfloat y = bottom; y <= top; y+=y_spacing) 
	{
		Line(left, y, left+TIC_WIDTH, y);
	}
}
Esempio n. 9
0
int Leveler::draw() 
{	
	if (!Visible) return 0;
	
	Stroke		(255, 128, 128, 0.5);
	StrokeWidth (2); 
 
	draw_l_title		(  );
	draw_horizontal_tics(  );
	draw_vertical_line  (  );
	draw_x_label	 	(  );
	draw_y_label	 	(  );

	draw_marker			(  );
	return 1;	
}
Esempio n. 10
0
/********************************************************************
 Comment on RoundRect & TextMid!!!!
	RoundRect Uses width / height as 2nd and 3rd parameters.
	Text characters come out the color of the Fill, not stroke!!
*********************************************************************/
int Button::draw()
{	
	//Control::draw();
	Stroke_l   ( border_color );		// box color
	StrokeWidth(2);

	//printf("text_size=%6.1f; %s\n", text_size, text);
	if (sunken)
	{
		draw_sunken();
	}
	else 
	{
		draw_raised();
	}  
	return 1;
}
Esempio n. 11
0
void Leveler::draw_marker(  )
{
	Stroke(255, 255, 0, 1.0);
	StrokeWidth(5);

	Fill(255, 0, 0, 1);
	VGfloat x[3];
	VGfloat y[3];

	y[0] = get_level_pixel();
	y[1] = get_level_pixel() + MARKER_HEIGHT/2;
	y[2] = get_level_pixel() - MARKER_HEIGHT/2;

	x[0] = left + TIC_WIDTH;
	x[1] = left + TIC_WIDTH + MARKER_WIDTH;
	x[2] = left + TIC_WIDTH + MARKER_WIDTH;	
	Polygon(x, y, 3);
}
Esempio n. 12
0
// refcard shows a reference card of shapes
void refcard(int width, int height) {
	char *shapenames[] = {
		"Circle",
		"Ellipse",
		"Rectangle",
		"Rounded Rectangle",
		"Line",
		"Polyline",
		"Polygon",
		"Arc",
		"Quadratic Bezier",
		"Cubic Bezier",
		"Image"
	};
	VGfloat shapecolor[4];
	RGB(202, 225, 255, shapecolor);
	VGfloat top = height * .95, sx = 500, sy = top, sw = width * .05, sh = height * .045, dotsize = 7, spacing = 2.0;

	int i, ns = sizeof(shapenames) / sizeof(char *), fontsize = height * .033;
	Start(width, height);
	sx = width * 0.10;

	Fill(128, 0, 0, 1);
	TextEnd(width - 20, height / 2, "OpenVG on the Raspberry Pi", fontsize + (fontsize / 2));
	Fill(0, 0, 0, 1);
	for (i = 0; i < ns; i++) {
		Text(sx + sw + sw / 2, sy, shapenames[i], fontsize);
		sy -= sh * spacing;
	}
	sy = top;
	VGfloat cx = sx + (sw / 2), ex = sx + sw;
	setfill(shapecolor);
	Circle(cx, sy, sw);
	coordpoint(cx, sy, dotsize, shapecolor);
	sy -= sh * spacing;
	Ellipse(cx, sy, sw, sh);
	coordpoint(cx, sy, dotsize, shapecolor);
	sy -= sh * spacing;
	Rect(sx, sy, sw, sh);
	coordpoint(sx, sy, dotsize, shapecolor);
	sy -= sh * spacing;
	Roundrect(sx, sy, sw, sh, 20, 20);
	coordpoint(sx, sy, dotsize, shapecolor);
	sy -= sh * spacing;

	StrokeWidth(1);
	Stroke(204, 204, 204, 1);
	Line(sx, sy, ex, sy);
	coordpoint(sx, sy, dotsize, shapecolor);
	coordpoint(ex, sy, dotsize, shapecolor);
	sy -= sh;

	VGfloat px[5] = { sx, sx + (sw / 4), sx + (sw / 2), sx + ((sw * 3) / 4), sx + sw };
	VGfloat py[5] = { sy, sy - sh, sy, sy - sh, sy };

	Polyline(px, py, 5);
	coordpoint(px[0], py[0], dotsize, shapecolor);
	coordpoint(px[1], py[1], dotsize, shapecolor);
	coordpoint(px[2], py[2], dotsize, shapecolor);
	coordpoint(px[3], py[3], dotsize, shapecolor);
	coordpoint(px[4], py[4], dotsize, shapecolor);
	sy -= sh * spacing;

	py[0] = sy;
	py[1] = sy - sh;
	py[2] = sy - (sh / 2);
	py[3] = py[1] - (sh / 4);
	py[4] = sy;
	Polygon(px, py, 5);
	sy -= (sh * spacing) + sh;

	Arc(sx + (sw / 2), sy, sw, sh, 0, 180);
	coordpoint(sx + (sw / 2), sy, dotsize, shapecolor);
	sy -= sh * spacing;

	VGfloat cy = sy + (sh / 2), ey = sy;
	Qbezier(sx, sy, cx, cy, ex, ey);
	coordpoint(sx, sy, dotsize, shapecolor);
	coordpoint(cx, cy, dotsize, shapecolor);
	coordpoint(ex, ey, dotsize, shapecolor);
	sy -= sh * spacing;

	ey = sy;
	cy = sy + sh;
	Cbezier(sx, sy, cx, cy, cx, sy, ex, ey);
	coordpoint(sx, sy, dotsize, shapecolor);
	coordpoint(cx, cy, dotsize, shapecolor);
	coordpoint(cx, sy, dotsize, shapecolor);
	coordpoint(ex, ey, dotsize, shapecolor);

	sy -= (sh * spacing * 1.5);
	Image(sx, sy, 100, 100, "starx.jpg");

	End();
}