/** Draw a box */ GFX_RESULT gfx_common_DrawBox(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, GFX_COLOR color) { uint16_t step, delta; // Wrap the operation in begin/end paint calls gfx_BeginPaint(); // Do the horizontal lines delta = (x2>x1)?1:-1; for(step=x1; step!=(x2 + delta); step+=delta) { gfx_PutPixel(step, y1, color); gfx_PutPixel(step, y2, color); } // Do the vertical lines delta = (y2>y1)?1:-1; for(step=y1 + delta; step!=(y2 + delta); step+=delta) { gfx_PutPixel(x1, step, color); gfx_PutPixel(x2, step, color); } gfx_EndPaint(); return GFX_RESULT_OK; }
/** Draw a portion of an image to the display * * Another straight forward, brute force implementation. Once again it depends * on the drivers PutPixel implementation to handle any clipping required * and doesn't do any error or bounds checking of it's parameters. * * @param x the X co-ordinate at which to display the icon portion. * @param y the Y co-ordinate at which to display the icon portion. * @param pIcon the icon to use as the source. * @param sx the X co-ordinate within the icon to start displaying. * @param xy the Y co-ordinate within the icon to start displaying. * @param w the width of the portion to display. * @param h the width of the portion to display. * @param mask an icon to use as a mask. */ GFX_RESULT gfx_common_DrawImage16(uint16_t x, uint16_t y, GFX_IMAGE *pImage, uint8_t sx, uint8_t sy, uint8_t w, uint8_t h, GFX_IMAGE *pMask) { uint16_t dx, dy; MASK_INFO infoMask; // Verify image data if((pImage==NULL)||(pImage->m_header.m_bpp!=IMAGE_BPP_16)) return GFX_RESULT_BADARG; // Set the width and height if needed if((w<0)||((sx + w)>(pImage->m_header.m_width + 1))) w = pImage->m_header.m_width - sx; if((h<0)||((sy + h)>(pImage->m_header.m_height + 1))) h = pImage->m_header.m_height - sy; int bpl = GFX_LINE_LENGTH(pImage, 16); // Handle using a mask if(pMask!=NULL) { // Make sure the mask is a monochrome image if((pMask->m_header.m_bpp!=IMAGE_BPP_1)||(pMask->m_header.m_width!=pImage->m_header.m_width)||(pMask->m_header.m_height!=pImage->m_header.m_height)) return GFX_RESULT_BADARG; maskInitInfo(&infoMask, pMask); // Draw the pixels for(dy=0;dy<h;dy++) { for(dx=0;dx<w;dx++) { if(maskGetPixel(&infoMask, sx + dx, sy + dy)) gfx_PutPixel(x + dx, y + dy, getImage16Pixel(pImage, sx + dx, sy + dy, bpl)); } } } else { // Draw the pixels for(dy=0;dy<h;dy++) { for(dx=0;dx<w;dx++) { gfx_PutPixel(x + dx, y + dy, getImage16Pixel(pImage, sx + dx, sy + dy, bpl)); } } } // All done return GFX_RESULT_OK; }
/* * Class: com_thegaragelab_quickui_Driver * Method: gfxPutPixel * Signature: (III)I */ JNIEXPORT jint JNICALL Java_com_thegaragelab_quickui_Driver_gfxPutPixel(JNIEnv *pEnv, jobject obj, jint x, jint y, jint color) { return (jint)gfx_PutPixel(x, y, color); }
void gfx_Part2(void) { int i ; int k ; int l ; WORD orbitx ; WORD orbity ; WORD vx[20] ; // : array[0..19] of word ; WORD vy[20] ; // : array[0..19] of word ; gfx_Cls() ; putstr("gfx_M to gfx_T") ; printf("gfx_M to gfx_T") ; k = 180 ; l = 80 ; gfx_MoveTo(k, l); gfx_CircleFilled(k,l,5,BLUE) ; i = -90; // 12 o'clock position while (i<270) { gfx_Orbit(i, 30, &orbitx, &orbity); k = 3; if ((i % 90) == 0 ) k = 5; gfx_Circle(orbitx , orbity, k, BLUE); i += 30; // each 30 degreees } gfx_OutlineColour(YELLOW) ; gfx_Panel(PANEL_RAISED,140,0,190,20, LIME) ; gfx_OutlineColour(0) ; // turn outline off vx[0] = 36; vy[0] = 110; vx[1] = 36; vy[1] = 80; vx[2] = 50; vy[2] = 80; vx[3] = 50; vy[3] = 110; vx[4] = 76; vy[4] = 104; vx[5] = 85; vy[5] = 80; vx[6] = 94; vy[6] = 104; vx[7] = 76; vy[7] = 70; vx[8] = 85; vy[8] = 76; vx[9] = 94; vy[9] = 70; vx[10] = 110; vy[10] = 66; vx[11] = 110; vy[11] = 80; vx[12] = 100; vy[12] = 90; vx[13] = 120; vy[13] = 90; vx[14] = 110; vy[14] = 80; vx[15] = 101; vy[15] = 70; vx[16] = 110; vy[16] = 76; vx[17] = 119; vy[17] = 70; // house gfx_Rectangle(6,50,66,110,RED); // frame gfx_Triangle(6,50,36,9,66,50,YELLOW); // roof gfx_Polyline(4, vx, vy, CYAN); // door // man gfx_Circle(85, 56, 10, BLUE); // head gfx_Line(85, 66, 85, 80, BLUE); // body gfx_Polyline(3, &vx[4], &vy[4], CYAN); // legs gfx_Polyline(3, &vx[7], &vy[7], BLUE); // arms // woman gfx_Circle(110, 56, 10, PINK); // head gfx_Polyline(5, &vx[10], &vy[10], BROWN); // dress gfx_Line(104, 104, 106, 90, PINK); // left arm gfx_Line(112, 90, 116, 104, PINK); // right arm gfx_Polyline(3, &vx[15], &vy[15], SALMON); // dress vx[0] = 10; vy[0] = 130; vx[1] = 35; vy[1] = 125; vx[2] = 80; vy[2] = 130; vx[3] = 60; vy[3] = 145; vx[4] = 80; vy[4] = 160; vx[5] = 35; vy[5] = 170; vx[6] = 10; vy[6] = 160; gfx_Polygon(7, vx, vy, RED); vx[0] = 110; vy[0] = 130; vx[1] = 135; vy[1] = 125; vx[2] = 180; vy[2] = 130; vx[3] = 160; vy[3] = 145; vx[4] = 180; vy[4] = 160; vx[5] = 135; vy[5] = 170; vx[6] = 110; vy[6] = 160; gfx_PolygonFilled(7, vx, vy, RED); gfx_PutPixel(40, 94, LIME) ; // door knob gfx_Rectangle(0,180, 10,200, AQUA) ; gfx_RectangleFilled(20,180, 40,200, ORANGE) ; gfx_ScreenCopyPaste(0,0, 0,280, 40,40) ; gfx_ScreenMode(LANDSCAPE) ; //gfx_Set(CLIPPING, ON) ; //gfx_SetClipRegion() ; gfx_Slider(SLIDER_RAISED, 210, 100, 250,10, BLUE, 100, 50) ; // coordinates are different because we are in landscape mode gfx_ScreenMode(PORTRAIT) ; gfx_Transparency(ON) ; gfx_TransparentColour(YELLOW) ; // how do we 'test' this? gfx_Triangle(6,250, 36,209, 66,250,YELLOW); gfx_TriangleFilled(110,210, 130,210, 120,230,CYAN); }