/**< Função Desenha um triangulo na Janela */ void Des_Triangulo( int desenha_triangulo, ALLEGRO_FONT *fonte, int x1, int y1, int x2, int y2, int x3, int y3) { if (desenha_triangulo == 1) { al_draw_text(fonte, al_map_rgb(255, 255, 255), 320, 70, ALLEGRO_ALIGN_CENTRE, "Precione em 3 pontos:"); al_draw_triangle( x1, y1, x2, y2, x3, y3, al_map_rgb(255, 255, 255), 2); } }
void Triangle::draw_in_another_target() { if(get_filled_status()) al_draw_filled_triangle(_V_pos_x1+_V_cam_pos_x,_V_pos_y1+_V_cam_pos_y, _V_pos_x2+_V_cam_pos_x,_V_pos_y2+_V_cam_pos_y, _V_pos_x3+_V_cam_pos_x,_V_pos_y3+_V_cam_pos_y,_V_color); al_draw_triangle(_V_pos_x1+_V_cam_pos_x,_V_pos_y1+_V_cam_pos_y,_V_pos_x2+_V_cam_pos_x, _V_pos_y2+_V_cam_pos_y,_V_pos_x3+_V_cam_pos_x,_V_pos_y3+_V_cam_pos_y, _V_color,_V_thickness); }
void RenderTarget::drawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, bool fill, const ALLEGRO_COLOR &color) { setAsCurrent(); convertCoords(x1, y1); convertCoords(x2, y2); convertCoords(x3, y3); if (fill) { al_draw_filled_triangle(x1, y1, x2, y2, x3, y3, color); } else { al_draw_triangle(x1, y1, x2, y2, x3, y3, color, CBEnchanted::instance()->gfxInterface->getLineWidth()); } }
void Triangle::draw() { if(get_filled_status()) al_draw_filled_triangle(_V_pos_x1*bitmap_scale_x+_V_cam_pos_x,_V_pos_y1*bitmap_scale_y+_V_cam_pos_y, _V_pos_x2*bitmap_scale_x+_V_cam_pos_x,_V_pos_y2*bitmap_scale_y+_V_cam_pos_y, _V_pos_x3*bitmap_scale_x+_V_cam_pos_x,_V_pos_y3*bitmap_scale_y+_V_cam_pos_y, _V_color); al_draw_triangle(_V_pos_x1*bitmap_scale_x+_V_cam_pos_x,_V_pos_y1*bitmap_scale_y+_V_cam_pos_y, _V_pos_x2*bitmap_scale_x+_V_cam_pos_x,_V_pos_y2*bitmap_scale_y+_V_cam_pos_y, _V_pos_x3*bitmap_scale_x+_V_cam_pos_x,_V_pos_y3*bitmap_scale_y+_V_cam_pos_y, _V_color,_V_thickness*primitives_scale); }
void Dropdown_menu_view::Render(const Widget& widget) const { const Dropdown_menu& dropdown_menu = dynamic_cast<const Dropdown_menu&>(widget); Vector2 p = widget.Get_position(); Vector2 s = widget.Get_size(); ALLEGRO_COLOR text_color = al_map_rgb_f(1, 1, 1); ALLEGRO_COLOR tri_color = al_map_rgb_f(1, 1, 1); ALLEGRO_COLOR edge_color = al_map_rgb_f(0.5, 0.5, 0.5); ALLEGRO_COLOR select_color = al_map_rgb_f(0.0, 0, 0.8); //const Ustring& text = dropdown_menu.Get_text(); float h = al_get_font_line_height(font->Afont()); Menu *child = dynamic_cast<Menu*>(dropdown_menu.Get_child()); if(child) { const Ustring& text = child->Get_option(child->Get_selected_option()); float text_width = font->Get_ustr_width(text.Astring()); al_draw_ustr(font->Afont(), text_color, p.x+6+h/2, p.y+3, 0, text.Astring()); } float top = h*0.25; float middle = h*0.5; float bottom = h*0.75; if(dropdown_menu.Is_open()) { al_draw_filled_triangle(p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, tri_color); al_draw_triangle (p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, edge_color, 0); } else { al_draw_filled_triangle(p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, tri_color); al_draw_triangle (p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, edge_color, 0); } }
void Mouse::Render() { ALLEGRO_COLOR mouseCol; if( mouseDownButton & 1 ) mouseCol = al_map_rgb( 255, 255, 0 ); else if( mouseDownButton & 2 ) mouseCol = al_map_rgb( 255, 128, 0 ); else mouseCol = al_map_rgb( 255, 255, 255 ); if( isBoxing ) { al_draw_rectangle( min(mouseDownAt.X, Position.X), min(mouseDownAt.Y, Position.Y), max(mouseDownAt.X, Position.X), max(mouseDownAt.Y, Position.Y), mouseCol, 1 ); } al_draw_filled_triangle( Position.X, Position.Y, Position.X + 16, Position.Y + 16, Position.X, Position.Y + 25, mouseCol ); al_draw_triangle( Position.X, Position.Y, Position.X + 16, Position.Y + 16, Position.X, Position.Y + 25, al_map_rgb( 0, 0, 0 ), 1 ); }
void shal_draw_triangle(float x1, float y1, float x2, float y2, float x3, float y3, float color_r, float color_g, float color_b, float color_a, float thickness) { ALLEGRO_COLOR color; color.r = color_r; color.g = color_g; color.b = color_b; color.a = color_a; return al_draw_triangle(x1, y1, x2, y2, x3, y3, color, thickness); }
static void TransformationsPrimitives(int mode) { float t = al_get_time(); if (mode == INIT) { } else if (mode == LOGIC) { Theta += Speed; al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, sinf(t / 5), cosf(t / 5), Theta); } else if (mode == DRAW) { float points[8] = { -300, -200, 700, 200, -700, 200, 300, -200 }; if (Blend) al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); else al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_use_transform(&MainTrans); al_draw_line(-300, -200, 300, 200, al_map_rgba_f(0, 0.5, 0.5, 1), Thickness); al_draw_triangle(-150, -250, 0, 250, 150, -250, al_map_rgba_f(0.5, 0, 0.5, 1), Thickness); al_draw_rectangle(-300, -200, 300, 200, al_map_rgba_f(0.5, 0, 0, 1), Thickness); al_draw_rounded_rectangle(-200, -125, 200, 125, 50, 100, al_map_rgba_f(0.2, 0.2, 0, 1), Thickness); al_draw_ellipse(0, 0, 300, 150, al_map_rgba_f(0, 0.5, 0.5, 1), Thickness); al_draw_elliptical_arc(-20, 0, 300, 200, -ALLEGRO_PI / 2, -ALLEGRO_PI, al_map_rgba_f(0.25, 0.25, 0.5, 1), Thickness); al_draw_arc(0, 0, 200, -ALLEGRO_PI / 2, ALLEGRO_PI, al_map_rgba_f(0.5, 0.25, 0, 1), Thickness); al_draw_spline(points, al_map_rgba_f(0.1, 0.2, 0.5, 1), Thickness); al_draw_pieslice(0, 25, 150, ALLEGRO_PI * 3 / 4, -ALLEGRO_PI / 2, al_map_rgba_f(0.4, 0.3, 0.1, 1), Thickness); al_use_transform(&Identity); } }
void gfx_render(int step) { static int last[2] = {0.0, 0.0}; int i, j, scale = MIN(G.w / G.gi.map_size[0], G.h / G.gi.map_size[1]); float cur[2]; ALLEGRO_COLOR colors[] = { al_map_rgb( 0, 0, 0), /* x */ al_map_rgb( 0,200, 0), /* p */ al_map_rgb( 0,150, 0), /* r */ al_map_rgb( 0,100, 0), /* a */ al_map_rgb( 0, 50, 0), /* s */ }; al_clear_to_color(al_map_rgb(0,0,0)); /* tiles */ for (i=0; i<G.gi.map_size[0]; i++) { for (j=0; j<G.gi.map_size[1]; j++) { int map_index = i + j * G.gi.map_size[1]; al_draw_filled_rectangle(scale*i, scale*j, scale*(i + 1), scale*(j + 1), colors[G.gi.mapv[map_index]]); } } /* prizes */ for (i=0; i<G.gi.num_prizes_orig; i++) { float x = G.gi.prizes[i][0] + 0.5; float y = G.gi.prizes[i][1] + 0.5; char buff[255]; if (!G.gi.prizes_visited[i]) al_draw_filled_triangle(scale*(x), scale*(y-0.3), scale*(x+0.3), scale*(y+0.3), scale*(x-0.3), scale*(y+0.3), al_map_rgb(255, 255, 0)); else al_draw_triangle(scale*(x), scale*(y-0.3), scale*(x+0.3), scale*(y+0.3), scale*(x-0.3), scale*(y+0.3), al_map_rgb(255, 255, 0), 1.0); sprintf(buff, "%d", i+1); al_draw_text(G.font, al_map_rgb(0,0,0), scale*x, scale*(y-0.1), ALLEGRO_ALIGN_CENTRE, buff); } /* start */ al_draw_filled_circle((float)scale * (G.gi.start[0]+0.5), (float)scale * (G.gi.start[1]+0.5), scale/3, al_map_rgb(0, 255, 0)); /* end */ al_draw_filled_circle((float)scale * (G.gi.end[0]+0.5), (float)scale * (G.gi.end[1]+0.5), scale/3, al_map_rgb(255, 0, 0)); if (step == MOVE_FRAMES-1) { last[0] = G.gi.cur[0]; last[1] = G.gi.cur[1]; } cur[0] = last[0] + (step * ((float)G.gi.cur[0]-last[0]))/MOVE_FRAMES; cur[1] = last[1] + (step * ((float)G.gi.cur[1]-last[1]))/MOVE_FRAMES; /* player */ al_draw_filled_circle((float)scale * (cur[0]+0.5), (float)scale * (cur[1]+0.5), scale/3, al_map_rgb(0, 0, 255)); al_flip_display(); }
USHORT ssfDrawChar( AL_BITMAP * dst, ssfFont * sfont, char c, int x, int y, int color ) { BYTE p; int i, j, thick; ssfGlyph charGlyph; ssfFrame charFrame; int points[ 8 ]; float fScale; p = ( BYTE ) c; charGlyph = *sfont->chars[ p ]; fScale = ( float ) ( ( float ) sfont->fsize / ( float ) 65535 ); for( i = 0; i < charGlyph.num; i++ ) { charFrame = charGlyph.frames[ i ]; if( charFrame.ftype == SSF_SPLINE2 ) { fLeft2 = x + ( int ) ( fScale * charFrame.left ); fTop2 = y + ( int ) ( fScale * charFrame.top ); fRight2 = x + ( int ) ( fScale * charFrame.right ); fBottom2 = y + ( int ) ( fScale * charFrame.bottom ); } else { fLeft = x + ( int ) ( fScale * charFrame.left ); fTop = y + ( int ) ( fScale * charFrame.top ); fRight = x + ( int ) ( fScale * charFrame.right ); fBottom = y + ( int ) ( fScale * charFrame.bottom ); } switch( charFrame.ftype ) { case SSF_SPLINE2: thick = ( int ) ( fScale * charFrame.thick ); if( thick == 0 ) thick++; for( j = 0; j < thick; j++ ) { al_draw_spline( dst, points, color ); switch( charFrame.thickdir ) { case THICK_LEFT: fLeft--; fRight--; fLeft2--; fRight2--; break; case THICK_UP: fTop--; fBottom--; fTop2--; fBottom2--; break; case THICK_RIGHT: fLeft++; fRight++; fLeft2++; fRight2++; break; case THICK_DOWN: fTop++; fBottom++; fTop2++; fBottom2++; break; } } break; case SSF_LINE: thick = ( int ) ( fScale * charFrame.thick ); if( thick == 0 ) thick++; for( j = 0; j < thick; j++ ) { al_draw_line( dst, fLeft, fTop, fRight, fBottom, color ); switch( charFrame.thickdir ) { case THICK_LEFT: fLeft--; fRight--; break; case THICK_UP: fTop--; fBottom--; break; case THICK_RIGHT: fLeft++; fRight++; break; case THICK_DOWN: fTop++; fBottom++; break; } } break; case SSF_BOX: al_draw_rect_fill( dst, fLeft, fTop, fRight, fBottom, color ); break; case SSF_TRIANGLE: thick = x + ( int ) ( fScale * charFrame.thick ); al_draw_triangle( dst, fLeft, fTop, fRight, fBottom, thick, y + ( int ) ( fScale * charFrame.thickdir ), color ); break; } } return sfont->fsize / 2; }
unsigned short ssfDrawChar( AL_BITMAP * dst, ssfFont * sfont, char c, int x, int y, int color ) { HB_BYTE p; int i, j, thick; ssfGlyph charGlyph; ssfFrame charFrame; int points[ 8 ]; float fScale; p = ( HB_BYTE ) c; charGlyph = *sfont->chars[ p ]; fScale = ( float ) ( ( float ) sfont->fsize / ( float ) 65535 ); for( i = 0; i < charGlyph.num; i++ ) { charFrame = charGlyph.frames[ i ]; if( charFrame.ftype == SSF_SPLINE2 ) { points[ _F_LEFT2 ] = x + ( int ) ( fScale * charFrame.left ); points[ _F_TOP2 ] = y + ( int ) ( fScale * charFrame.top ); points[ _F_RIGHT2 ] = x + ( int ) ( fScale * charFrame.right ); points[ _F_BOTTOM2 ] = y + ( int ) ( fScale * charFrame.bottom ); } else { points[ _F_LEFT ] = x + ( int ) ( fScale * charFrame.left ); points[ _F_TOP ] = y + ( int ) ( fScale * charFrame.top ); points[ _F_RIGHT ] = x + ( int ) ( fScale * charFrame.right ); points[ _F_BOTTOM ] = y + ( int ) ( fScale * charFrame.bottom ); } switch( charFrame.ftype ) { case SSF_SPLINE2: thick = ( int ) ( fScale * charFrame.thick ); if( thick == 0 ) thick++; for( j = 0; j < thick; j++ ) { al_draw_spline( dst, points, color ); switch( charFrame.thickdir ) { case THICK_LEFT: points[ _F_LEFT ]--; points[ _F_RIGHT ]--; points[ _F_LEFT2 ]--; points[ _F_RIGHT2 ]--; break; case THICK_UP: points[ _F_TOP ]--; points[ _F_BOTTOM ]--; points[ _F_TOP2 ]--; points[ _F_BOTTOM2 ]--; break; case THICK_RIGHT: points[ _F_LEFT ]++; points[ _F_RIGHT ]++; points[ _F_LEFT2 ]++; points[ _F_RIGHT2 ]++; break; case THICK_DOWN: points[ _F_TOP ]++; points[ _F_BOTTOM ]++; points[ _F_TOP2 ]++; points[ _F_BOTTOM2 ]++; break; } } break; case SSF_LINE: thick = ( int ) ( fScale * charFrame.thick ); if( thick == 0 ) thick++; for( j = 0; j < thick; j++ ) { al_draw_line( dst, points[ _F_LEFT ], points[ _F_TOP ], points[ _F_RIGHT ], points[ _F_BOTTOM ], color ); switch( charFrame.thickdir ) { case THICK_LEFT: points[ _F_LEFT ]--; points[ _F_RIGHT ]--; break; case THICK_UP: points[ _F_TOP ]--; points[ _F_BOTTOM ]--; break; case THICK_RIGHT: points[ _F_LEFT ]++; points[ _F_RIGHT ]++; break; case THICK_DOWN: points[ _F_TOP ]++; points[ _F_BOTTOM ]++; break; } } break; case SSF_BOX: al_draw_rect_fill( dst, points[ _F_LEFT ], points[ _F_TOP ], points[ _F_RIGHT ], points[ _F_BOTTOM ], color ); break; case SSF_TRIANGLE: thick = x + ( int ) ( fScale * charFrame.thick ); al_draw_triangle( dst, points[ _F_LEFT ], points[ _F_TOP ], points[ _F_RIGHT ], points[ _F_BOTTOM ], thick, y + ( int ) ( fScale * charFrame.thickdir ), color ); break; } } return sfont->fsize / 2; }
void DrawingClass::DrawTriangle (float x0, float y0, float x1, float y1, float x2, float y2, int r, int g, int b, float thick) { ALLEGRO_COLOR color = al_map_rgb(r, g, b); al_draw_triangle(x0, y0, x1, y1, x2, y2, color, thick); }
static void draw_the_controls(bool draw_controls, ALLEGRO_COLOR tint) { #if defined ALLEGRO_IPHONE || defined ALLEGRO_ANDROID if (use_dpad && dpad_buttons && draw_controls && global_draw_controls) { if ((dpad_type == DPAD_TOTAL_2 || dpad_type == DPAD_HYBRID_2)) { ALLEGRO_COLOR light = al_map_rgba(100*tint.r, 200*tint.g, 100*tint.b, 255*tint.a); ALLEGRO_COLOR dark = al_map_rgba(150*tint.r, 250*tint.g, 150*tint.b, 255*tint.a); int x = BUTTON_SIZE+10; int y = dpad_at_top ? 5 : BH-5-BUTTON_SIZE; if (!config.getSwapButtons()) { al_draw_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, BUTTON_SIZE/2, light, 2); al_draw_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, BUTTON_SIZE/2+1, dark, 1); al_draw_filled_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, BUTTON_SIZE/2, light); al_draw_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, BUTTON_SIZE/2, dark, 1); } else { al_draw_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, BUTTON_SIZE/2, light, 2); al_draw_circle(BW-25-BUTTON_SIZE*1.5, y+BUTTON_SIZE/2, BUTTON_SIZE/2+1, dark, 1); al_draw_filled_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, BUTTON_SIZE/2, light); al_draw_circle(BW-20-BUTTON_SIZE/2, y+BUTTON_SIZE/2, BUTTON_SIZE/2, dark, 1); } y = dpad_at_top ? 5 : BH-BUTTON_SIZE*3-5; int l = BUTTON_SIZE*1.5-10; al_draw_rounded_rectangle(10, y, 10+BUTTON_SIZE*3, y+BUTTON_SIZE*3, 5, 5, light, 2); al_draw_rounded_rectangle(9, y-1, 10+BUTTON_SIZE*3+1, y+BUTTON_SIZE*3+1, 5, 5, dark, 1); m_draw_line(17, y+7, 17+l, y+7+l, dark); m_draw_line(10+BUTTON_SIZE*3-8, y+7, 10+BUTTON_SIZE*3-8-l, y+7+l, dark); m_draw_line(17, y+BUTTON_SIZE*3-7, 17+l, y+BUTTON_SIZE*3-7-l, dark); m_draw_line(10+BUTTON_SIZE*3-7, y+BUTTON_SIZE*3-7, 10+BUTTON_SIZE*3-7-l, y+BUTTON_SIZE*3-7-l, dark); al_draw_filled_triangle(x+4, y+BUTTON_SIZE-4, x+BUTTON_SIZE/2, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, light/*, 1*/); al_draw_triangle(x+4, y+BUTTON_SIZE-4, x+BUTTON_SIZE/2, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, dark, 1); x = 10; y += BUTTON_SIZE; al_draw_filled_triangle(x+4, y+BUTTON_SIZE/2, x+BUTTON_SIZE-4, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, light/*, 1*/); al_draw_triangle(x+4, y+BUTTON_SIZE/2, x+BUTTON_SIZE-4, y+4, x+BUTTON_SIZE-4, y+BUTTON_SIZE-4, dark, 1); x = 10+BUTTON_SIZE*2; al_draw_filled_triangle(x+BUTTON_SIZE-4, y+BUTTON_SIZE/2, x+4, y+BUTTON_SIZE-4, x+4, y+4, light/*, 1*/); al_draw_triangle(x+BUTTON_SIZE-4, y+BUTTON_SIZE/2, x+4, y+BUTTON_SIZE-4, x+4, y+4, dark, 1); x = 10+BUTTON_SIZE; y += BUTTON_SIZE; al_draw_filled_triangle(x+4, y+4, x+BUTTON_SIZE/2, y+BUTTON_SIZE-4, x+BUTTON_SIZE-4, y+4, light/*, 1*/); al_draw_triangle(x+4, y+4, x+BUTTON_SIZE/2, y+BUTTON_SIZE-4, x+BUTTON_SIZE-4, y+4, dark, 1); } else { ALLEGRO_VERTEX verts[36]; InputDescriptor ie = getInput()->getDescriptor(); int x = BUTTON_SIZE+10; int y = dpad_at_top ? 5 : BH-5-BUTTON_SIZE; const int s = 20; // bitmap size const int o = (BUTTON_SIZE-s)/2; // offset to draw int nv = 0; int vx, vy; int vu, vv; #define SETXY \ verts[nv].x = vx; \ verts[nv].y = vy; \ verts[nv].z = 0; \ verts[nv+1].x = vx+20; \ verts[nv+1].y = vy; \ verts[nv+1].z = 0; \ verts[nv+2].x = vx; \ verts[nv+2].y = vy+20; \ verts[nv+2].z = 0; \ verts[nv+3].x = vx+20; \ verts[nv+3].y = vy; \ verts[nv+3].z = 0; \ verts[nv+4].x = vx+20; \ verts[nv+4].y = vy+20; \ verts[nv+4].z = 0; \ verts[nv+5].x = vx; \ verts[nv+5].y = vy+20; \ verts[nv+5].z = 0; #define SETUV \ verts[nv].u = vu; \ verts[nv].v = vv; \ verts[nv+1].u = vu+20; \ verts[nv+1].v = vv; \ verts[nv+2].u = vu; \ verts[nv+2].v = vv+20; \ verts[nv+3].u = vu+20; \ verts[nv+3].v = vv; \ verts[nv+4].u = vu+20; \ verts[nv+4].v = vv+20; \ verts[nv+5].u = vu; \ verts[nv+5].v = vv+20; \ nv += 6; if (config.getSwapButtons()) { vx = BW-20-BUTTON_SIZE+o; vy = y+o; } else { vx = BW-25-BUTTON_SIZE*2; vy = y+o; } SETXY if (ie.button1) { vu = 20; vv = 40; SETUV } else { vu = 0; vv = 40; SETUV } if (config.getSwapButtons()) { vx = BW-25-BUTTON_SIZE*2; vy = y+o; } else { vx = BW-20-BUTTON_SIZE+o; vy = y+o; } SETXY if (ie.button2) { vu = 60; vv = 40; SETUV }
void al_draw_triangle_w(float x1, float y1, float x2, float y2, float x3, float y3, ALLEGRO_COLOR *color, float thickness) { al_draw_triangle(x1, y1, x2, y2, x3, y3, *color, thickness); }