void Draw_Geometry() { int flag = 1; SDL_FillRect(WINDOW, NULL, 0xffffffff); while( flag ){ switch( rand() % 7 ){ case 0: hlineColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break; case 1: vlineColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break; case 2: rectangleColor(WINDOW, AXIS, AXIS, AXIS, AXIS, COLOR); break; case 3: lineColor(WINDOW, AXIS, AXIS, AXIS, AXIS, COLOR); break; case 4: circleColor(WINDOW, AXIS, AXIS, AXIS, COLOR); break; case 5: pieColor(WINDOW, AXIS, AXIS, AXIS, THETA, THETA, COLOR); break; case 6: trigonColor(WINDOW, AXIS, AXIS, AXIS, AXIS, AXIS, AXIS, COLOR); break; default: break; } SDL_UpdateRect(WINDOW, 0, 0, 0, 0); printf("again->'a' reset->'r' exit->'e'\n"); char ch = getchar(), c = getchar(); switch( ch ){ case 'a': flag = 1; break; case 'r': SDL_FillRect(WINDOW, NULL, 0xffffffff); break; case 'e': flag = 0; break; default : flag = 1; break; } } }
int GeoLayer::trigon(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint32_t col) { if(!surf) { error("%s can't run: layer not initialized", __PRETTY_FUNCTION__); return -1; } res = trigonColor(surf, x1, y1, x2, y2, x3, y3, col); if(res < 0) error("error in %s", __PRETTY_FUNCTION__); return(res); }
static PyObject* _gfx_trigoncolor (PyObject *self, PyObject* args) { PyObject *surface, *color, *p1, *p2, *p3; int x1, x2, x3, _y1, y2, y3; pguint32 c; ASSERT_VIDEO_INIT (NULL); if (!PyArg_ParseTuple (args, "OOOOO:trigon", &surface, &p1, &p2, &p3, &color)) { PyErr_Clear (); if (!PyArg_ParseTuple (args, "OiiiiiiO:trigon", &surface, &x1, &_y1, &x2, &y2, &x3, &y3, &color)) return NULL; } else { if (!PointFromObj (p1, &x1, &_y1) || !PointFromObj (p2, &x2, &y2) || !PointFromObj (p3, &x3, &y3)) return NULL; } if (!PySDLSurface_Check (surface)) { PyErr_SetString (PyExc_TypeError, "surface must be a Surface"); return NULL; } if (!ColorFromObj (color, &c)) return NULL; if (trigonColor (((PySDLSurface*)surface)->surface, (Sint16)x1, (Sint16)_y1, (Sint16)x2, (Sint16)y2, (Sint16)x3, (Sint16)y3, (Uint32)c) == -1) { PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return NULL; } Py_RETURN_NONE; }
/*************** 敵集団をプロット ***************/ void Opponent_Prot(SDL_Surface *window) { int i; char tmp_n[5]; /*個体を描画*/ for(i=0;i<No;i++){ /* sprintf(tmp_n,"%d",Opponent[i].nitch); stringColor(window, (Opponent[i].n[0]*2)+center[0]-2, (Opponent[i].n[1]*2)+center[1]-2, tmp_n, 0x000000ff); */ trigonColor(window, (Opponent[i].n[0]*2)+center[0], (Opponent[i].n[1]*2)+center[1]-5, (Opponent[i].n[0]*2)+center[0]+6, (Opponent[i].n[1]*2)+center[1]+6, (Opponent[i].n[0]*2)+center[0]-5, (Opponent[i].n[1]*2)+center[1]+6, 0x0000ffff); // 三角形を描画 } }
void pointer(int x, int y) { int dx, dy, dlen, ex, ey, incx = 0, incy = 0, x1, y1, x2, y2; const int shaft_width = 10; const int arrow_head = 50; double aspect, angle; Uint32 pen = colour->yellow_pen; dx = x - SCREEN_WIDTH / 2; dy = y - SCREEN_HEIGHT / 2; if(dx == 0) dx = 1; if(dy == 0) dy = 1; angle = (double)abs(dx) / (double)abs(dy); aspect = (double)SCREEN_WIDTH / (double)SCREEN_HEIGHT; if(angle < aspect) { if(dy < 0) { // Top edge: ex = SCREEN_WIDTH / 2 + (dx * SCREEN_HEIGHT) / 2 / (-dy); ey = 0; } else { // Bottom edge: ex = SCREEN_WIDTH / 2 + (dx * SCREEN_HEIGHT) / 2 / dy; ey = SCREEN_HEIGHT - 1; } incx = 1; } else { if(dx > 0) { // Right edge: ex = SCREEN_WIDTH - 1; ey = SCREEN_HEIGHT / 2 + (dy * SCREEN_WIDTH) / 2 / dx; } else { // Left edge: ex = 0; ey = SCREEN_HEIGHT / 2 + (dy * SCREEN_WIDTH) / 2 / (-dx); } incy = 1; } lineColor(screen, ex, ey, x, y, pen); for(int i = 1; i < shaft_width; i++) { lineColor(screen, ex + i * incx, ey + i * incy, x, y, pen); lineColor(screen, ex - i * incx, ey - i * incy, x, y, pen); } lineColor(screen, ex + shaft_width * incx, ey + shaft_width * incy, x, y, colour->black_pen); lineColor(screen, ex - shaft_width * incx, ey - shaft_width * incy, x, y, colour->black_pen); // Arrow head: dlen = dx * dx + dy * dy; dlen = (int)ceil(sqrt(dlen)); dx *= arrow_head; dy *= arrow_head; dx /= dlen; dy /= dlen; x1 = x + dx + dy / 2; y1 = y + dy - dx / 2; x2 = x + dx - dy / 2; y2 = y + dy + dx / 2; filledTrigonColor(screen, x, y, x1, y1, x2, y2, pen); trigonColor(screen, x, y, x1, y1, x2, y2, colour->black_pen); // SDL_Flip(screen); }
void PlayerVehicle::render(SDL_Renderer* renderer) { trigonColor(renderer, vertices[0].x, vertices[0].y, vertices[1].x ,vertices[1].y, vertices[2].x, vertices[2].y, m_iColor); }
void sfml_drawsurface::trigonColor(Point& a, unsigned int size, int t_color) { My_Color color(t_color); trigonColor(a, size, color.red, color.green, color.blue); }