int Button::draw_raised ( ) { // Draw Border: Stroke_l ( 0xFF000000 ); Roundrect( left, bottom, width, height, 15.0, 15.0); // use 2 rectangles: Stroke_l ( border_color ); Fill_l ( background_color ); Roundrect( left+1, bottom+1, width-2, height-2, 15.0, 15.0); // DRAW TEXT: float y = bottom + (height - text_size)/2.0; if (text==NULL) return 1; Fill_l (text_color); TextMid(left+width/2.0, y, text, SerifTypeface, text_size ); return 1; }
DrawButton(int ButtonIndex) { button_t *Button=&(ButtonArray[ButtonIndex]); Fill(Button->Status[Button->NoStatus].Color.r, Button->Status[Button->NoStatus].Color.g, Button->Status[Button->NoStatus].Color.b, 1); Roundrect(Button->x,Button->y,Button->w,Button->h, Button->w/10, Button->w/10); Fill(255, 255, 255, 1); // White text TextMid(Button->x+Button->w/2, Button->y+Button->h/2, Button->Status[Button->NoStatus].Text, SerifTypeface, Button->w/strlen(Button->Status[Button->NoStatus].Text)/*25*/); }
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; }
int Button::draw_sunken ( ) { //Fill_l(text_color); Stroke_l ( background_color ); Fill_l ( background_color ); Roundrect( left, bottom, width, height, 15.0, 15.0); if (text==NULL) return 1; Fill_l (text_color); float y = bottom + (height - text_size)/2.0; TextMid(left+width/2.0, y, text, SerifTypeface, text_size ); return 1; }
//------------------------------------------------------------------------------ void term_show(tTermState * ts, bool swap) { if (ts->image == 0) return; clear_screen(false); vgSetPixels(ts->tvXY.x, ts->tvXY.y, ts->image, 0, 0, ts->tv_width, ts->tv_height); Roundrect(ts->imageXY.x, ts->imageXY.y, ts->image_width, ts->image_height, 20, 20, numRectPenSize, rectColor, bgColor); int x, y; char temp[2]; temp[1] = 0x00; tPointXY pos; pos.x = ts->txtXY.x; pos.y = ts->txtXY.y; tScrChr * pBuff = &ts->term_vbuff[0]; for (y = 0; y < ts->term_h ; y++) { for(x = 0; x < ts->term_w ; x++) { temp[0] = pBuff->c; Text(&fontDefs[ts->numFont], //Topaz font pos.x, pos.y, temp, ts->numPointFont, &colorScheme[pBuff->color], VG_FILL_PATH); pos.x += ts->term_x_inc; pBuff++; } pos.y -= ts->term_y_inc; pos.x = ts->txtXY.x; } if(swap) eglSwapBuffers(state->display, state->surface); }
void show_osd(int played, int duration, char* title) { if (MAIN_OSD == NULL) { // Calling ``init_osd`` everytime seems wasteful, but it is needed to // ensure that the OSD is visible. The main issue is that if the player // is stopped and then restarted, the graphics library needs to be // reinitalized, otherwise the OSD is not drawn ontop of the video. init_osd(); } OSD* osd = MAIN_OSD; if (played > duration) { played = duration; } osd->duration = duration; osd->played = played; osd->title = title; Start(osd->width, osd->height); Fill(255,255,255,1); Text(32, 120+82+20, "PAUSED", OpenSansBold, 16); // Main OSD background Fill(0, 0, 0, 0.5); Roundrect(22, 82, osd->width-44, 120, 15, 15); /////////////////////////////////////////////////////////////////////// // Header /////////////////////////////////////////////////////////////////////// Fill(0, 0, 0, 1); Roundrect(22, 120+82-20, osd->width-44, 20, 15, 15); // Top of the header Rect(22, 120+82-(54+10), osd->width-44, 54); // Bottom of header // Current time get_time(osd->time_now, 0); Fill(102, 102, 102, 1); Text(46, 162, osd->time_now, OpenSansSemiBold, 14); // End time if (duration > 0) { get_time(osd->time_end, osd->duration-osd->played); TextEnd(osd->width-46, 162, osd->time_end, OpenSansSemiBold, 14); } // Title text Fill(255, 255, 255, 1); int title_width = TextWidth(osd->title, OpenSansSemiBold, 20); Text((osd->width/2)-(title_width/2), 162, osd->title, OpenSansSemiBold, 20); /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Progress Bar /////////////////////////////////////////////////////////////////////////// if (duration > 0) { int pbar_width = osd->width-288; float pct_player = (float)played/duration; Fill(255, 255, 255, 0.2); // Transparent bg Roundrect(142, 102, pbar_width, 12, 10, 10); // Centered Fill(209, 125, 30, 1); // Orange bar (progress) Roundrect(142, 102, pbar_width*pct_player, 12, 10, 10); // Left justified // Progress text seconds_to_str(osd->pos_now, osd->played); seconds_to_str(osd->pos_end, osd->duration-osd->played); // Text shadow Fill(0, 0, 0, 1); Text(46-1, 102-1, osd->pos_now, OpenSansSemiBold, 12); TextEnd(osd->width-46-1, 102-1, osd->pos_end, OpenSansSemiBold, 12); // Actual text Fill(255,255,255,1); Text(46, 102, osd->pos_now, OpenSansSemiBold, 12); TextEnd(osd->width-46, 102, osd->pos_end, OpenSansSemiBold, 12); } ////////////////////////////////////////////////////////////////////// End(); }
// 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(); }