void GUICheckBox::Draw(SDL_Surface *dst){ if(isCircle){ int rad = ((posX2-posX1<posY2-posY1)?(posX2-posX1):(posY2-posY1))-7; filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,0xFFFFFFFF); arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,135,315,0x000000FF); arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad+1,135,315,0x808080FF); arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad,315,135,0xD4D0C8FF); arcColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad+1,315,135,0xFFFFFFFF); if(isChecked)filledCircleColor(dst,(posX1+posX2)/2,(posY1+posY2)/2,rad-3,0x000000FF); }else{ boxColor(dst,posX1,posY1,posX2,posY2,0xFFFFFFFF); GUIDrawBorder(dst,posX1,posY1,posX2,posY2,0x808080FF,0x404040FF,0xFFFFFFFF,0xD4D0C8FF); if(isChecked){ int tickX=((posX2+posX1)/2)-2,tickY=((posY2+posY1)/2)-3; Uint32 clr=0x000000FF; boxColor(dst,tickX+1,tickY+4,tickX+3,tickY+5,clr); boxColor(dst,tickX+4,tickY+2,tickX+5,tickY+3,clr); vlineColor(dst,tickX,tickY+2,tickY+4,clr); vlineColor(dst,tickX+6,tickY,tickY+2,clr); pixelColor(dst,tickX+1,tickY+3,clr); pixelColor(dst,tickX+3,tickY+3,clr); pixelColor(dst,tickX+4,tickY+4,clr); pixelColor(dst,tickX+5,tickY+1,clr); pixelColor(dst,tickX+2,tickY+6,clr); } } }
static PyObject* _gfx_arccolor (PyObject *self, PyObject* args) { PyObject *surface, *color, *pt; int x, y, r, start, end; pguint32 c; ASSERT_VIDEO_INIT (NULL); if (!PyArg_ParseTuple (args, "OOiiiO:arc", &surface, &pt, &r, &start, &end, &color)) { PyErr_Clear (); if (!PyArg_ParseTuple (args, "OiiiiiO:arc", &surface, &x, &y, &r, &start, &end, &color)) return NULL; } else { if (!PointFromObj (pt, &x, &y)) return NULL; } if (!PySDLSurface_Check (surface)) { PyErr_SetString (PyExc_TypeError, "surface must be a Surface"); return NULL; } if (!ColorFromObj (color, &c)) return NULL; if (arcColor (((PySDLSurface*)surface)->surface, (Sint16)x, (Sint16)y, (Sint16)r, (Sint16)start, (Sint16)end, (Uint32)c) == -1) { PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return NULL; } Py_RETURN_NONE; }
/** * Desenhador de RectNoScrolling retirado da SDL_gfx mais nova. */ int Sprite::drawRoundRectNoScrolling(Rectangle rect, int r, int g, int b, int a, int rad, Screen *screen) { SDL_Surface * dst; Sint16 x1, y1, x2, y2; Uint32 color; int result; dst = screen->getTopScreen(); x1 = rect.x; x2 = rect.x + rect.w; y1 = rect.y; y2 = rect.y + rect.h; color = ((Uint32) r << 24) | ((Uint32) g << 16) | ((Uint32) b << 8) | (Uint32) a; Sint16 w, h, tmp; Sint16 xx1, xx2, yy1, yy2; /* * Check destination surface */ if (dst == NULL) { return -1; } /* * Check radius vor valid range */ if (rad < 0) { return -1; } /* * Special case - no rounding */ if (rad == 0) { return rectangleColor(dst, x1, y1, x2, y2, color); } /* * Check visibility of clipping rectangle */ if ((dst->clip_rect.w==0) || (dst->clip_rect.h==0)) { return 0; } /* * Test for special cases of straight lines or single point */ if (x1 == x2) { if (y1 == y2) { return (pixelColor(dst, x1, y1, color)); } else { return (vlineColor(dst, x1, y1, y2, color)); } } else { if (y1 == y2) { return (hlineColor(dst, x1, x2, y1, color)); } } /* * Swap x1, x2 if required */ if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; } /* * Swap y1, y2 if required */ if (y1 > y2) { tmp = y1; y1 = y2; y2 = tmp; } /* * Calculate width&height */ w = x2 - x1; h = y2 - y1; /* * Maybe adjust radius */ if ((rad * 2) > w) { rad = w / 2; } if ((rad * 2) > h) { rad = h / 2; } /* * Draw corners */ result = 0; xx1 = x1 + rad; xx2 = x2 - rad; yy1 = y1 + rad; yy2 = y2 - rad; result |= arcColor(dst, xx1, yy1, rad, 180, 270, color); result |= arcColor(dst, xx2, yy1, rad, 270, 360, color); result |= arcColor(dst, xx1, yy2, rad, 90, 180, color); result |= arcColor(dst, xx2, yy2, rad, 0, 90, color); /* * Draw lines */ if (xx1 <= xx2) { result |= hlineColor(dst, xx1, xx2, y1, color); result |= hlineColor(dst, xx1, xx2, y2, color); } if (yy1 <= yy2) { result |= vlineColor(dst, x1, yy1, yy2, color); result |= vlineColor(dst, x2, yy1, yy2, color); } return 1; }