private void makeSine(int xorig, int yorig, float startX, float startY, int xseg, int yseg, long ampl, long freq, bool nl = false) { float y = startY, y2 = startY, x2 = lastx; for (float x = xorig; x < pb.Width / xseg + xorig; x += 50F) { if (nl) { y = yorig; y2 = y; x2 = xorig; nl = false; } else { y = (float)Math.Sin(x * freq / 1000) * ampl + yorig; } svg_graphics.DrawLine(pen, x, y, x2, y2); graphics.DrawLine(pen, x, y, x2, y2); x2 = x; y2 = y; lastx = x2; lasty = y2; } }
public override void DrawLine(IPen pen, float x1, float y1, float x2, float y2) { Pen sdPen = ((PenHandler)pen).Handle; fCanvas.DrawLine(sdPen, x1, y1, x2, y2); if (fSVGGfx != null) { fSVGGfx.SetColor(pen.Color); fSVGGfx.DrawLine(x1, y1, x2, y2, pen.Width); } }
public void Test_SvgGraphics() { using (MemoryStream stm = new MemoryStream()) { var svg = new SvgGraphics(stm, ExtRectF.CreateBounds(0, 0, 100, 100)); svg.BeginDrawing(); svg.Clear(UIHelper.ConvertColor(Color.Yellow)); svg.BeginEntity(null); svg.DrawLine(10, 10, 50, 10, 1); svg.DrawArc(60, 60, 20, 15, 25, 1); svg.DrawEllipse(10, 10, 30, 30, null, null); svg.DrawRect(50, 50, 20, 20, 2); svg.DrawRoundedRect(80, 80, 10, 10, 3, 1); svg.EndEntity(); svg.FillArc(60, 60, 20, 15, 25); svg.DrawEllipse(10, 10, 30, 30, null, null); svg.FillRect(50, 50, 20, 20); svg.SetColor(UIHelper.ConvertColor(Color.Red)); svg.FillRoundedRect(80, 80, 10, 10, 3); svg.DrawCircleSegment(0, 0, 10, 20, 0, 17, null, null); svg.DrawImage(null, 0, 0, 100, 100); svg.DrawPolygon(new ExtPointF[] {}, null, null); svg.DrawString("x", 10, 10); svg.ResetState(); svg.SaveState(); svg.RestoreState(); svg.Rotate(75); svg.Translate(10, 10); svg.Scale(0.5f, 0.5f); svg.SetClippingRect(0.0f, 0.0f, 10f, 10f); svg.SetFont(null); Assert.Throws(typeof(ArgumentNullException), () => { svg.SetColor(null); }); svg.BeginLines(false); svg.EndLines(); svg.EndDrawing(); } }