void DrawOval(int x, int y, int rx, int ry, uint color, int is_fill) // 椭圆 { if (is_fill) filledEllipseColor(screen, x, y, rx, ry, color); else ellipseColor(screen, x, y, rx, ry, color); }
int GeoLayer::ellipse_fill(int16_t x, int16_t y, int16_t rx, int16_t ry, uint32_t col) { if(!surf) { error("%s can't run: layer not initialized", __PRETTY_FUNCTION__); return -1; } res = filledEllipseColor(surf, x, y, rx, ry, col); if(res < 0) error("error in %s", __PRETTY_FUNCTION__); return(res); }
void smallbullet(int x, int y, SDL_Surface *surface, style *st) { if(st->bullet3 != NULL) { SDL_Rect dst; dst.x = x - (st->bullet3->w / 2); dst.y = y - (st->bullet3->h / 2); SDL_BlitSurface(st->bullet3, NULL, surface, &dst); } else { Uint32 pen = colour->pens->item(st->bullet3colour); filledEllipseColor(surface, x, y, st->bullet3size, (st->bullet3size * 2) / 3, colour->light_grey_pen); filledEllipseColor(surface, x, y, st->bullet3size - 1, (st->bullet3size * 2) / 3 - 1, pen); } }
CAMLprim value ml_filledEllipseColor(value dst,value p,value rp, value col) { SDL_Surface *sur= SDL_SURFACE(dst); SDL_Rect prect,rprect; int r; SDLRect_of_value(&prect,p); SDLRect_of_value(&rprect,rp); r=filledEllipseColor(sur,prect.x,prect.y,rprect.x,rprect.y,Int32_val(col)); return Val_bool(r); }
static PyObject* _gfx_filledellipsecolor (PyObject *self, PyObject* args) { PyObject *surface, *color, *pt, *rd; int x, y, rx, ry; pguint32 c; ASSERT_VIDEO_INIT (NULL); if (!PyArg_ParseTuple (args, "OOOO:filled_ellipse", &surface, &pt, &rd, &color)) { PyErr_Clear (); if (!PyArg_ParseTuple (args, "OiiiiO:filled_ellipse", &surface, &x, &y, &rx, &ry, &color)) return NULL; } else { if (!PointFromObj (pt, &x, &y) || !PointFromObj (rd, &rx, &ry)) return NULL; } if (!PySDLSurface_Check (surface)) { PyErr_SetString (PyExc_TypeError, "surface must be a Surface"); return NULL; } if (!ColorFromObj (color, &c)) return NULL; if (filledEllipseColor (((PySDLSurface*)surface)->surface, (Sint16)x, (Sint16)y, (Sint16)rx, (Sint16)ry, (Uint32)c) == -1) { PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return NULL; } Py_RETURN_NONE; }
/** * Draws a filled ellipse on the surface. * @param x X coordinate in pixels. * @param y Y coordinate in pixels. * @param rx Radius in pixels on X axis. * @param ry Radius in pixels on Y axis. * @param color Color of the circle. */ void Surface::drawEllipse(Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint8 color) { filledEllipseColor(_surface, x, y, rx, ry, Palette::getRGBA(getPalette(), color)); }
void TMoveStatic::disp(SDL_Surface *sf, TFont *font, int x, int y, int w, int h, int myfg, int mybg, int xoptions) { int fg = myfg, bg = mybg; char buff[256]; /* Copy the string to allow to modify it without problem */ strcpy(buff,menu->label); char *s = buff; char *old = s; int old_min = min_font_size; min_font_size = 1; font->set_utf(is_utf); int white = mymakecol(255,255,255); // All the translations are taken from http://home.comcast.net/~plotor/command.html while (*s) { if (*s != '_' && *s != '^' && *s != '@') { s++; continue; } char pre = *s; if (s > old) { // Eventually display what's before *s = 0; int w,h; font->dimensions(old,&w,&h); font->surf_string(sf,x,y,old,fg,bg,w); x += w; *s = pre; } s++; font->dimensions("mp",&w,&h); int col = 0; char str[4]; TFont *f0 = NULL; str[0] = *s; str[1] = 0; TSketcher *d = new TSketcher(sf,x,y,w,h,10,9); if (pre == '_') { switch(*s) { case 'A': case 'a': case 'S': case '5': col = mymakecol(255,64,64); break; case 'B': case 'b': col = mymakecol(255,238,0); break; case 'C': case 'c': col = mymakecol(0,255,64); break; case 'D': case 'd': col = mymakecol(0,170,255); break; case 'P': case 'e': col = mymakecol(255,0,170); break; case 'K': case 'Z': case 'f': col = mymakecol(170,0,255); break; case 'g': col = mymakecol(0,255,204); break; case 'i': col = mymakecol(255,160,0); break; case 'G': col = mymakecol(0,170,255); break; case 'H': case 'h': col = mymakecol(255,0,255); break; case 'j': col = mymakecol(190,190,190); break; } if (*s >= 'a' && *s <= 'j') sprintf(str,"%d",*s-'a'+1); else if (*s == 'L') sprintf(str,">>"); // too many drawings !!! else if (*s == 'M') sprintf(str,"<<"); else if (*s == 'X') sprintf(str,"TAP"); else if (*s == '^') sprintf(str,"AIR"); else if (*s == '?') sprintf(str,"DIR"); else if (*s == 'S') sprintf(str,"St"); // tss... else if (*s == '.') sprintf(str,"..."); d->set_filled_poly(1); } else if (pre == '^') { d->set_filled_poly(0); switch (*s) { case 'S': case 'E': col = mymakecol(255,238,0); break; case 's': case 'F': col = mymakecol(255,160,0); break; case 'G': col = mymakecol(255,64,64); break; case 'H': col = mymakecol(190,190,190); break; case 'I': col = mymakecol(0,255,204); break; case 'J': col = mymakecol(0,170,255); break; case 'T': col = mymakecol(170,0,255); break; case 'W': case 'U': col = mymakecol(255,0,170); break; case 'V': col = mymakecol(170,0,255); break; } if (*s >= 'E' && *s <= 'J') { if (has_input(KB_DEF_P1_B6)) { // Street fighter games char *keys[] = { "lp","mp","sp","lk","mk","sk" }; sprintf(str,"%s",keys[*s-'E']); } else sprintf(str,"b%d",*s-'E'+1); // button n for other games } else if (*s == 'T') sprintf(str,"3K"); else if (*s == 'U') sprintf(str,"3P"); else if (*s == 'V') sprintf(str,"2K"); else if (*s == 'W') sprintf(str,"2P"); else if (*s == 'S') sprintf(str,"SE"); // ?! else if (*s == 'M') sprintf(str,"MAX"); } else if (pre == '@') { if (!strncmp(s,"W-button",8)) { sprintf(str,"W"); col = mymakecol(255,238,0); s += 7; } } // I finally keep a constant base width to have all the circles of the // same size... // font->dimensions(str,&w,&h); // w += 2; // some small margin if (col) filledEllipseColor(sf, x+w/2, y+h/2, w/2,h/2, col); if (strlen(str) > 2) { // Try to find a font size which fits in this space ! f0 = font; int h = f0->get_font_height()/2; do { font = new TFont_ttf(h,"VeraMono.ttf"); if (h <= 3) break; int w0,h0; font->dimensions(str,&w0,&h0); if (w0 > w) { h--; delete font; font = NULL; } } while (!font); } // The coordinates below are supposed to be on & 10x9 matrix, except // that the picture I am using has clearly been resized and so it's // only an approximation... // For the arrows they are rotated and mirrored, so I do the rotation/ // mirror instead of risking more errors with more coordinates... Sint16 kx[13] = {1,3,6,4,4,7,7,9,9,7,4,2,2}; Sint16 ky[13] = {3,1,3,3,5,5,3,3,5,7,7,5,3}; Sint16 mkx[13],mky[13]; mirror(13,kx,mkx); mirror(13,ky,mky); Sint16 ox[10] = {1,3,3,5,5,7,7,5,3,3}; Sint16 oy[10] = {6,4,5,5,1,1,5,7,7,8}; Sint16 mox[10],moy[10]; mirror(10,ox,mox); mirror(10,oy,moy); Sint16 wx[16] = {3,1,1,3,6,8,8,10,7,5,7,5,3,3,5,4}; Sint16 wy[16] = {8,6,3,1,1,3,5,5, 7,5,5,3,3,6,7,8},mwx[16],mwy[16]; mirror(16,wx,mwx); mirror(16,wy,mwy); if (pre == '@') { // Very special case, W Button, 1 letter. font->surf_string(sf,x+w/4,y,str,(col ? 0 : fg),bg,w); goto end_loop; } if (*s == '1') d->poly(white, 6,1, 2,6, 1,5, 1,8, 4,8, 3,7, 8,2, -1,-1); else if (*s == '2') d->poly(white, 2,1, 2,6, 1,6, 3,8, 5,6, 4,6, 4,1, -1,-1); else if (*s == '3') d->poly(white, 0,2, 5,8, 4,9, 8,9, 8,5, 7,6, 3,1, -1,-1); else if (*s == '4') d->poly(white, 3,2, 0,5, 3,7, 3,6, 9,6, 9,4, 3,4, -1,-1); else if (*s == '6') d->poly(white, 1,4, 6,4, 6,2, 9,5, 6,7, 6,6, 1,6, -1,-1); else if (*s == '7') d->poly(white, 1,1, 1,5, 2,4, 8,9, 9,7, 4,2, 5,1, -1,-1); else if (*s == '8') d->poly(white, 2,8, 2,3, 1,3, 3,1, 5,3, 4,3, 4,8, -1,-1); else if (*s == '9') d->poly(white, 8,1, 8,5, 7,4, 1,9, 0,7, 5,2, 4,1, -1,-1); else if (*s == 'k') d->polytab(13,kx,ky,white); else if (*s == 'm') // horizontal mirror of k (10-x) d->polytab(13,mkx,ky,white); else if (*s == 'l') // vertical mirror of m (8-y) d->polytab(13,mkx,mky,white); else if (*s == 'n') // horizontal mirror of l (10-x) d->polytab(13,kx,mky,white); else if (*s == 'o') d->polytab(10,ox,oy,white); else if (*s == 'p') d->polytab(10,moy,ox,white); else if (*s == 'q') d->polytab(10,mox,moy,white); else if (*s == 'r') d->polytab(10,oy,mox,white); else if (*s == 's' && pre == '_') d->polytab(10,mox,oy,white); else if (*s == 't') d->polytab(10,oy,ox,white); else if (*s == 'u') d->polytab(10,ox,moy,white); else if (*s == 'v') d->polytab(10,moy,mox,white); else if (*s == 'w') d->polytab(16,wx,wy,white); else if (*s == 'x') d->polytab(16,mwx,mwy,white); else if (*s == 'y') d->polytab(16,wx,mwy,white); else if (*s == 'z') d->polytab(16,mwx,wy,white); else if (*s == 'Q') d->poly(white, 1,1, 1,3, 3,3, 3,4, 1,6, 7,6, 7,7, 9,5, 7,3, 7,4, 4,4, 4,3, 6,1, -1,-1); else if (*s == 'R') // horiz mirror of Q (10-x) d->poly(white, 9,1, 9,3, 7,3, 7,4, 9,6, 3,6, 3,7, 1,5, 3,3, 3,4, 6,4, 6,3, 4,1, -1,-1); else if (*s == '-' && pre == '_') { // not used for any raine game afaik d->lineC(3,1,7,1,white); d->lineC(3,5,5,3,white); d->lineC(5,3,7,5,white); d->lineC(5,3,5,7,white); } else if (*s == '-' && pre == '^') { d->lineC(1,4,6,4,white); d->lineC(6,4,4,2,white); d->lineC(6,4,4,6,white); d->lineC(8,2,8,6,white); } else if (*s == '=' && pre == '^') { d->lineC(1,4,6,4,white); d->lineC(1,4,3,2,white); d->lineC(1,4,3,6,white); d->lineC(8,2,8,6,white); } else if (*s == '`' && pre == '_') { filledCircleColor(sf, x+w/2, y+h/2, w/10, white); } else if (str[1] == 0) { int ws,hs; font->dimensions(str,&ws,&hs); font->surf_string(sf,x+(w-ws)/2,y,str,(col ? 0 : fg),bg,w); } else { int ws,hs; font->dimensions(str,&ws,&hs); font->surf_string(sf,x+(w-ws)/2,y,str,(col ? 0 : fg),bg,w); } if (f0) { delete font; font = f0; } delete d; end_loop: s++; old = s; x += w; } if (*old) font->surf_string(sf,x,y,old,fg,bg,w); min_font_size = old_min; }