void glcd::DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color) { DrawHLine(x, y, width, color); // top DrawHLine(x, y + height, width, color); // bottom DrawVLine(x, y, height, color); // left DrawVLine(x + width, y, height, color); // right }
// ------------------------------------------------------ // Draw a bevelled box on the screen void Gadgets::Draw_Box(int x, int y, int width, int height, int reversed, int colhi, int colmid, int collo, int bevel) { int Color; SetColor(colmid); if(bevel) { Fillrect(x - 1 + (reversed ? 2 : 0), y - 1 + (reversed ? 2 : 0), x + width - 1 - (reversed ? 2 : 0), y + height - 1 - (reversed ? 2 : 0)); Color = reversed ? colhi : collo; DrawVLine(x + width - 2, y, y + height - 2, Color); DrawHLine(y + height - 2, x, x + width - 2, Color); Color = reversed ? collo : colhi; DrawVLine(x - 1, y - 1, y + height - 3, Color); DrawHLine(y - 1, x - 1, x + width - 3, Color); } else { Fillrect(x, y, x + width - 2, y + height - 2); } }
void RenderBuffer::DrawCircle(int x0, int y0, int radius, const xlColor& rgb, bool filled, bool wrap) { int x = radius; int y = 0; int radiusError = 1 - x; while(x >= y) { if (!filled) { SetPixel(x + x0, y + y0, rgb, wrap); SetPixel(y + x0, x + y0, rgb, wrap); SetPixel(-x + x0, y + y0, rgb, wrap); SetPixel(-y + x0, x + y0, rgb, wrap); SetPixel(-x + x0, -y + y0, rgb, wrap); SetPixel(-y + x0, -x + y0, rgb, wrap); SetPixel(x + x0, -y + y0, rgb, wrap); SetPixel(y + x0, -x + y0, rgb, wrap); } else { DrawVLine(x0 - x, y0 - y, y0 + y, rgb, wrap); DrawVLine(x0 + x, y0 - y, y0 + y, rgb, wrap); DrawVLine(x0 - y, y0 - x, y0 + x, rgb, wrap); DrawVLine(x0 + y, y0 - x, y0 + x, rgb, wrap); } y++; if (radiusError<0) { radiusError += 2 * y + 1; } else { x--; radiusError += 2 * (y - x) + 1; } } }
// judb draw a 'lowered button' border based on the given color void CPainter::Draw3DLoweredRect(const CRect& Rect, const CRGBColor& Color) { CRect RealRect(Rect); if (m_pWindow) { RealRect = Rect + m_pWindow->GetClientRect().TopLeft(); RealRect.ClipTo(m_pWindow->GetClientRect()); } DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), Color * 0.3); DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), Color * 1.6); DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), Color * 0.3); DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), Color * 1.6); }
/////////////////// // Draw the scrollbar void CScrollbar::Draw(SDL_Surface * bmpDest) { int x=0; int length; // Top arrow if(bTopButton) x=15; DrawImageAdv(bmpDest, gfxGUI.bmpScrollbar, x,0, iX,iY, 15,14); // Bottom arrow x=0; if(bBotButton) x=15; DrawImageAdv(bmpDest, gfxGUI.bmpScrollbar, x,14, iX,iY+iHeight-14, 15,14); // Main bit DrawRectFill(bmpDest, iX,iY+14, iX+iWidth, iY+iHeight-14, tLX->clScrollbarBack); DrawVLine(bmpDest, iY+14, iY+iHeight-14, iX,tLX->clScrollbarBackLight); DrawVLine(bmpDest, iY+14, iY+iHeight-14, iX+iWidth,tLX->clScrollbarBackLight); // Slider if(iMax > iItemsperbox && iMax > 0) { length = (int)((float)iItemsperbox/(float)iMax * iHeight-30); length = MAX(length, 12); int pos = iScrollPos; if(pos+length > iHeight-30) pos=iHeight-30-length; if (pos < 0) pos = 0; DrawRectFill(bmpDest, iX+2, iY+15+pos, iX+iWidth-1, iY+15+pos+length, tLX->clScrollbarFront); // Shine DrawVLine(bmpDest, iY+15+pos, iY+15+pos+length, iX+1, tLX->clScrollbarHighlight); DrawHLine(bmpDest, iX+1, iX+iWidth-1, iY+15+pos, tLX->clScrollbarHighlight); // Dark DrawVLine(bmpDest, iY+15+pos, iY+15+pos+length, iX+iWidth-1, tLX->clScrollbarShadow); DrawHLine(bmpDest, iX+1, iX+iWidth-1, iY+15+pos+length, tLX->clScrollbarShadow); } // Slight hack if( !GetMouse()->Button ) { bTopButton=false; bBotButton=false; } }
void ScrnInit(void) { InitText(); signal(SIGINT, SevereErrorSIGINT); signal(SIGSEGV, SevereErrorSIGSEGV); #ifdef SIGQUIT signal(SIGQUIT, SevereErrorSIGQUIT); #endif LastCheck = StartTime = (long)I_FloatTime(); SetForeColor(ANSI_WHITE); SetBackColor(ANSI_BLUE); DrawFilledBox(0, 0, ScrnWidth, ScrnHeight); StatusLine = 5; MoveCurs(2, 1); SetForeColor(ANSI_WHITE); SetBackColor(ANSI_BLUE); DrawVLine(45, 5, ScrnHeight - 6); DrawHLine(1, 4, ScrnWidth - 2); DrawHLine(1, 2, ScrnWidth - 2); MoveCurs(2, 3); CPrintf("$f3Elapsed time: $f200:00:00 $f7By Lee Smith <[email protected]$f7>$f3"); remove("error.log"); }
void CPainter::DrawLine(const CPoint& Point1, const CPoint& Point2, const CRGBColor& LineColor) { if (Point1.XPos() == Point2.XPos()) { DrawVLine(Point1.YPos(), Point2.YPos(), Point1.XPos(), LineColor); } else { double iSlope = double(Point2.YPos() - Point1.YPos()) / (Point2.XPos() - Point1.XPos()); if (iSlope <= 1 && iSlope >= -1) { CPoint StartPoint = (Point1.XPos() < Point2.XPos()) ? Point1 : Point2; CPoint EndPoint = (Point1.XPos() < Point2.XPos()) ? Point2 : Point1; for (int x = StartPoint.XPos(); x <= EndPoint.XPos(); ++x) { DrawPoint(CPoint(x, stdex::safe_static_cast<int>(StartPoint.YPos() + (x - StartPoint.XPos()) * iSlope)), LineColor); } } else { CPoint StartPoint = (Point1.YPos() < Point2.YPos()) ? Point1 : Point2; CPoint EndPoint = (Point1.YPos() < Point2.YPos()) ? Point2 : Point1; for (int y = StartPoint.YPos(); y <= EndPoint.YPos(); ++y) { DrawPoint(CPoint(stdex::safe_static_cast<int>(StartPoint.XPos() + (y - StartPoint.YPos()) / iSlope), y), LineColor); } } } }
void vline(ALLEGRO_BITMAP *bmp, int x, int y1, int y2, int color) { sub_to_abs_coords(bmp, x, y1); sub_to_abs_coords_y(bmp, y2); DrawVLine(bmp->surf.get(), y1, y2, x, allegcol_to_Col(color)); /* for(int y = y1; y < y2; ++y) if(abscoord_in_bmp(bmp, x, y)) putpixel(bmp, x, y, color);*/ }
void DrawTest(void){ uint32_t h,v; uint16_t dark = 0; uint32_t c = 0; uint16_t col = 0; uint32_t pixel = 0; DrawBox(0,0,0,HLEN-1,VLEN-1); /* DrawHLine(-1,0,0,20);*/ /* DrawBox(0xAA,270,190,370,290);*/ // DrawHLine(0x55,0,0,HLEN-1); //DrawHLine(0x55,VLEN-1,0,HLEN-1); DrawVLine(0x55,0,0,VLEN-1); DrawVLine(0x55,HLEN-1,0,VLEN-1); WaitMs(100); for (h = 0; h < HLEN; ++h) { pixel++; if (pixel == 10){ pixel = 0; dark++; } if (dark == 16) { c++; dark = 0; } if (c == 4) { c = 0; } col = 0; switch (c) { case 0: col = (dark << 1); break; case 1: col = (dark << 7); break; case 2: col = (dark << 12); break; case 3: col = (dark << 1) | (dark << 7) | (dark << 12); break; } DrawPoint(col,h,0); } for (v = 1; v < VLEN; ++v) { DrawCopyHLine(v-1,v); } }
void CPainter::DrawRect(const CRect& Rect, bool bFilled, const CRGBColor& BorderColor, const CRGBColor& FillColor) { CRect RealRect(Rect); if (m_pWindow) { RealRect = Rect + m_pWindow->GetClientRect().TopLeft(); RealRect.ClipTo(m_pWindow->GetClientRect()); } if (!bFilled || (BorderColor != FillColor)) { DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Top(), BorderColor); DrawHLine(RealRect.Left(), RealRect.Right(), RealRect.Bottom(), BorderColor); DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Left(), BorderColor); DrawVLine(RealRect.Top(), RealRect.Bottom(), RealRect.Right(), BorderColor); RealRect.Grow(-1); //In case we have to fill the rect, then it's ready to go. } if (bFilled) { if (m_PaintMode == PAINT_REPLACE) { SDL_Rect FillRect = RealRect.SDLRect(); SDL_FillRect(m_pSurface, &FillRect, FillColor.SDLColor(m_pSurface->format)); } else { for (int iY = RealRect.Top(); iY <= RealRect.Bottom(); ++iY) { for (int iX = RealRect.Left(); iX <= RealRect.Right(); ++iX) { DrawPoint(CPoint(iX, iY), FillColor); } } } } }
void DrawPenCues(Image *Img,int ShowDialpad,pixel Color) { pixel *P; int W,H,W9,W3,H3; P = (pixel *)Img->Data; W = Img->W; H = Img->H; W9 = W/9; W3 = W/3; H3 = H/3; /* Vertical edges */ DrawVLine(Img,W3,0,H-1,Color); DrawVLine(Img,W-W3,0,H-1,Color); /* Corner buttons */ DrawHLine(Img,0,W3,H>>4,Color); DrawHLine(Img,W-W3,W-1,H>>4,Color); DrawHLine(Img,0,W3,H-(H>>4),Color); DrawHLine(Img,W-W3,W-1,H-(H>>4),Color); /* Fire buttons (with overlap) */ DrawHLine(Img,W-W3,W-1,(H>>1)-(H>>4),Color); DrawHLine(Img,W-W3,W-1,(H>>1)+(H>>4),Color); /* Directional buttons */ DrawVLine(Img,W9,H>>4,H-(H>>4),Color); DrawVLine(Img,W3-W9,H>>4,H-(H>>4),Color); DrawHLine(Img,0,W3,H3,Color); DrawHLine(Img,0,W3,H-H3,Color); /* Button labels */ PrintXY(Img,"L",2,2,Color,-1); PrintXY(Img,"R",W-W3+2,2,Color,-1); PrintXY(Img,"B",W-W3+2,(H>>4)+2,Color,-1); PrintXY(Img,"A+B",W-W3+2,(H>>1)-(H>>4)+2,Color,-1); PrintXY(Img,"A",W-W3+2,(H>>1)+(H>>4)+2,Color,-1); PrintXY(Img,"SELECT",2,H-(H>>4)+2,Color,-1); PrintXY(Img,"START",W-W3+2,H-(H>>4)+2,Color,-1); /* If requested, show on-screen dialpad */ if(ShowDialpad) { DrawHLine(Img,W3,W-W3,H>>2,Color); DrawHLine(Img,W3,W-W3,H>>1,Color); DrawHLine(Img,W3,W-W3,H-(H>>2),Color); DrawVLine(Img,W3+W9,0,H-1,Color); DrawVLine(Img,W-W3-W9,0,H-1,Color); PrintXY(Img,"1",W3+2,2,Color,-1); PrintXY(Img,"2",W3+W9+2,2,Color,-1); PrintXY(Img,"3",W-W3-W9+2,2,Color,-1); PrintXY(Img,"4",W3+2,(H>>2)+2,Color,-1); PrintXY(Img,"5",W3+W9+2,(H>>2)+2,Color,-1); PrintXY(Img,"6",W-W3-W9+2,(H>>2)+2,Color,-1); PrintXY(Img,"7",W3+2,(H>>1)+2,Color,-1); PrintXY(Img,"8",W3+W9+2,(H>>1)+2,Color,-1); PrintXY(Img,"9",W-W3-W9+2,(H>>1)+2,Color,-1); PrintXY(Img,"*",W3+2,H-(H>>2)+2,Color,-1); PrintXY(Img,"0",W3+W9+2,H-(H>>2)+2,Color,-1); PrintXY(Img,"#",W-W3-W9+2,H-(H>>2)+2,Color,-1); } }