public override void DrawEllipse(PBrush c, float width, RectangleF rect) { const int DETAIL = 50; float x = (rect.Left + rect.Right) / 2f; float y = (rect.Top + rect.Bottom) / 2f; float rx = (rect.Right - rect.Left) / 2f; float ry = (rect.Bottom - rect.Top) / 2f; float w = 1 - width * 2f / (rx + ry); if (c != null) { GL.Color(c.GetColor()); } GL.Begin(PrimitiveType.QUADS); double lA = 0; for (int i = 1; i <= DETAIL; i++) { double a = i * Math.PI * 2.0 / DETAIL; float sin1 = (float)Math.Sin(lA); float cos1 = (float)Math.Cos(lA); float sin2 = (float)Math.Sin(a); float cos2 = (float)Math.Cos(a); float[] ptsx = new float[] { cos1, cos1 *w, cos2 *w, cos2 }; float[] ptsy = new float[] { sin1, sin1 *w, sin2 *w, sin2 }; NativeGL.nglVertex2fTrans(4, ptsx, ptsy, x, y, rx, ry); lA = a; } GL.End(); }
public override void DrawRoundedRectangle(PBrush c, float width, RectangleF rect) { g.DrawRectangle(new Pen(c.Brush, width) { LineJoin = System.Drawing.Drawing2D.LineJoin.Round }, rect.X, rect.Y, rect.Width, rect.Height); }
public override void BeginCircles(PBrush brush) { if (brush != null) { GL.Color(brush.GetColor()); } GL.Begin(PrimitiveType.TRIANGLE_STRIP); }
public ImageObject(Renderer.Image image, RectangleF rect) { Brush = PBrush.CreateSolid(Color.White); this.image = image; AddPoint(rect.Left, rect.Top, 1); AddPoint(rect.Right, rect.Top, 1); AddPoint(rect.Right, rect.Bottom, 1); AddPoint(rect.Left, rect.Bottom, 1); }
public override void DrawRoundedLine(PBrush c, float width, PointF p1, PointF p2) { g.DrawLine(new Pen(c.Brush, width) { DashCap = System.Drawing.Drawing2D.DashCap.Round, EndCap = System.Drawing.Drawing2D.LineCap.Round, StartCap = System.Drawing.Drawing2D.LineCap.Round }, p1, p2); }
public override void FillPolygon(PBrush b, PointF[] pts) { /*GL.Begin(PrimitiveType.Polygon); * GL.Color3(b.GetColors()[0]); * for (int i = 0; i < pts.Length; i++) * { * GL.Vertex2(pts[i].X, pts[i].Y); * } * GL.End();*/ }
public override void DrawText(string text, PBrush brush, RectangleF rect, float size) { float x = Util.MmToPoint(rect.X); float y = Util.MmToPoint(rect.Y); float w = Util.MmToPoint(rect.Width); float h = 0; g.DrawString(text, new XFont("Calibri", Util.MmToPoint(size) * 1.3), createBrush(brush), new RectangleF(x, y, w, h)); }
public override void DrawEllipse(PBrush c, float width, RectangleF rect) { using (Brush b = GetBrush(c)) { Ellipse ell = new Ellipse(); ell.Point = new RawVector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); ell.RadiusX = rect.Width / 2; ell.RadiusY = rect.Height / 2; renderTarget.DrawEllipse(ell, b, width); } }
public override void FillEllipse(PBrush c, RectangleF rect) { using (SolidColorBrush b = new SolidColorBrush(renderTarget, c.GetColor().ToColor4())) { Ellipse ell = new Ellipse(); ell.Point = new RawVector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2); ell.RadiusX = rect.Width / 2; ell.RadiusY = rect.Height / 2; renderTarget.FillEllipse(ell, b); } }
public override void DrawRoundedLine(PBrush c, float width, PointF p1, PointF p2) { using (Brush b = GetBrush(c)) { StrokeStyle style = new StrokeStyle(factory, new StrokeStyleProperties() { StartCap = CapStyle.Round, EndCap = CapStyle.Round }); renderTarget.DrawLine(p1.ToVector(), p2.ToVector(), b, width, style); style.Dispose(); } }
public override void DrawRoundedRectangle(PBrush c, float width, RectangleF rect) { using (Brush b = GetBrush(c)) { RoundedRectangle rr = new RoundedRectangle(); rr.Rect.Left = rect.Left; rr.Rect.Right = rect.Right; rr.Rect.Top = rect.Top; rr.Rect.Bottom = rect.Bottom; rr.RadiusX = width / 2; rr.RadiusY = width / 2; renderTarget.DrawRoundedRectangle(rr, b, width); } }
public override void FillEllipse(PBrush c, RectangleF rect) { float x = (rect.Left + rect.Right) / 2f; float y = (rect.Top + rect.Bottom) / 2f; float rx = (rect.Right - rect.Left) / 2f; float ry = (rect.Bottom - rect.Top) / 2f; if (c != null) { GL.Color(c.GetColor()); } GL.Begin(PrimitiveType.TRIANGLES); NativeGL.nglVertex2fTrans(pEllipseX.Length, pEllipseX, pEllipseY, x, y, rx, ry); GL.End(); }
public override void DrawText(string str, PBrush brush, RectangleF rect, float size) { float sizept = Util.MmToPoint(size); float px = Util.MmToPoint(rect.X); float py = Util.MmToPoint(rect.Y); float pw = Util.MmToPoint(rect.Width); float ph = Util.MmToPoint(rect.Height); RawRectangleF rectpt = new RawRectangleF(px, py, pw, ph); text.TextFormat format = new text.TextFormat(writeFactory, "Arial", sizept); using (Brush b = GetBrush(brush)) { renderTarget.DrawText(str, format, rectpt, b, DrawTextOptions.None, MeasuringMode.GdiNatural); } }
public override void Draw(GPURenderer renderer, int width, int height) { int _x = x; int _y = y; control.GetTransform().Transform(ref _x, ref _y); renderer.Transform(Transformation); PBrush brushI = PBrush.CreateSolid(Color.White); PBrush brushO = PBrush.CreateSolid(Color.Black); RectangleF rect = new RectangleF(_x - innerRad, _y - innerRad, innerRad * 2, innerRad * 2); renderer.FillEllipse(brushI, rect); renderer.DrawEllipse(brushO, 4, rect); renderer.DrawImage(img, rect); }
public override void Draw(BaseRenderer r, PageFormat format, float border, Color mainColor, Color secondaryColor) { PBrush brush = PBrush.CreateSolid(mainColor); r.BeginCircles(brush); for (float x = border; x < format.Width - border; x += 5) { float xpx = Util.MmToPoint(x); for (float y = border; y < format.Height - border; y += 5) { float ypx = Util.MmToPoint(y); r.Circle(xpx, ypx, 1); } } r.EndCircle(); }
public override void Draw(GPURenderer renderer, int width, int height) { renderer.Transform(Transformation); RectangleF rect = new RectangleF(0, 0, width, size); renderer.FillRectangle(Color.FromArgb(100, 200, 200, 200), rect); renderer.DrawRect(Color.Black, 1, rect); float scale = parent.GetTransform().GetScale(); int linMM = (int)(Util.PointToMm(width) / scale); float len1 = Util.MmToPoint(3); float len2 = Util.MmToPoint(5); float len3 = Util.MmToPoint(10); renderer.BeginLines(Color.Black, 1); for (int i = 0; i <= linMM; i++) { float x = Util.MmToPoint(i) * scale; float y1 = len1; if (i % 5 == 0) { y1 = len2; } if (i % 10 == 0) { y1 = len3; } renderer.BatchedLine(new PointF(x, 0), new PointF(x, y1)); renderer.BatchedLine(new PointF(x, size), new PointF(x, size - y1)); //renderer.DrawLine(Color.Black, 1, new PointF(x, 0), new PointF(x, y1)); //renderer.DrawLine(Color.Black, 1, new PointF(x, size), new PointF(x, size - y1)); } renderer.EndLines(); float tx = width / 2; double deg = Math.Abs( Math.Round( (Transformation.GetRotation() - parent.GetTransform().GetRotation()) * 18000.0 / Math.PI) / 100.0); if (deg > 90) { deg = 180 - deg; } renderer.DrawText("" + deg + "°", PBrush.CreateSolid(Color.Tomato), new RectangleF(Util.PointToMm(tx), 10, 50, 50), 20); }
public override void Draw(GPURenderer renderer, int width, int height) { renderer.Transform(Transformation); int _x = x; int _y = y; control.GetTransform().Transform(ref _x, ref _y); Rectangle rect = new Rectangle(_x - rad, _y - rad, 2 * rad, 2 * rad); renderer.DrawEllipse(PBrush.CreateSolid(Color.White), this.width, rect); rect.Extend(-this.width / 2); renderer.DrawEllipse(PBrush.CreateSolid(Color.Black), 4, rect); rect.Extend(this.width); renderer.DrawEllipse(PBrush.CreateSolid(Color.Black), 4, rect); Matrix3x3 mat = new Matrix3x3(); mat.TransformRotateAt(ringRot, _x, _y); renderer.Transform(mat); renderer.DrawImage(img, new RectangleF(imRect.X + _x, imRect.Y + _y, imRect.Width, imRect.Height)); }
public override void DrawRoundedRectangle(PBrush c, float width, RectangleF rect) { GL.Color(c.GetColor()); PointF p1 = new PointF(rect.Left, rect.Top); PointF p2 = new PointF(rect.Right, rect.Top); PointF p3 = new PointF(rect.Right, rect.Bottom); PointF p4 = new PointF(rect.Left, rect.Bottom); GL.Begin(PrimitiveType.QUADS); drawLine(width, p1, p2); drawLine(width, p2, p3); drawLine(width, p3, p4); drawLine(width, p4, p1); GL.End(); BeginCircles(null); Circle(p1.X, p1.Y, width / 2); Circle(p2.X, p2.Y, width / 2); Circle(p3.X, p3.Y, width / 2); Circle(p4.X, p4.Y, width / 2); EndCircle(); }
public override void DrawText(string str, PBrush brush, RectangleF rect, float size) { float quality = 5; size = Util.MmToPoint(size); rect = Util.MmToPoint(rect); gdi.Graphics dummy = gdi.Graphics.FromHwnd(IntPtr.Zero); gdi.Font ft = new gdi.Font("Calibri", size / Util.GetScaleFactor() * quality); gdi.SizeF s = dummy.MeasureString(str, ft); s.Height *= 2; s.Height *= quality; s.Width *= quality; gdi.Bitmap bmp = new gdi.Bitmap((int)s.Width, (int)s.Height); gdi.Color c1 = brush.GetColor(); gdi.Color c2 = gdi.Color.FromArgb(0, c1.R, c1.G, c1.B); gdi.SolidBrush b = new gdi.SolidBrush(c1); gdi.Graphics g = gdi.Graphics.FromImage(bmp); g.Clear(c2); g.DrawString(str, ft, b, new PointF(0, 0)); int tex = GLRenderer.Util.LoadTexture(bmp); Opengl32.glEnable(GLConsts.GL_TEXTURE_2D); Opengl32.glBindTexture(GLConsts.GL_TEXTURE_2D, tex); rect = new RectangleF(rect.X, rect.Y, s.Width / quality, s.Height / quality); GL.Color(1, 1, 1, 1); GL.Begin(PrimitiveType.QUADS); GL.TexCoord(0, 0); GL.Vertex2(rect.Left, rect.Top); GL.TexCoord(1, 0); GL.Vertex2(rect.Right, rect.Top); GL.TexCoord(1, 1); GL.Vertex2(rect.Right, rect.Bottom); GL.TexCoord(0, 1); GL.Vertex2(rect.Left, rect.Bottom); GL.End(); Opengl32.glDisable(GLConsts.GL_TEXTURE_2D); Opengl32.glDeleteTextures(1, ref tex); b.Dispose(); bmp.Dispose(); dummy.Dispose(); }
public override void FillPolygon(PBrush b, PointF[] pts) { if (pts.Length == 0) { return; } using (Brush brush = GetBrush(b)) { PathGeometry geo = new PathGeometry(factory); var sink = geo.Open(); sink.BeginFigure(pts[0].ToVector(), FigureBegin.Filled); for (int i = 0; i < pts.Length; i++) { sink.AddLine(pts[i].ToVector()); } sink.EndFigure(FigureEnd.Closed); sink.Close(); renderTarget.FillGeometry(geo, brush); sink.Dispose(); geo.Dispose(); } }
public void RenderTransformed(BaseRenderer r) { if (r is GPURenderer) { GPURenderer gr = (GPURenderer)r; Matrix3x3 mat = gr.GetCurrentTransform(); gr.ResetTransform(); gr.Transform(this.Transformation * mat); this.Render(r); gr.ResetTransform(); gr.Transform(mat); } else { } r.BeginCircles(PBrush.CreateSolid(System.Drawing.Color.Lime)); foreach (var point in Points) { r.Circle(point.X, point.Y, 4); } r.EndCircle(); }
public override void Draw(GPURenderer renderer, int width, int height) { Matrix3x3 rotate = Matrix3x3.Rotate(angle); renderer.Transform(rotate); renderer.Transform(Transformation); PBrush bgrColor = PBrush.CreateSolid(Color.FromArgb(100, 200, 200, 200)); PBrush fgrColor = PBrush.CreateSolid(Color.Black); PBrush fntColor = PBrush.CreateSolid(Color.Tomato); RectangleF rect1 = new RectangleF(-ballRad, -ballRad, ballRad * 2, ballRad * 2); RectangleF rect2 = rect1; rect2.X += rad; renderer.FillEllipse(bgrColor, rect1); renderer.FillEllipse(bgrColor, rect2); renderer.DrawEllipse(fgrColor, 2, rect1); renderer.DrawEllipse(fgrColor, 2, rect2); renderer.DrawLine(Color.Black, 2, new PointF(ballRad, 0), new PointF(rad - ballRad, 0)); renderer.DrawLine(Color.Tomato, 1, new PointF(-ballRad, 0), new PointF(ballRad, 0)); renderer.DrawLine(Color.Tomato, 1, new PointF(0, -ballRad), new PointF(0, ballRad)); renderer.DrawLine(Color.Tomato, 1, new PointF(-ballRad + rad, 0), new PointF(ballRad + rad, 0)); renderer.DrawLine(Color.Tomato, 1, new PointF(rad, -ballRad), new PointF(rad, ballRad)); float pageScale = parent.GetTransform().GetScale(); float pageRot = parent.GetTransform().GetRotation(); string strRad = "" + Math.Round(Util.PointToMm(rad / pageScale) * 100.0) / 100.0; string strDeg = "" + Math.Round((pageRot - angle) * 18000.0 / Math.PI) / 100.0; renderer.DrawText($"{strRad}mm\n{strDeg}°", fntColor, new RectangleF(Util.PointToMm(ballRad), Util.PointToMm(-ballRad), 500, 50), 10); renderer.ResetTransform(); }
XBrush createBrush(PBrush pBrush) { XBrush brush = new XSolidBrush(pBrush.GetMainColor()); return(brush); }
public override void FillPolygon(PBrush b, PointF[] pts) { g.DrawPolygon(createBrush(b), pts, XFillMode.Alternate); }
public override void DrawEllipse(PBrush c, float width, RectangleF rect) { g.DrawEllipse(new Pen(c.Brush, width), rect); }
public override void FillEllipse(PBrush c, RectangleF rect) { g.DrawEllipse(createBrush(c), rect); }
public override void BeginRects(PBrush brush) { cBrush = new XSolidBrush(brush.GetColor()); }
public ImageObject() { Brush = PBrush.CreateSolid(Color.White); }
public override void BeginRects(PBrush brush) { circleBrush = GetBrush(brush); }
public Brush GetBrush(PBrush pBrush) { return(new SolidColorBrush(renderTarget, pBrush.GetColor().ToColor4())); }