void Rectangle(PixelScalar left, PixelScalar top, PixelScalar right, PixelScalar bottom) { DrawFilledRectangle(left, top, right, bottom, brush); if (pen_over_brush()) DrawOutlineRectangle(left, top, right, bottom, pen.GetColor()); }
void Canvas::DrawTriangleFan(const RasterPoint *points, unsigned num_points) { if (brush.IsHollow() && !pen.IsDefined()) return; glVertexPointer(2, GL_VALUE, 0, points); if (!brush.IsHollow() && num_points >= 3) { brush.Set(); glDrawArrays(GL_TRIANGLE_FAN, 0, num_points); } if (pen_over_brush()) { pen.Bind(); if (pen.GetWidth() <= 2) { glDrawArrays(GL_LINE_LOOP, 0, num_points); } else { unsigned vertices = LineToTriangles(points, num_points, vertex_buffer, pen.GetWidth(), true); if (vertices > 0) { glVertexPointer(2, GL_VALUE, 0, vertex_buffer.begin()); glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices); } } pen.Unbind(); } }
void Canvas::TriangleFan(const RasterPoint *points, unsigned num_points) { if (brush.is_hollow() && !pen.defined()) return; glVertexPointer(2, GL_VALUE, 0, points); if (!brush.is_hollow() && num_points >= 3) { brush.set(); glDrawArrays(GL_TRIANGLE_FAN, 0, num_points); } if (pen_over_brush()) { pen.set(); if (pen.get_width() <= 2) { glDrawArrays(GL_LINE_LOOP, 0, num_points); } else { vertex_buffer.grow_discard(2 * (num_points + 1)); unsigned vertices = line_to_triangle(points, num_points, vertex_buffer.begin(), pen.get_width(), true); if (vertices > 0) { glVertexPointer(2, GL_VALUE, 0, vertex_buffer.begin()); glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices); } } } }
void Canvas::DrawAnnulus(PixelScalar x, PixelScalar y, UPixelScalar small_radius, UPixelScalar big_radius, Angle start, Angle end) { GLDonutVertices vertices(x, y, small_radius, big_radius); const std::pair<unsigned,unsigned> i = AngleToDonutVertices(start, end); const unsigned istart = i.first; const unsigned iend = i.second; if (!brush.IsHollow()) { brush.Set(); vertices.bind(); if (istart > iend) { glDrawArrays(GL_TRIANGLE_STRIP, istart, 64 - istart + 2); glDrawArrays(GL_TRIANGLE_STRIP, 0, iend + 2); } else { glDrawArrays(GL_TRIANGLE_STRIP, istart, iend - istart + 2); } } if (pen_over_brush()) { pen.Bind(); if (istart != iend && iend != 64) { if (brush.IsHollow()) vertices.bind(); glDrawArrays(GL_LINE_STRIP, istart, 2); glDrawArrays(GL_LINE_STRIP, iend, 2); } const unsigned pstart = istart / 2; const unsigned pend = iend / 2; vertices.bind_inner_circle(); if (pstart < pend) { glDrawArrays(GL_LINE_STRIP, pstart, pend - pstart + 1); } else { glDrawArrays(GL_LINE_STRIP, pstart, 32 - pstart + 1); glDrawArrays(GL_LINE_STRIP, 0, pend + 1); } vertices.bind_outer_circle(); if (pstart < pend) { glDrawArrays(GL_LINE_STRIP, pstart, pend - pstart + 1); } else { glDrawArrays(GL_LINE_STRIP, pstart, 32 - pstart + 1); glDrawArrays(GL_LINE_STRIP, 0, pend + 1); } pen.Unbind(); } }
void Canvas::annulus(int x, int y, unsigned small_radius, unsigned big_radius, Angle start, Angle end) { GLDonutVertices vertices(x, y, small_radius, big_radius); const unsigned istart = AngleToDonutVertex(start); const unsigned iend = AngleToDonutVertex(end); if (!brush.is_hollow()) { brush.set(); vertices.bind(); if (istart > iend) { glDrawArrays(GL_TRIANGLE_STRIP, istart, 64 - istart + 2); glDrawArrays(GL_TRIANGLE_STRIP, 0, iend + 2); } else { glDrawArrays(GL_TRIANGLE_STRIP, istart, iend - istart + 2); } } if (pen_over_brush()) { pen.set(); if (istart != iend) { if (brush.is_hollow()) vertices.bind(); glDrawArrays(GL_LINE_STRIP, istart, 2); glDrawArrays(GL_LINE_STRIP, iend, 2); } const unsigned pstart = istart / 2; const unsigned pend = iend / 2; vertices.bind_inner_circle(); if (pstart < pend) { glDrawArrays(GL_LINE_STRIP, pstart, pend - pstart + 1); } else { glDrawArrays(GL_LINE_STRIP, pstart, 32 - pstart + 1); glDrawArrays(GL_LINE_STRIP, 0, pend + 1); } vertices.bind_outer_circle(); if (pstart < pend) { glDrawArrays(GL_LINE_STRIP, pstart, pend - pstart + 1); } else { glDrawArrays(GL_LINE_STRIP, pstart, 32 - pstart + 1); glDrawArrays(GL_LINE_STRIP, 0, pend + 1); } } }
void Canvas::circle(PixelScalar x, PixelScalar y, UPixelScalar radius) { x += x_offset; y += y_offset; if (!brush.IsHollow()) ::filledCircleColor(surface, x, y, radius, brush.GetColor().GFXColor()); if (pen_over_brush()) ::circleColor(surface, x, y, radius, pen.GetColor().GFXColor()); }
void Canvas::segment(int x, int y, unsigned radius, const RECT rc, double start, double end, bool horizon) { // XXX horizon if (!brush.is_hollow()) ::filledPieColor(surface, x, y, radius, (int)start - 90, (int)end - 90, brush.get_color().gfx_color()); if (pen_over_brush()) ::pieColor(surface, x, y, radius, (int)start - 90, (int)end - 90, pen.get_color().gfx_color()); }
void Canvas::polygon(const RasterPoint *lppt, unsigned cPoints) { if (brush.IsHollow() && !pen.IsDefined()) return; Sint16 vx[cPoints], vy[cPoints]; for (unsigned i = 0; i < cPoints; ++i) { vx[i] = x_offset + lppt[i].x; vy[i] = y_offset + lppt[i].y; } if (!brush.IsHollow()) ::filledPolygonColor(surface, vx, vy, cPoints, brush.GetColor().GFXColor()); if (pen_over_brush()) ::polygonColor(surface, vx, vy, cPoints, pen.GetColor().GFXColor()); }
void Canvas::DrawSegment(PixelScalar x, PixelScalar y, UPixelScalar radius, Angle start, Angle end, bool horizon) { // XXX horizon x += x_offset; y += y_offset; if (!brush.IsHollow()) ::filledPieColor(surface, x, y, radius, (int)start.Degrees() - 90, (int)end.Degrees() - 90, brush.GetColor().GFXColor()); if (pen_over_brush()) ::pieColor(surface, x, y, radius, (int)start.Degrees() - 90, (int)end.Degrees() - 90, pen.GetColor().GFXColor()); }
void Canvas::DrawPolygon(const RasterPoint *points, unsigned num_points) { if (brush.IsHollow() && !pen.IsDefined()) return; glVertexPointer(2, GL_VALUE, 0, points); if (!brush.IsHollow() && num_points >= 3) { brush.Set(); static AllocatedArray<GLushort> triangle_buffer; unsigned idx_count = PolygonToTriangles(points, num_points, triangle_buffer); if (idx_count > 0) glDrawElements(GL_TRIANGLES, idx_count, GL_UNSIGNED_SHORT, triangle_buffer.begin()); } if (pen_over_brush()) { pen.Bind(); if (pen.GetWidth() <= 2) { glDrawArrays(GL_LINE_LOOP, 0, num_points); } else { unsigned vertices = LineToTriangles(points, num_points, vertex_buffer, pen.GetWidth(), true); if (vertices > 0) { glVertexPointer(2, GL_VALUE, 0, vertex_buffer.begin()); glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices); } } pen.Unbind(); } }
void Canvas::polygon(const RasterPoint *points, unsigned num_points) { if (brush.is_hollow() && !pen.defined()) return; glVertexPointer(2, GL_VALUE, 0, points); if (!brush.is_hollow() && num_points >= 3) { brush.set(); static AllocatedArray<GLushort> triangle_buffer; triangle_buffer.grow_discard(3 * (num_points - 2)); unsigned idx_count = polygon_to_triangle(points, num_points, triangle_buffer.begin()); if (idx_count > 0) glDrawElements(GL_TRIANGLES, idx_count, GL_UNSIGNED_SHORT, triangle_buffer.begin()); } if (pen_over_brush()) { pen.set(); if (pen.get_width() <= 2) { glDrawArrays(GL_LINE_LOOP, 0, num_points); } else { vertex_buffer.grow_discard(2 * (num_points + 1)); unsigned vertices = line_to_triangle(points, num_points, vertex_buffer.begin(), pen.get_width(), true); if (vertices > 0) { glVertexPointer(2, GL_VALUE, 0, vertex_buffer.begin()); glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices); } } } }
void rectangle(int left, int top, int right, int bottom) { fill_rectangle(left, top, right, bottom, brush); if (pen_over_brush()) outline_rectangle(left, top, right, bottom, pen.get_color()); }
void Canvas::DrawCircle(PixelScalar x, PixelScalar y, UPixelScalar radius) { if (pen_over_brush() && pen.GetWidth() > 2) { GLDonutVertices vertices(x, y, radius - pen.GetWidth() / 2, radius + pen.GetWidth() / 2); if (!brush.IsHollow()) { vertices.bind_inner_circle(); brush.Set(); glDrawArrays(GL_TRIANGLE_FAN, 0, vertices.CIRCLE_SIZE); } vertices.bind(); pen.Set(); glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices.SIZE); } else if (OpenGL::vertex_buffer_object && radius < 16) { /* draw a "small" circle with VBO */ OpenGL::small_circle_buffer->Bind(); glVertexPointer(2, GL_SHORT, 0, NULL); glPushMatrix(); #ifdef HAVE_GLES glTranslatex((GLfixed)x << 16, (GLfixed)y << 16, 0); glScalex((GLfixed)radius << 8, (GLfixed)radius << 8, (GLfixed)1 << 16); #else glTranslatef(x, y, 0.); glScalef(radius / 256., radius / 256., 1.); #endif if (!brush.IsHollow()) { brush.Set(); glDrawArrays(GL_TRIANGLE_FAN, 0, OpenGL::SMALL_CIRCLE_SIZE); } if (pen_over_brush()) { pen.Bind(); glDrawArrays(GL_LINE_LOOP, 0, OpenGL::SMALL_CIRCLE_SIZE); pen.Unbind(); } glPopMatrix(); OpenGL::small_circle_buffer->Unbind(); } else if (OpenGL::vertex_buffer_object) { /* draw a "big" circle with VBO */ OpenGL::circle_buffer->Bind(); glVertexPointer(2, GL_SHORT, 0, NULL); glPushMatrix(); #ifdef HAVE_GLES glTranslatex((GLfixed)x << 16, (GLfixed)y << 16, 0); glScalex((GLfixed)radius << 6, (GLfixed)radius << 6, (GLfixed)1 << 16); #else glTranslatef(x, y, 0.); glScalef(radius / 1024., radius / 1024., 1.); #endif if (!brush.IsHollow()) { brush.Set(); glDrawArrays(GL_TRIANGLE_FAN, 0, OpenGL::CIRCLE_SIZE); } if (pen_over_brush()) { pen.Bind(); glDrawArrays(GL_LINE_LOOP, 0, OpenGL::CIRCLE_SIZE); pen.Unbind(); } glPopMatrix(); OpenGL::circle_buffer->Unbind(); } else { GLCircleVertices vertices(x, y, radius); vertices.bind(); if (!brush.IsHollow()) { brush.Set(); glDrawArrays(GL_TRIANGLE_FAN, 0, vertices.SIZE); } if (pen_over_brush()) { pen.Bind(); glDrawArrays(GL_LINE_LOOP, 0, vertices.SIZE); pen.Unbind(); } } }