public override void draw_point(Vector2 p, Rgb rgb, PointStyle s) { if ((int)s >= ids.Length) { s = PointStyle.PointStyleCross; } Vector2 v2d = trans_pos(p); svg_begin_use(ids[(int)s], v2d.x(), v2d.y(), false); svg_add_stroke(rgb); svg_end(); }
void draw_2d_e(Renderer r, Stop stop, Element ref_) { Vector3 mr = new Vector3(0, stop.get_external_radius(), 0); Vector3 top = new Vector3(0, stop.get_shape().get_outter_radius(Vector2.vector2_01), 0); Vector3 bot = new Vector3(0, -stop.get_shape().get_outter_radius(Vector2.vector2_01.negate()), 0); Transform3 t = stop.get_transform_to(ref_); Rgb color = r.get_style_color(stop.get_style()); r.group_begin(""); r.draw_segment(t.transform(top), t.transform(mr), color); r.draw_segment(t.transform(bot), t.transform(mr.negate()), color); r.group_end(); }
public override void draw_circle(Vector2 c, double r, Rgb rgb, bool filled) { Vector2 v2d = trans_pos(c); svg_begin_ellipse(v2d.x(), v2d.y(), x_scale(r), y_scale(r), false); svg_add_stroke(rgb); if (filled) { svg_add_fill(rgb); } else { _out.Append(" fill=\"none\""); } svg_end(); }
public virtual void draw_circle(Vector2 v, double r, Rgb rgb, bool filled) { int count = Math.Min(100, Math.Max(6, (int)(2.0 * Math.PI * r / _feature_size))); Vector2[] p = new Vector2[count]; double astep = 2.0 * Math.PI / count; double a = astep; p[0] = new Vector2(r, 0); for (int i = 0; i < count; i++, a += astep) { p[i] = v.plus(new Vector2(r * Math.Cos(a), r * Math.Sin(a))); } draw_polygon(p, rgb, filled, true); }
/********************************************************************** * Misc shapes 2d drawing */ public virtual void draw_polygon(Vector2[] array, Rgb rgb, bool filled, bool closed) { int i; if (array.Length < 3) { return; } for (i = 0; i + 1 < array.Length; i++) { draw_segment(new Vector2Pair(array[i], array[i + 1]), rgb); } if (closed) { draw_segment(new Vector2Pair(array[i], array[0]), rgb); } }
public override void draw_polygon(Vector2[] array, Rgb rgb, bool filled, bool closed) { if (array.Length < 3) { return; } closed = closed || filled; if (closed) { _out.Append("<polygon"); if (filled) { svg_add_fill(rgb); } else { _out.Append(" fill=\"none\""); svg_add_stroke(rgb); } } else { _out.Append("<polyline fill=\"none\""); svg_add_stroke(rgb); } _out.Append(" points=\""); for (int i = 0; i < array.Length; i++) { Vector2 v2d = trans_pos(array[i]); _out.Append(format(v2d.x())).Append(",").Append(format(v2d.y())).Append(" "); } _out.Append("\" />").Append('\n'); }
public void draw_point(Vector3 p, Rgb rgb, PointStyle s) { draw_point(project(p), rgb, s); }
void svg_add_stroke(Rgb rgb) { _out.Append(" stroke=\""); write_srgb(rgb); _out.Append("\""); }
void svg_add_fill(Rgb rgb) { _out.Append(" fill=\""); write_srgb(rgb); _out.Append("\""); }
/** Draw a point in 2d */ public abstract void draw_point(Vector2 p, Rgb rgb, PointStyle s);
public virtual void draw_triangle(Triangle2 t, bool filled, Rgb rgb) { draw_polygon(t._v, rgb, filled, true); }
public virtual void draw_segment(Vector3 a, Vector3 b, Rgb rgb) { draw_segment(new Vector3Pair(a, b), rgb); }
public abstract void draw_segment(Vector3Pair s, Rgb rgb);
public abstract void draw_text(Vector2 pos, Vector2 dir, string str, int alignMask, int size, Rgb rgb);
public override void draw_segment(Vector3Pair l, Rgb rgb) { draw_segment(new Vector2Pair(project(l.point()), project(l.direction())), rgb); }
public void draw_text(Vector3 pos, Vector3 dir, string str, int a, int size, Rgb rgb) { draw_text(project(pos), project(dir), str, a, size, rgb); }
StringBuilder write_srgb(Rgb rgb) { _out.Append(string.Format("#{0:X2}{1:X2}{2:X2}", (int)(rgb.r * 255.0), (int)(rgb.g * 255.0), (int)(rgb.b * 255.0))); return(_out); }