void MenuView::Draw() { model().interface().screen().draw(); model().interface().screen().getGraphics()->pushClipArea( top->getClipRectangle() ); model().interface().screen().getGraphics()->setColor( gcn::Color( 0xffffff ) ); // The colour to be used when drawing. From here on, white will be used. model().interface().screen().getGraphics()->drawLine( 10, 10, 100, 100 ); model().interface().screen().getGraphics()->drawRectangle( gcn::Rectangle( 0, 0, 250, 250 ) ); model().interface().screen().getGraphics()->drawText( "Texto de prueba", 10, 10 ); gcn::SDLGraphics * gr = static_cast < gcn::SDLGraphics* >( model().interface().screen().getGraphics() ); ellipseRGBA( gr->getTarget(), 100, 100, 20, 10, 0xFF, 0x00, 0x00, 0xFF ); model().interface().screen().getGraphics()->popClipArea(); }
/*! * @breif Draw ellipse * drawEllipse({x, y, width, height}, color) * drawEllipse(x, y, width, height, color) */ static int32_t luaSDL_drawEllipse( lua_State *L ) { SDL_Surface *surface; gp_rect_t rect; gp_color_t color; surface = (SDL_Surface *) lua_touserdata(L, 1); if (!lua_istable(L, 2)) { /* number mode */ rect.x = (int16_t)lua_tointeger(L, 2); rect.y = (int16_t)lua_tointeger(L, 3); rect.width = (int16_t)lua_tointeger(L, 4); rect.height = (int16_t)lua_tointeger(L, 5); color = luaSdl_toColor(L, 6); } else { rect = luaSdl_toRect(L, 2); color = luaSdl_toColor(L, 3); } ellipseRGBA(surface, rect.x + rect.width/2, rect.y + rect.height/2, rect.width/2, rect.height/2, color.red, color.green, color.blue, color.alpha); return 0; }
void Elipse(int x, int y, int radx, int rady, unsigned char r, unsigned char g, unsigned char b, GRF_Imagen img) { GRF_Imagen ptr = ((img==0) ? ventana : img); ellipseRGBA(ptr, x, y, radx, rady, r, g, b,255); if (img==0 && dibujo_activo) SDL_UpdateRect(ptr, x-radx, y-rady, radx*2+1, rady*2+1); }
void inicio(){ if (SDL_Init(SDL_INIT_EVERYTHING) || TTF_Init()) exit(1); wnd = SDL_CreateWindow("SHOL GUI", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800,800, SDL_WINDOW_SHOWN); renderer = SDL_CreateRenderer(wnd,-1,SDL_RENDERER_SOFTWARE); fnt_pt = TTF_OpenFont("font.ttf", 12); if (fnt_pt == NULL){ printf("Font (font.ttf) not found! Exiting...\n"); exit(1); } SDL_SetRenderDrawColor(renderer, 0,0,0,255); SDL_RenderClear(renderer); int fila,columna; fila = 60; columna = 560; renderString("Smart Home", columna, fila, 0xFF,0xFF,0xFF); fila = 80; renderString("Proyecto TL", columna, fila, 0xFF,0xFF,0xFF); fila = 100; renderString("Curso 2015/2016", columna, fila, 0xFF,0xFF,0xFF); renderString("Simulador de Smart Home - Plano de la casa", 50, 10, 0xFF,0xFF,0xFF); SDL_Rect *rect = new SDL_Rect(); rect->x = ORIGEN_X-5; rect->y = ORIGEN_Y-5; rect->w = 455; rect->h = 555; SDL_SetRenderDrawColor(renderer, 255,255,255,255); SDL_RenderFillRect(renderer, rect); fila = 180; columna = 560; renderString("Sensor de temperatura", columna+20,fila , 0,0xFF,0); ellipseRGBA(renderer, columna, fila, 6,6,0,0xFF,0,0xFF); fila = 200; columna = 560; renderString("Sensor de luminosidad",columna+20,fila,0xFF,0xFF,0xFF); ellipseColor(renderer, columna, fila, 6,6, 0xFFFFFFFF); fila = 220; columna = 560; renderString("Sensor de humo",columna+20,fila,0x00,0x00,0xFF); ellipseRGBA(renderer, columna, fila, 6,6, 0x00,0x00,0xFF,0xFF); fila = 250; columna = 560; renderString("Alarma",columna+20,fila,0xFF,0x00,0x00); ellipseColor(renderer, columna, fila, 6,6, 0xFF0000FF); fila = 270; columna = 560; renderString("Luz",columna+20,fila,0xFF,0xB4,0x00); ellipseRGBA(renderer, columna, fila, 6,6, 0xFF,0xB4,0x00,0xFF); SDL_RenderPresent(renderer); }
/* Interface to SDL_gfx version for drawing circles */ int Surface::DrawCircle(int x0, int y0, int r, int color, int fill) { int red = (color >> 16) & 0xff; int green = (color >> 4) & 0xff; int blue = color & 0xff; if (fill) filledEllipseRGBA(surf, x0, y0, r, r, red, green, blue, 255); else ellipseRGBA(surf, x0, y0, r, r, red, green, blue, 255); return 0; }
void SDLDebugDraw::DrawCircle(const b2Vec2 ¢er, float32 radius, const b2Color &color) { Sint16 x; Sint16 y; b2Vec2 v = center; //((vertices[i] + camera.wpos)*camera.getScale()) ; v*= camera; x = (Sint16) v.x; y = (Sint16) v.y; ellipseRGBA(App::get()->ren->renderer,x, y, radius*30, radius*30, color.r, color.g, color.b, color.a); }
CAMLprim value ml_ellipseRGBA(value dst,value p,value rp, value col,value alpha) { SDL_Surface *sur= SDL_SURFACE(dst); SDL_Rect prect,rprect; SDL_Color c; int r; SDLRect_of_value(&prect,p); SDLRect_of_value(&rprect,rp); SDLColor_of_value(&c,col); r=ellipseRGBA(sur,prect.x,prect.y,rprect.x,rprect.y,c.r,c.g,c.b, Int_val(alpha)); return Val_bool(r); }
void Ellipse::draw() { ellipseRGBA(surface, center.x, center.y, rx, ry, 0, 0, 0, 255); }
extern void game_draw_ellipse(Game *game, int x, int y, int rx, int ry, int r, int g, int b, int a) { ellipseRGBA(game->screen, x, y, rx, ry, r, g, b, a); }
void gfx_ellipse(int x, int y, int rx, int ry) { ellipseRGBA(g_gfx_screen, x, y, rx, ry, g_gfx_color.r, g_gfx_color.g, g_gfx_color.b, 255); }
void Main_controller::main_loop() { bool quit = false; Point down = Point(0, 0); vector<Point>* points_list = new vector<Point>; bool in_drawing = false; while ( !quit ) { SDL_Event event = sdl_controller->get_event(); sdl_controller->clear(); switch ( event.type ) { case SDL_KEYDOWN: switch ( event.key.keysym.sym ) { case SDLK_q: draw_mode = MO_LINE; break; case SDLK_w: draw_mode = MO_RECTANGLE; break; case SDLK_e: draw_mode = MO_ELLIPSE; break; case SDLK_g: scene->clear(); gm->build_match_scene(scene); scene->set_working_surface( sdl_controller->get_surface() ); break; case SDLK_a: { bool res = gm->match_grammar(scene); fprintf(stderr, "res=%d\n", res); // not a good idea, but using kdialog to display information here if ( res ) system("kdialog --msgbox \"It's a valid house\""); else system("kdialog --msgbox \"It's not a valid house\""); } break; case SDLK_c: scene->clear(); break; } break; case SDL_MOUSEBUTTONDOWN: if ( event.button.button == SDL_BUTTON_LEFT ) { switch ( draw_mode ) { case MO_LINE: case MO_RECTANGLE: case MO_ELLIPSE: down.x = event.button.x; down.y = event.button.y; in_drawing = true; break; } } break; case SDL_MOUSEBUTTONUP: if ( event.button.button == SDL_BUTTON_LEFT ) { Point up; up.x = event.button.x; up.y = event.button.y; switch ( draw_mode ) { case MO_LINE: { Line* line = new Line(down.x, down.y, up.x, up.y); line->set_surface( sdl_controller->get_surface() ); scene->add_figure(line); in_drawing = false; break; } case MO_RECTANGLE: { Rectangle* rectangle = new Rectangle(down.x, down.y, up.x, up.y); rectangle->set_surface( sdl_controller->get_surface() ); scene->add_figure(rectangle); in_drawing = false; break; } case MO_ELLIPSE: { int rx = abs(up.x - down.x); int ry = abs(up.y - down.y); Ellipse* ellipse = new Ellipse( down.x, down.y, rx, ry); ellipse->set_surface( sdl_controller->get_surface() ); scene->add_figure(ellipse); in_drawing = false; break; } } } break; case SDL_MOUSEMOTION: if ( in_drawing ) { Point up; up.x = event.motion.x; up.y = event.motion.y; switch ( draw_mode ) { case MO_LINE: lineRGBA(sdl_controller->get_surface(), down.x, down.y, up.x, up.y, 0, 0, 0, 255); break; case MO_RECTANGLE: rectangleRGBA(sdl_controller->get_surface(), down.x, down.y, up.x, up.y, 0, 0, 0, 255); break; case MO_ELLIPSE: int rx = abs(up.x - down.x); int ry = abs(up.y - down.y); ellipseRGBA(sdl_controller->get_surface(), down.x, down.y, rx, ry, 0, 0, 0, 255); break; } } break; case SDL_QUIT: quit = true; break; } scene->draw_all(); sdl_controller->redraw(); } }
void DrawingArea::DrawEllipse(const int x, const int y, const int rx, const int ry, const SSDL::Color Color) { ellipseRGBA(this->surface, x, y, rx, ry, Color.GetRed(), Color.GetGreen(), Color.GetBlue(), Color.GetAlpha()); }