public static VertexStore RotateDegToNewVxs(this VertexStore src, double deg, VertexStore outputVxs) { return(AffineMat.GetRotateDegMat(deg).TransformToVxs(src, outputVxs)); //TODO: review here, use struct mat //Affine aff = Affine.NewRotationDeg(deg); //return aff.TransformToVxs(src, outputVxs); }
public override void Draw(Painter p) { p.Clear(Drawing.Color.Yellow); //// ////---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) { AffineMat aff = AffineMat.Iden(); aff.Translate(-_imgW / 2f, -_imgH / 2f); aff.Scale(0.5, 0.5); aff.RotateDeg(i); aff.Translate((_imgW / 2f) + x_pos, _imgH / 2f); p.DrawImage(_lionImg, aff); x_pos += _imgW / 3; } using (Tools.BorrowVxs(out var vxs1, out var vxs2)) using (Tools.BorrowRect(out var rect)) { int x = 5, y = 5, w = 100, h = 100; rect.SetRect(x, y, x + w, y + h); rect.MakeVxs(vxs1); p.Fill(vxs1, Color.Blue); //------------------- AffineMat af = AffineMat.GetRotateDegMat(30, w / 2f, h / 2f); af.TransformToVxs(vxs1, vxs2); p.Fill(vxs2, Color.Red); //------------------- } }
public override void Draw(Painter p) { p.Clear(Drawing.Color.White); p.UseLcdEffectSubPixelRendering = 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; //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) { AffineMat aff = AffineMat.Iden(); aff.Translate(-_imgW / 2f, -_imgH / 2f); aff.Scale(0.5, 0.5); aff.RotateDeg(i); aff.Translate((_imgW / 2f) + x_pos, (_imgH / 2f) + y_pos); p.DrawImage(_lionImg, aff); x_pos += _imgW / 3; } //---- // using (Tools.BorrowVxs(out var vxs1, out var vxs2)) using (Tools.BorrowRect(out var rect)) { int x = 5, y = 5, w = 100, h = 100; rect.SetRect(x, y, x + w, y + h); rect.MakeVxs(vxs1); p.Fill(vxs1, Color.Blue); //------------------- AffineMat mat = AffineMat.GetRotateDegMat(30, w / 2f, h / 2f); mat.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.StrokeColor = Color.Blue; p.Clear(Drawing.Color.White); p.UseLcdEffectSubPixelRendering = false; //string teststr = "ABCDE pqyt 1230"; //p.FillColor = Color.Black; //p.CurrentFont = new RequestFont("tahoma", 10); //p.StrokeColor = Color.Red; p.RenderQuality = RenderQuality.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.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.RenderQuality = RenderQuality.Fast; //p.DrawImage(lionImg, 0, 0); //reference at 0,0 p.DrawImage(_lionImg, 300, 0); int _imgW = _lionImg.Width; int _imgH = _lionImg.Height; //p.RenderQuality = RenderQuality.Fast; AffineMat mat = AffineMat.GetRotateDegMat(30, _imgW / 2, _imgH / 2); p.DrawImage(_lionImg, mat); //AffinePlan.Scale(0.75, 0.75), //move to target //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)); }