void RunSampleE(PixelFarm.Drawing.Painter p) { //version 4: p.Clear(PixelFarm.Drawing.Color.White); p.UseSubPixelLcdEffect = this.EnableSubPix; //-------------------------- p.StrokeColor = PixelFarm.Drawing.Color.Black; p.StrokeWidth = 2.0f; p.DrawLine(2, 0, 10, 15); int lineLen = 10; int x = 30; int y = 30; p.FillColor = PixelFarm.Drawing.Color.Black; p.FillRect(0, 0, 1, 1); for (int i = 0; i < 360; i += 30) { p.DrawLine(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i))); } y += 10; for (int i = 0; i < 360; i += 360) { p.DrawLine(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i))); } }
void RunSampleF(PixelFarm.Drawing.Painter p) { //version 4: p.Clear(PixelFarm.Drawing.Color.White); p.UseSubPixelLcdEffect = this.EnableSubPix; //-------------------------- p.StrokeColor = PixelFarm.Drawing.Color.Black; p.StrokeWidth = 2.0f; p.DrawLine(2, 0, 10, 15); int lineLen = 10; int x = 30; int y = 30; p.FillColor = PixelFarm.Drawing.Color.Black; VertexStorePool pool = new VertexStorePool(); using (System.IO.FileStream fs = new System.IO.FileStream("c:\\Windows\\Fonts\\tahoma.ttf", System.IO.FileMode.Open, System.IO.FileAccess.Read)) { Typography.OpenFont.OpenFontReader reader = new Typography.OpenFont.OpenFontReader(); Typography.OpenFont.Typeface typeface = reader.Read(fs); var builder = new Typography.Contours.GlyphPathBuilder(typeface); builder.BuildFromGlyphIndex((ushort)typeface.LookupIndex('C'), 16); PixelFarm.Drawing.Fonts.GlyphTranslatorToVxs tovxs = new Drawing.Fonts.GlyphTranslatorToVxs(); builder.ReadShapes(tovxs); VertexStore vxs = new VertexStore(); tovxs.WriteOutput(vxs); p.Fill(vxs); } p.FillRect(0, 0, 20, 20); }
void DrawD(PixelFarm.Drawing.Painter painter) { PathWriter ps = new PathWriter(); painter.Clear(PixelFarm.Drawing.Color.White); painter.StrokeColor = PixelFarm.Drawing.Color.Red; //p.Line(10, 10, 50, 10); //p.Line(50, 10, 50, 50); //p.Line(50, 50, 10, 50); //p.Line(50, 10, 10, 10); ps.Clear(); ps.MoveTo(10, 10); ps.LineTo(50, 10); ps.LineTo(50, 50); ps.LineTo(10, 50); ps.CloseFigure(); // //ps.MoveTo(15, 15); //ps.LineTo(15, 45); //ps.LineTo(45, 45); //ps.LineTo(45, 15); //ps.CloseFigure(); // //p.Fill(ps.Vxs, PixelFarm.Drawing.Color.Black); painter.Draw(ps.Vxs, PixelFarm.Drawing.Color.Red); }
void RunSampleD(PixelFarm.Drawing.Painter p) { //version 4: p.Clear(PixelFarm.Drawing.Color.White); p.UseSubPixelLcdEffect = this.EnableSubPix; //-------------------------- p.StrokeColor = PixelFarm.Drawing.Color.Black; p.StrokeWidth = 1.0f; //p.Line(2, 0, 10, 15); int lineLen = 10; int x = 30; int y = 30; for (int i = 0; i < 360; i += 15) { p.DrawLine(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i))); y += 5; } //y += 10; //for (int i = 0; i < 360; i += 360) //{ // p.Line(x, y, x + lineLen * Math.Cos(DegToRad(i)), y + lineLen * Math.Sin(DegToRad(i))); //} }
public override void Draw(PixelFarm.Drawing.Painter p) { p.RenderQuality = RenderQuality.Fast; Brush prevBrush = p.CurrentBrush; Brush selectedBrush = _linearGrBrush; p.Clear(Color.White); switch (SelectedBrushKind) { case BrushKind.LinearGradient: break; case BrushKind.CircularGradient: selectedBrush = _circularGrBrush; break; case BrushKind.PolygonGradient: selectedBrush = _polygonGradientBrush; break; } // p.CurrentBrush = selectedBrush; p.FillRect(0, 100, 500, 500); //p.FillRect(0, 200, 200, 50); //p.Fill(_triangleVxs); ////------------- p.CurrentBrush = prevBrush; }
void RunSampleC(PixelFarm.Drawing.Painter p) { //version 3: p.Clear(PixelFarm.Drawing.Color.White); //--------------------------------------------- p.StrokeColor = PixelFarm.Drawing.Color.Black; p.StrokeWidth = 1.0f; p.UseSubPixelLcdEffect = this.EnableSubPix; p.DrawLine(0, 1, 15, 20); }
public override void Draw(PixelFarm.Drawing.Painter p) { p.Clear(Drawing.Color.White); p.FillColor = Drawing.Color.Black; int j = myBrushPathList.Count; for (int n = 0; n < j; ++n) { var brushPath = myBrushPathList[n]; if (brushPath.Vxs != null) { switch (brushPath.BrushMode) { case SmoothBrushMode.CutBrush: { } break; default: { //TODO: review PixelCache here p.FillColor = brushPath.FillColor; p.Fill(brushPath.Vxs); #if DEBUG //if (brushPath.StrokeColor.alpha > 0) //{ // p.StrokeColor = Drawing.Color.Red; // p.Draw(brushPath.Vxs); //} #endif } break; } } else { //current drawing brush var contPoints = brushPath.contPoints; int pcount = contPoints.Count; for (int i = 1; i < pcount; ++i) { var p0 = contPoints[i - 1]; var p1 = contPoints[i]; p.DrawLine(p0.x, p0.y, p1.x, p1.y); } } } }
void DrawE(PixelFarm.Drawing.Painter painter) { PathWriter ps = new PathWriter(); painter.Clear(PixelFarm.Drawing.Color.White); painter.StrokeColor = PixelFarm.Drawing.Color.Red; //p.Line(10, 10, 50, 10); //p.Line(50, 10, 50, 50); //p.Line(50, 50, 10, 50); //p.Line(50, 10, 10, 10); ps.Clear(); //ps.MoveTo(10, 10); //ps.LineTo(50, 10); //ps.LineTo(50, 50); //ps.MoveTo(10, 10); //ps.LineTo(50, 10); //ps.LineTo(10, 20); ps.MoveTo(150, 10); ps.LineTo(110, 10); ps.LineTo(150, 20); //ps.MoveTo(50, 50); //ps.LineTo(40, 50); //ps.LineTo(80, 70); //ps.CloseFigure(); //p.Fill(ps.Vxs, PixelFarm.Drawing.Color.Black); VertexStore output = new VertexStore(); StrokeGen2 gen2 = new StrokeGen2(); gen2.LineCapStyle = LineCap.Butt; gen2.LineJoinStyle = LineJoin.Miter; gen2.HalfStrokeWidth = 7;// gen2.Generate(ps.Vxs, output); //----------------------------------------------------- painter.Fill(output, PixelFarm.Drawing.Color.Red); painter.StrokeWidth = 1f; painter.Draw(ps.Vxs, PixelFarm.Drawing.Color.Black); }
void RunSampleA(PixelFarm.Drawing.Painter p) { //1. create simple vertical line to test agg's lcd rendernig technique //create gray-scale actual image ActualImage glyphImg = new ActualImage(100, 100, PixelFormat.ARGB32); AggRenderSurface glyph2d = new AggRenderSurface(glyphImg); AggPainter painter = new AggPainter(glyph2d); painter.StrokeColor = PixelFarm.Drawing.Color.Black; painter.StrokeWidth = 2.0f * 3; int x = 10, y = 10; painter.DrawLine(x * 3, 0, y * 3, 20); //scale horizontal 3 times, int lineLen = 4; //painter.Line(x * 3, 0, y * 3, 20); //scale horizontal 3 times, //painter.Line(2, 0, 2, 15); //painter.Line(2, 0, 20, 20); //painter.Line(2, 0, 30, 15); //painter.Line(2, 0, 30, 5); //clear surface bg p.Clear(PixelFarm.Drawing.Color.White); //draw img into that bg //--------------- //convert glyphImg from RGBA to grey Scale buffer //--------------- //lcd process ... byte[] glyphGreyScale = CreateGreyScaleBuffer(glyphImg); //--------------- //swap gray scale int newGreyImgStride; byte[] expanedGreyScaleBuffer = CreateNewExpandedLcdGrayScale(glyphGreyScale, glyphImg.Width, glyphImg.Height, out newGreyImgStride); //blend lcd var aggPainer = (PixelFarm.Agg.AggPainter)p; Blend(aggPainer.RenderSurface.DestActualImage, expanedGreyScaleBuffer, newGreyImgStride, glyphImg.Height); //--------------- p.DrawImage(glyphImg, 0, 50); }
void RunSampleA(PixelFarm.Drawing.Painter p) { //1. create simple vertical line to test agg's lcd rendernig technique //create gray-scale actual image using (MemBitmap glyphBmp = new MemBitmap(100, 100)) { int x = 10, y = 10; using (AggPainterPool.Borrow(glyphBmp, out var painter)) { painter.StrokeColor = PixelFarm.Drawing.Color.Black; painter.StrokeWidth = 2.0f * 3; painter.DrawLine(x * 3, 0, y * 3, 20); //scale horizontal 3 times, s } //painter.Line(x * 3, 0, y * 3, 20); //scale horizontal 3 times, //painter.Line(2, 0, 2, 15); //painter.Line(2, 0, 20, 20); //painter.Line(2, 0, 30, 15); //painter.Line(2, 0, 30, 5); //clear surface bg p.Clear(PixelFarm.Drawing.Color.White); //draw img into that bg //--------------- //convert glyphImg from RGBA to grey Scale buffer //--------------- //lcd process ... byte[] glyphGreyScale = CreateGreyScaleBuffer(glyphBmp); //--------------- //swap gray scale int newGreyImgStride; byte[] expanedGreyScaleBuffer = CreateNewExpandedLcdGrayScale(glyphGreyScale, glyphBmp.Width, glyphBmp.Height, out newGreyImgStride); //blend lcd var aggPainer = (PixelFarm.CpuBlit.AggPainter)p; Blend(aggPainer.RenderSurface.DestBitmap, expanedGreyScaleBuffer, newGreyImgStride, glyphBmp.Height); //--------------- p.DrawImage(glyphBmp, 0, 50); } }
public override void Draw(PixelFarm.Drawing.Painter p) { AggPainter aggPainter = (AggPainter)p; //---------------- //5. use PixelFarm's Agg to render to bitmap... //5.1 clear background p.Clear(PixelFarm.Drawing.Color.White); if (FillBG) { //5.2 p.FillColor = PixelFarm.Drawing.Color.Black; //5.3 //p.Fill(vxs); float x = aggPainter.OriginX; float y = aggPainter.OriginY; p.Fill(left_vxs); aggPainter.SetOrigin(x + 50, y + 20); p.Fill(right_vxs); aggPainter.SetOrigin(x, y); } if (FillBorder) { //5.4 p.StrokeColor = PixelFarm.Drawing.Color.Green; //user can specific border width here... //p.StrokeWidth = 2; //5.5 //p.Draw(vxs); float x = aggPainter.OriginX; float y = aggPainter.OriginY; p.Fill(left_vxs); aggPainter.SetOrigin(x + 50, y + 20); p.Fill(right_vxs); aggPainter.SetOrigin(x, y); } }
void RunSampleB(PixelFarm.Drawing.Painter p) { //version 2: //1. create simple vertical line to test agg's lcd rendernig technique //create gray-scale actual image using (MemBitmap glyphBmp = new MemBitmap(100, 100)) { AggPainter painter = AggPainter.Create(glyphBmp); // painter.StrokeColor = PixelFarm.Drawing.Color.Black; painter.StrokeWidth = 2.0f; painter.DrawLine(2, 0, 3, 15); //not need to scale3 // //clear surface bg p.Clear(PixelFarm.Drawing.Color.White); //-------------------------- var aggPainer = (PixelFarm.CpuBlit.AggPainter)p; BlendWithLcdTechnique(aggPainer.RenderSurface.DestBitmap, glyphBmp, PixelFarm.Drawing.Color.Black); //--------------- p.DrawImage(glyphBmp, 0, 50); //--------------- } }
void RunSampleB(PixelFarm.Drawing.Painter p) { //version 2: //1. create simple vertical line to test agg's lcd rendernig technique //create gray-scale actual image ActualImage glyphImg = new ActualImage(100, 100, PixelFormat.ARGB32); AggRenderSurface glyph2d = new AggRenderSurface(glyphImg); AggPainter painter = new AggPainter(glyph2d); // painter.StrokeColor = PixelFarm.Drawing.Color.Black; painter.StrokeWidth = 2.0f; painter.DrawLine(2, 0, 3, 15);//not need to scale3 // //clear surface bg p.Clear(PixelFarm.Drawing.Color.White); //-------------------------- var aggPainer = (PixelFarm.Agg.AggPainter)p; BlendWithLcdTechnique(aggPainer.RenderSurface.DestActualImage, glyphImg, PixelFarm.Drawing.Color.Black); //--------------- p.DrawImage(glyphImg, 0, 50); //--------------- }
public void RenderChar(char testChar, HintTechnique hint) { builder.SetHintTechnique(hint); #if DEBUG GlyphBoneJoint.dbugTotalId = 0;//reset builder.dbugAlwaysDoCurveAnalysis = true; #endif _infoView.Clear(); _latestHint = hint; _testChar = testChar; //---------------------------------------------------- // builder.Build(testChar, _sizeInPoint); var txToVxs1 = new GlyphTranslatorToVxs(); builder.GlyphDynamicEdgeOffset = this.GlyphEdgeOffset; builder.ReadShapes(txToVxs1); #if DEBUG var ps = txToVxs1.dbugGetPathWriter(); _infoView.ShowOrgBorderInfo(ps.Vxs); #endif PixelFarm.Drawing.VertexStore vxs = new PixelFarm.Drawing.VertexStore(); txToVxs1.WriteOutput(vxs); //---------------------------------------------------- //---------------------------------------------------- painter.UseSubPixelLcdEffect = this.UseLcdTechnique; //5. use PixelFarm's Agg to render to bitmap... //5.1 clear background painter.Clear(PixelFarm.Drawing.Color.White); RectD bounds = new RectD(); BoundingRect.GetBoundingRect(new PixelFarm.Drawing.VertexStoreSnap(vxs), ref bounds); //---------------------------------------------------- float scale = _typeface.CalculateScaleToPixelFromPointSize(_sizeInPoint); _pxscale = scale; this._infoView.PxScale = scale; var left2 = 0; int floor_1 = (int)left2; float diff = left2 - floor_1; //---------------------------------------------------- if (OffsetMinorX) { MinorOffsetInfo = left2.ToString() + " =>" + floor_1 + ",diff=" + diff; } else { MinorOffsetInfo = left2.ToString(); } //5. use PixelFarm's Agg to render to bitmap... //5.1 clear background painter.Clear(PixelFarm.Drawing.Color.White); if (FillBackGround) { //5.2 painter.FillColor = PixelFarm.Drawing.Color.Black; float xpos = 5;// - diff; if (OffsetMinorX) { xpos -= diff; } painter.SetOrigin(xpos, 10); painter.Fill(vxs); } if (DrawBorder) { //5.4 painter.StrokeColor = PixelFarm.Drawing.Color.Green; //user can specific border width here... //5.5 painter.Draw(vxs); //-------------- int markOnVertexNo = _infoView.DebugMarkVertexCommand; double x, y; vxs.GetVertex(markOnVertexNo, out x, out y); painter.FillRect(x, y, 4, 4, PixelFarm.Drawing.Color.Red); //-------------- _infoView.ShowFlatternBorderInfo(vxs); //-------------- } #if DEBUG builder.dbugAlwaysDoCurveAnalysis = false; #endif if (ShowTess) { RenderTessTesult(); } //if (DrawDynamicOutline) //{ // GlyphDynamicOutline dynamicOutline = builder.LatestGlyphFitOutline; // WalkDynamicOutline(painter, dynamicOutline, scale, DrawRegenerateOutline); //} }
public override void Draw(PixelFarm.Drawing.Painter p) { p.Clear(Drawing.Color.White); p.StrokeColor = Color.Black; p.StrokeWidth = 2; p.StrokeColor = Color.Green; p.Draw(_triangleVxs); if (!ShowReconstructionCurve) { return; } //draw Ci line p.StrokeColor = KnownColors.OrangeRed; DrawLine(p, a01, a12); DrawLine(p, a12, a20); DrawLine(p, a20, a01); //find B //DrawPoint(p, a01); //DrawPoint(p, a12); //DrawPoint(p, a20); BezierControllerArmPair c1 = BezierControllerArmPair.ReconstructControllerArms(v0, v1, v2); BezierControllerArmPair c2 = BezierControllerArmPair.ReconstructControllerArms(v1, v2, v0); BezierControllerArmPair c0 = BezierControllerArmPair.ReconstructControllerArms(v2, v0, v1); c0.UniformSmoothCoefficient = SmoothCoefficientValue; c1.UniformSmoothCoefficient = SmoothCoefficientValue; c2.UniformSmoothCoefficient = SmoothCoefficientValue; //DrawPoint(p, c0 = FindB(v0, v1, v2, out c1)); //DrawPoint(p, b2 = FindB(v1, v2, v0, out c2)); //DrawPoint(p, b0 = FindB(v2, v0, v1, out c0)); p.StrokeColor = Color.Red; DrawControllerPair(p, c0); DrawControllerPair(p, c1); DrawControllerPair(p, c2); p.StrokeColor = Color.Blue; using (Tools.BorrowVxs(out var tmpVxs1, out var tmpVxs2)) using (Tools.BorrowPathWriter(tmpVxs1, out var pw)) { pw.MoveTo(c0.mid.X, c0.mid.y); pw.Curve4(c0.right.x, c0.right.y, c1.left.x, c1.left.y, c1.mid.x, c1.mid.y); //1st curve pw.Curve4(c1.right.x, c1.right.y, c2.left.x, c2.left.y, c2.mid.x, c2.mid.y); //2nd curve pw.Curve4(c2.right.x, c2.right.y, c0.left.x, c0.left.y, c0.mid.x, c0.mid.y); //3rd curve _curveflattener.MakeVxs(tmpVxs1, tmpVxs2); p.Draw(tmpVxs2); } }
public override void Draw(PixelFarm.Drawing.Painter p) { p.RenderQuality = RenderQuality.Fast; Brush prevBrush = p.CurrentBrush; Brush selectedBrush; p.Clear(Color.White); switch (SelectedBrushKind) { default: throw new NotSupportedException(); case BrushKind.SolidBrush: selectedBrush = _solidBrush; break; case BrushKind.LinearGradient: selectedBrush = _linearGrBrush; break; case BrushKind.CircularGradient: selectedBrush = _circularGrBrush; break; case BrushKind.PolygonGradient: selectedBrush = _polygonGradientBrush; break; } // p.CurrentBrush = selectedBrush; //special set for our GLPainter bool glPainter2MaskColor = false; DrawingGL.GLPainter glPainter = p as DrawingGL.GLPainter; if (glPainter != null) { glPainter2MaskColor = glPainter.UseTwoColorsMask; glPainter.UseTwoColorsMask = EnableGLPainterTwoColorsMask; } //p.FillRect(0, 100, 500, 500); //p.FillRect(0, 200, 200, 50); if (UseClipRegion) { //fill vxs region1 p.FillRegion(_triangleVxs); //fill vxs region2 if (UseOffset) { float prev_ox = p.OriginX; float prev_oy = p.OriginY; p.SetOrigin(100, 120); p.FillRegion(_triangleVxs); p.SetOrigin(prev_ox, prev_oy);//restore } else { p.FillRegion(_triangleVxs2); } } else { p.Fill(_triangleVxs); if (UseOffset) { float prev_ox = p.OriginX; float prev_oy = p.OriginY; p.SetOrigin(100, 120); p.Fill(_triangleVxs); p.SetOrigin(prev_ox, prev_oy);//restore } else { p.Fill(_triangleVxs2); } } //------------- p.CurrentBrush = prevBrush; if (glPainter != null) { //restore glPainter.UseTwoColorsMask = glPainter2MaskColor; } }