public override void Draw(Graphics2D g) { //1. // clear the image to white CanvasPainter p = new CanvasPainter(g); p.Clear(ColorRGBA.White); // draw a circle p.FillColor = ColorRGBA.Blue; p.FillCircle(50, 50, 30); p.StrokeColor = new ColorRGBA(20, 200, 200); p.Line(10, 100, 520, 50); // draw a filled box p.FillRectangle(60, 260, 200, 280, ColorRGBA.Yellow); // and an outline around it p.Rectangle(60, 260, 200, 280, ColorRGBA.Magenta); p.DrawString("A Simple Example", 300, 400); p.DrawString("A Simple Example2", 300, 350); p.DrawString("A Simple Example3", 300, 300); p.DrawString("A Simple Example4", 300, 250); }
public static void DrawVxsPoints(VertexStore vxs, CanvasPainter p) { int j = vxs.Count; for (int i = 0; i < j; ++i) { double x, y; var cmd = vxs.GetVertex(i, out x, out y); switch (cmd) { case VertexCmd.MoveTo: { p.FillColor = PixelFarm.Drawing.Color.Blue; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; case VertexCmd.P2c: { p.FillColor = PixelFarm.Drawing.Color.Red; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; case VertexCmd.P3c: { p.FillColor = PixelFarm.Drawing.Color.Gray; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; case VertexCmd.LineTo: { p.FillColor = PixelFarm.Drawing.Color.Yellow; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; } } }
public override void Draw(CanvasPainter p) { p.Clear(Drawing.Color.White); //p.SmoothingMode = Drawing.SmoothingMode.AntiAlias; //// draw a circle p.FillColor = Drawing.Color.Blue; p.FillCircle(50, 50, 30); p.StrokeColor = Drawing.Color.FromArgb(20, 200, 200); p.Line(10, 100, 520, 50); //// draw a filled box p.FillRectangle(60, 260, 200, 280, Drawing.Color.Yellow); // and an outline around it p.Rectangle(60, 260, 200, 280, Drawing.Color.Magenta); p.DrawString("A Simple Example", 20, 400); p.DrawString("A Simple Example2", 300, 350); p.DrawString("A Simple Example3", 300, 300); p.DrawString("A Simple Example4", 300, 250); }
public override void Draw(CanvasPainter p) { p.Clear(ColorRGBA.White); //g.UseSubPixelRendering = true; string teststr = "ABCDE abcd 1230 Hello!"; p.DrawString(teststr, 300, 400); //g.UseSubPixelRendering = false; //g.DrawString(teststr, 300, 422, 22); }
public static void DrawVxsPoints(VertexStore vxs, Graphics2D g) { CanvasPainter p = new CanvasPainter(g); int j = vxs.Count; for (int i = 0; i < j; ++i) { double x, y; var cmd = vxs.GetVertex(i, out x, out y); switch (cmd) { case VertexCmd.MoveTo: { p.FillColor = ColorRGBA.DarkGray; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; case VertexCmd.P2c: { p.FillColor = ColorRGBA.Red; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; case VertexCmd.P3c: { p.FillColor = ColorRGBA.Blue; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; case VertexCmd.LineTo: { p.FillColor = ColorRGBA.Yellow; p.FillRectLBWH(x, y, 5, 5); p.DrawString(i.ToString(), x, y + 5); } break; } } }
public override void Draw(CanvasPainter p) { p.Clear(Drawing.Color.White); //g.UseSubPixelRendering = true; string teststr = "ABCDE abcd 1230 Hello!"; //string teststr = "A"; p.FillColor = PixelFarm.Drawing.Color.Black; p.DrawString(teststr, 300, 400); //g.UseSubPixelRendering = false; //g.DrawString(teststr, 300, 422, 22); }
public override void Draw(CanvasPainter p) { p.Clear(ColorRGBA.White); lionFill.Draw(p); p.DrawString("hello", 0, 0); }
void DrawWithPainter(Graphics2D graphics2D) { //create painter CanvasPainter painter = new CanvasPainter(graphics2D); painter.SetClipBox(0, 0, Width, Height); painter.Clear(ColorRGBA.White); //----------------------------------------------------------------------- //green glyph Perspective shadow_persp = new Perspective( m_shape_bounds, m_shadow_ctrl.GetInnerCoords()); VertexStore s2; if (FlattenCurveChecked) { s2 = shadow_persp.TransformToVxs(m_path_2); } else { s2 = shadow_persp.TransformToVxs(m_pathVxs); } painter.FillColor = new ColorRGBAf(0.2f, 0.3f, 0f).ToColorRGBA(); painter.Fill(s2); //--------------------------------------------------------------------------------------------------------- //shadow //--------------------------------------------------------------------------------------------------------- // Calculate the bounding box and extend it by the blur radius RectInt boundRect = BoundingRectInt.GetBoundingRect(s2); var widgetImg = graphics2D.DestImage; int m_radius = this.BlurRadius; //expand bound rect boundRect.Left -= m_radius; boundRect.Bottom -= m_radius; boundRect.Right += m_radius; boundRect.Top += m_radius; if (BlurMethod == BlurMethod.RecursiveBlur) { // The recursive blur method represents the true Gaussian Blur, // with theoretically infinite kernel. The restricted window size // results in extra influence of edge pixels. It's impossible to // solve correctly, but extending the right and top areas to another // radius value produces fair result. //------------------ boundRect.Right += m_radius; boundRect.Top += m_radius; } stopwatch.Stop(); stopwatch.Reset(); stopwatch.Start(); if (BlurMethod != BlurMethod.ChannelBlur) { // Create a new pixel renderer and attach it to the main one as a child image. // It returns true if the attachment succeeded. It fails if the rectangle // (bbox) is fully clipped. //------------------ if (boundRect.Clip(new RectInt(0, 0, widgetImg.Width - 1, widgetImg.Height - 1))) { //check if intersect var prevClip = painter.ClipBox; painter.ClipBox = boundRect; // Blur it switch (BlurMethod) { case BlurMethod.StackBlur: { //------------------ // Faster, but bore specific. // Works only for 8 bits per channel and only with radii <= 254. //------------------ painter.DoFilterBlurStack(boundRect, m_radius); } break; default: { // True Gaussian Blur, 3-5 times slower than Stack Blur, // but still constant time of radius. Very sensitive // to precision, doubles are must here. //------------------ painter.DoFilterBlurRecursive(boundRect, m_radius); } break; } //store back painter.ClipBox = prevClip; } } double tm = stopwatch.ElapsedMilliseconds; painter.FillColor = ColorRGBAf.MakeColorRGBA(0.6f, 0.9f, 0.7f, 0.8f); // Render the shape itself ////------------------ if (FlattenCurveChecked) { //m_ras.AddPath(m_path_2); painter.Fill(m_path_2); } else { //m_ras.AddPath(m_pathVxs); painter.Fill(m_pathVxs); } painter.FillColor = ColorRGBA.Black; painter.DrawString(string.Format("{0:F2} ms", tm), 140, 30); //------------------------------------------------------------- //control m_shadow_ctrl.OnDraw(graphics2D); }
public override void Draw(CanvasPainter p) { //1. // clear the image to white p.Clear(Drawing.Color.White); p.FillColor = Drawing.Color.FromArgb(80, Drawing.Color.Blue); //M414 -20q-163 0 -245 86t-82 236z //<path d="M414 20q-163 40 -245 126t-82 276z"/> //PathWriter path = new PathWriter(); //path.MoveTo(414, 20); //path.Curve3Rel(-163, 40, -245, 126); //path.SmoothCurve3Rel(-82, 246); //path.CloseFigure(); //M414 -20q-163 0 -245 86t-82 236z //PathWriter path = new PathWriter(); //path.MoveTo(414, -20); //path.Curve3Rel(-163, 0, -245, 86); //path.SmoothCurve3Rel(-82, 236); //path.CloseFigure(); //p.Fill(p.FlattenCurves(path.Vxs)); //p.DrawBezierCurve(120, 500 - 160, 220, 500 - 40, 35, 500 - 200, 220, 500 - 260); //--------------------------------------------------- //temp comment, get glyph outline //var fontGlyph = a_font1.GetGlyph('{'); ////outline version //var flat_v = fontGlyph.flattenVxs; //p.Fill(flat_v); //bitmap version //p.DrawImage(fontGlyph.glyphImage32, 20, 30); //----------------------------------------------------- p.CurrentFont = font1; p.FillColor = Drawing.Color.Black; //string test_str = "fมีมี่ญูดุญคำค่าค่ำป่บ่"; //string test_str = "abcde"; string test_str = "I...A Quick Brown Fox Jumps Over The Lazy Dog...I"; //string test_str = "A single pixel on a color LCD"; //string test_str = "กิน กิ่น"; //string test_str = "บ่ป่มีมี่อุอูญญูกินกิ่นก็โก้"; p.UseSubPixelRendering = true; p.DrawString(test_str, 5, 200); //p.DrawString("12345", 50, 200); p.UseSubPixelRendering = false; p.DrawString(test_str, 5, 300); //--------------------------------------------------- p.UseSubPixelRendering = true; p.StrokeColor = Drawing.Color.Black; p.Line(0, 200, 800, 200); p.FillColor = Drawing.Color.Black; p.CurrentFont = font2; p.DrawString(test_str, 80, 100); //--------------------------------------------------- p.UseSubPixelRendering = false; p.DrawString(test_str, 80, 150); //--------------------------------------------------- //p.Fill(fontGlyph.vxs); #if DEBUG //p.Fill(fontGlyph.vxs); // dbugVxsDrawPoints.DrawVxsPoints(flat_v, g); //dbugVxsDrawPoints.DrawVxsPoints(fontGlyph.vxs, g); #endif //p.Fill(p.FlattenCurves(fontGlyph.vxs)); //StyledTypeFace typeFaceForLargeA = new StyledTypeFace(LiberationSansFont.Instance, 300, flatenCurves: false); //var m_pathVxs = typeFaceForLargeA.GetGlyphForCharacter('a'); //Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 50)); //m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs); ////p.FillColor = new ColorRGBA(ColorRGBA.Red, 100); ////p.Fill(m_pathVxs); //p.FillColor = new ColorRGBA(ColorRGBA.Green, 120); //p.Fill(p.FlattenCurves(m_pathVxs)); }
public override void Draw(Graphics2D g) { //1. // clear the image to white CanvasPainter p = new CanvasPainter(g); p.Clear(ColorRGBA.White); p.FillColor = new ColorRGBA(ColorRGBA.Blue, 80); //M414 -20q-163 0 -245 86t-82 236z //<path d="M414 20q-163 40 -245 126t-82 276z"/> //PathWriter path = new PathWriter(); //path.MoveTo(414, 20); //path.Curve3Rel(-163, 40, -245, 126); //path.SmoothCurve3Rel(-82, 246); //path.CloseFigure(); //M414 -20q-163 0 -245 86t-82 236z //PathWriter path = new PathWriter(); //path.MoveTo(414, -20); //path.Curve3Rel(-163, 0, -245, 86); //path.SmoothCurve3Rel(-82, 236); //path.CloseFigure(); //p.Fill(p.FlattenCurves(path.Vxs)); //p.DrawBezierCurve(120, 500 - 160, 220, 500 - 40, 35, 500 - 200, 220, 500 - 260); //--------------------------------------------------- var fontGlyph = font1.GetGlyph('{'); //outline version var flat_v = p.FlattenCurves(fontGlyph.flattenVxs); p.Fill(flat_v); //bitmap version p.DrawImage(fontGlyph.glyphImage32, 20, 30); p.CurrentFont = font1; p.FillColor = ColorRGBA.Black; // string test_str = "มีมี่ญูดุญคำค่าค่ำป่บ่"; //string test_str = "abcde"; string test_str = "บ่ป่มีมี่"; p.UseSubPixelRendering = true; p.DrawString(test_str, 5, 200); //p.DrawString("12345", 50, 200); p.StrokeColor = ColorRGBA.Black; p.Line(0, 200, 800, 200); p.FillColor = ColorRGBA.Black; p.CurrentFont = font2; p.DrawString(test_str, 80, 100); p.UseSubPixelRendering = false; //--------------------------------------------------- //p.Fill(fontGlyph.vxs); #if DEBUG //p.Fill(fontGlyph.vxs); // dbugVxsDrawPoints.DrawVxsPoints(flat_v, g); //dbugVxsDrawPoints.DrawVxsPoints(fontGlyph.vxs, g); #endif //p.Fill(p.FlattenCurves(fontGlyph.vxs)); //StyledTypeFace typeFaceForLargeA = new StyledTypeFace(LiberationSansFont.Instance, 300, flatenCurves: false); //var m_pathVxs = typeFaceForLargeA.GetGlyphForCharacter('a'); //Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 50)); //m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs); ////p.FillColor = new ColorRGBA(ColorRGBA.Red, 100); ////p.Fill(m_pathVxs); //p.FillColor = new ColorRGBA(ColorRGBA.Green, 120); //p.Fill(p.FlattenCurves(m_pathVxs)); }