void BuildEndCap( double x0, double y0, double x1, double y1, List <Vector> outputVectors) { switch (LineCapStyle) { default: throw new NotSupportedException(); case LineCap.Butt: break; case LineCap.Square: break; case LineCap.Round: { //------------------------ //x0,y0 -> end of line 1 //x1,y1 -> end of line 2 //------------------------ double c_x = (x0 + x1) / 2; double c_y = (y0 + y1) / 2; Vector2 delta = new Vector2(x1 - c_x, y1 - c_y); ArcGenerator.GenerateArcNew(outputVectors, c_x, c_y, delta, AggMath.deg2rad(180)); } break; } }
static GlyphMeshStore() { s_flipY = AffineMat.Iden(); s_flipY.Scale(1, -1); // s_slantHorizontal = AffineMat.Iden(); s_slantHorizontal.Skew(AggMath.deg2rad(-15), 0); }
public spiral(double x, double y, double r1, double r2, double step, double start_angle = 0) { m_x = x; m_y = y; m_r1 = r1; m_r2 = r2; m_step = step; m_start_angle = start_angle; m_angle = start_angle; m_da = AggMath.deg2rad(4.0); m_dr = m_step / 90.0; }
public void SetParameters(double x, double y, double r1, double r2, double step, double start_angle = 0) { _x = x; _y = y; _r1 = r1; _r2 = r2; _step = step; _start_angle = start_angle; _angle = start_angle; _da = AggMath.deg2rad(4.0); _dr = _step / 90.0; }
//--------------------------------------------------------------------- public void DrawArc( float fromX, float fromY, float endX, float endY, float xaxisRotationAngleDec, float rx, float ry, SvgArcSize arcSize, SvgArcSweep arcSweep) { //------------------ //SVG Elliptical arc ... //from Apache Batik //----------------- CenterFormArc centerFormArc = new CenterFormArc(); ComputeArc2(fromX, fromY, rx, ry, AggMath.deg2rad(xaxisRotationAngleDec), arcSize == SvgArcSize.Large, arcSweep == SvgArcSweep.Negative, endX, endY, ref centerFormArc); // using (VectorToolBox.Borrow(out Arc arcTool)) using (VxsTemp.Borrow(out var v1, out var v2, out var v3)) { arcTool.Init(centerFormArc.cx, centerFormArc.cy, rx, ry, centerFormArc.radStartAngle, (centerFormArc.radStartAngle + centerFormArc.radSweepDiff)); bool stopLoop = false; foreach (VertexData vertexData in arcTool.GetVertexIter()) { switch (vertexData.command) { case VertexCmd.NoMore: stopLoop = true; break; default: v1.AddVertex(vertexData.x, vertexData.y, vertexData.command); //yield return vertexData; break; } //------------------------------ if (stopLoop) { break; } } double scaleRatio = 1; if (centerFormArc.scaleUp) { int vxs_count = v1.Count; double px0, py0, px_last, py_last; v1.GetVertex(0, out px0, out py0); v1.GetVertex(vxs_count - 1, out px_last, out py_last); double distance1 = Math.Sqrt((px_last - px0) * (px_last - px0) + (py_last - py0) * (py_last - py0)); double distance2 = Math.Sqrt((endX - fromX) * (endX - fromX) + (endY - fromY) * (endY - fromY)); if (distance1 < distance2) { scaleRatio = distance2 / distance1; } else { } } if (xaxisRotationAngleDec != 0) { //also rotate if (centerFormArc.scaleUp) { //var mat = Affine.NewMatix( // new AffinePlan(AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy), // new AffinePlan(AffineMatrixCommand.Scale, scaleRatio, scaleRatio), // new AffinePlan(AffineMatrixCommand.Rotate, DegToRad(xaxisRotationAngleDec)), // new AffinePlan(AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy)); //mat1.TransformToVxs(v1, v2); //v1 = v2; AffineMat mat = AffineMat.Iden; mat.Translate(-centerFormArc.cx, -centerFormArc.cy); mat.Scale(scaleRatio); mat.RotateDeg(xaxisRotationAngleDec); mat.Translate(centerFormArc.cx, centerFormArc.cy); VertexStoreTransformExtensions.TransformToVxs(ref mat, v1, v2); v1 = v2; } else { //not scale //var mat = Affine.NewMatix( // AffinePlan.Translate(-centerFormArc.cx, -centerFormArc.cy), // AffinePlan.RotateDeg(xaxisRotationAngleDec), // AffinePlan.Translate(centerFormArc.cx, centerFormArc.cy)); //mat.TransformToVxs(v1, v2); //v1 = v2; AffineMat mat = AffineMat.Iden; mat.Translate(-centerFormArc.cx, -centerFormArc.cy); mat.RotateDeg(xaxisRotationAngleDec); mat.Translate(centerFormArc.cx, centerFormArc.cy); VertexStoreTransformExtensions.TransformToVxs(ref mat, v1, v2); v1 = v2; } } else { //no rotate if (centerFormArc.scaleUp) { //var mat = Affine.NewMatix( // new AffinePlan(AffineMatrixCommand.Translate, -centerFormArc.cx, -centerFormArc.cy), // new AffinePlan(AffineMatrixCommand.Scale, scaleRatio, scaleRatio), // new AffinePlan(AffineMatrixCommand.Translate, centerFormArc.cx, centerFormArc.cy)); //mat.TransformToVxs(v1, v2); //v1 = v2; AffineMat mat = AffineMat.Iden; mat.Translate(-centerFormArc.cx, -centerFormArc.cy); mat.RotateDeg(scaleRatio); mat.Translate(centerFormArc.cx, centerFormArc.cy); // VertexStoreTransformExtensions.TransformToVxs(ref mat, v1, v2); v1 = v2; } } //_stroke.Width = this.StrokeWidth; //_stroke.MakeVxs(v1, v3); //_pcx.DrawGfxPath(_pcx.StrokeColor, _pathRenderVxBuilder.CreatePathRenderVx(v3)); } }
public override void Draw(Painter p) { if (UseBitmapExt) { p.RenderQuality = RenderQualtity.Fast; } else { p.RenderQuality = RenderQualtity.HighQuality; } p.Clear(Drawing.Color.White); p.UseSubPixelLcdEffect = false; //string teststr = "ABCDE pqyt 1230"; //p.FillColor = Color.Black; //p.CurrentFont = new RequestFont("tahoma", 10); //p.StrokeColor = Color.Red; p.RenderQuality = RenderQualtity.Fast; // //---red reference line-- p.DrawLine(0, 400, 800, 400); p.DrawLine(0, 400, 800, 500); //test oblique line //p.DrawString(teststr, 300, 400); // p.DrawRect(0.5, 400, 40, 40); // p.FillColor = Color.Yellow; p.StrokeColor = Color.Blue; p.FillEllipse(100.5, 400, 40, 60); p.DrawEllipse(50.5, 400, 40, 60); //---red reference line-- p.StrokeColor = Color.Red; p.DrawLine(0, 500, 800, 500); p.StrokeColor = Color.Blue; p.FillColor = Color.Yellow; p.FillRect(0.5, 500, 40, 40); //---red reference line-- //p.DrawImage(lionImg, 0, 0); //reference at 0,0 p.DrawImage(lionImg, 300, 0); int _imgW = lionImg.Width; int _imgH = lionImg.Height; p.RenderQuality = RenderQualtity.Fast; p.DrawImage(lionImg, //move to center of the image (hotspot x,y) AffinePlan.Translate(-_imgW / 2, -_imgH / 2), AffinePlan.Rotate(AggMath.deg2rad(45)), AffinePlan.Scale(0.75, 0.75), //move to target AffinePlan.Translate(400, 200)); }
public override void Draw(Painter p) { if (UseBitmapExt) { p.RenderQuality = RenderQuality.Fast; } else { p.RenderQuality = RenderQuality.HighQuality; } p.Clear(Drawing.Color.Yellow); p.UseSubPixelLcdEffect = false; // //---red reference line-- p.StrokeColor = Color.Black; p.DrawLine(0, 400, 800, 400); //draw reference line p.DrawImage(_lionImg, 300, 0); int _imgW = _lionImg.Width; int _imgH = _lionImg.Height; int x_pos = 0; for (int i = 0; i < 360; i += 30) { p.DrawImage(_lionImg, //move to center of the image (hotspot x,y) AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f), AffinePlan.Scale(0.50, 0.50), AffinePlan.Rotate(AggMath.deg2rad(i)), AffinePlan.Translate((_imgW / 2f) + x_pos, _imgH / 2f) //translate back ); x_pos += _imgW / 3; } using (VxsTemp.Borrow(out var vxs1, out var vxs2)) { SimpleRect sRect = new SimpleRect(); int x = 0, y = 0, w = 100, h = 100; sRect.SetRect(x, y, x + w, y + h); sRect.MakeVxs(vxs1); p.Fill(vxs1, Color.Blue); //------------------- Affine af = Affine.NewMatix( AffinePlan.Translate(-w / 2f, -h / 2f), AffinePlan.Rotate(AggMath.deg2rad(30)), AffinePlan.Translate(w / 2f, h / 2f) ); af.TransformToVxs(vxs1, vxs2); p.Fill(vxs2, Color.Red); //------------------- } }
public override void Draw(Painter p) { if (UseBitmapExt) { p.RenderQuality = RenderQuality.Fast; } else { p.RenderQuality = RenderQuality.HighQuality; } p.Clear(Drawing.Color.White); p.UseSubPixelLcdEffect = false; //---red reference line-- p.StrokeColor = Color.Black; p.DrawLine(0, 400, 800, 400); //draw reference line p.DrawImage(_lionImg, 300, 0); //p.DrawImage(lionImg, 0, 0, 10, 10, 100, 100); // //p.DrawImage(halfLion, 50, 0); int _imgW = _lionImg.Width; int _imgH = _lionImg.Height; int x_pos = 0; int y_pos = 0; var affPlans = new AffinePlan[4]; //1. create new half-size lion image //for (int i = 0; i < 360; i += 30) //{ // affPlans[0] = AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f); // affPlans[1] = AffinePlan.Scale(1, 1); // affPlans[2] = AffinePlan.Rotate(AggMath.deg2rad(i)); // affPlans[3] = AffinePlan.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos); // p.DrawImage(halfLion, affPlans); // x_pos += _imgW / 3; //} x_pos = 0; y_pos = 100; for (int i = 0; i < 360; i += 30) { affPlans[0] = AffinePlan.Translate(-_imgW / 2f, -_imgH / 2f); affPlans[1] = AffinePlan.Scale(0.50, 0.50); affPlans[2] = AffinePlan.Rotate(AggMath.deg2rad(i)); affPlans[3] = AffinePlan.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos); p.DrawImage(_lionImg, affPlans); x_pos += _imgW / 3; } //---- // using (VxsTemp.Borrow(out var vxs1, out var vxs2)) { SimpleRect sRect = new SimpleRect(); int x = 0, y = 0, w = 100, h = 100; sRect.SetRect(x, y, x + w, y + h); sRect.MakeVxs(vxs1); p.Fill(vxs1, Color.Blue); //------------------- Affine af = Affine.NewMatix( AffinePlan.Translate(-w / 2f, -h / 2f), AffinePlan.Rotate(AggMath.deg2rad(30)), AffinePlan.Translate(w / 2f, h / 2f) ); af.TransformToVxs(vxs1, vxs2); p.Fill(vxs2, Color.Red); } }