public void RenderPathOutlineTest() { GdiVectorRenderer renderer = new GdiVectorRenderer(); Point2D[] points = new Point2D[] {new Point2D(1, 0), new Point2D(0, 1), new Point2D(-1, 0), new Point2D(0, -1)}; Path2D path = new Path2D(points, true); StylePen outline = new StylePen(new SolidStyleBrush(StyleColor.Blue), 1); StylePen highlight = new StylePen(new SolidStyleBrush(StyleColor.Red), 1); StylePen selected = new StylePen(new SolidStyleBrush(StyleColor.Green), 1); IEnumerable<GdiRenderObject> renderObjects = renderer.RenderPaths( new Path2D[] {path}, outline, highlight, selected, RenderState.Normal); IEnumerator<GdiRenderObject> enumertor = renderObjects.GetEnumerator(); enumertor.MoveNext(); GdiRenderObject ro = enumertor.Current; Assert.AreEqual(RenderState.Normal, ro.State); Assert.IsInstanceOfType(typeof (SolidBrush), ro.Fill); Assert.IsNotNull(ro.GdiPath); Assert.AreEqual(4, ro.GdiPath.PointCount); Assert.AreEqual(new RectangleF(-1, -1, 2, 2), ro.GdiPath.GetBounds()); PathData data = ro.GdiPath.PathData; for (Int32 i = 0; i < 4; i++) { Assert.AreEqual(points[i].X, data.Points[i].X, _e); Assert.AreEqual(points[i].Y, data.Points[i].Y, _e); } Assert.AreEqual(0, data.Types[0]); Assert.AreEqual(1, data.Types[1]); Assert.AreEqual(1, data.Types[2]); Assert.AreEqual(129, data.Types[3]); Pen expectedOutline = new Pen(Brushes.Blue, 1.0f); Pen expectedHighlight = new Pen(Brushes.Red, 1.0f); Pen expectedSelected = new Pen(Brushes.Green, 1.0f); Assert.IsTrue(pensAreEqual(expectedOutline, ro.Outline)); Assert.IsTrue(pensAreEqual(expectedHighlight, ro.HighlightOutline)); Assert.IsTrue(pensAreEqual(expectedSelected, ro.SelectOutline)); expectedOutline.Dispose(); expectedHighlight.Dispose(); expectedSelected.Dispose(); renderer.Dispose(); }
public void AddFiguresTest() { Point2D[] points = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Path2D p1 = new Path2D(); p1.NewFigure(points, false); Assert.Equal(1, p1.Figures.Count); Assert.NotNull(p1.CurrentFigure); Assert.Equal(4, p1.CurrentFigure.Points.Count); Assert.False(p1.CurrentFigure.IsClosed); Assert.Equal(p1.Bounds, p1.CurrentFigure.Bounds); Assert.Equal(p1.Bounds, new Rectangle2D(0, 0, 1, 1)); }
public void CurrentFigureTest1() { Point2D[] points = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Figure2D f1 = new Figure2D(points, true); Path2D p1 = new Path2D(f1); f1 = p1.CurrentFigure as Figure2D; Assert.Equal(4, p1.Points.Count); p1.NewFigure(points, false); Assert.Same(p1.CurrentFigure, p1.Figures[1]); p1.CurrentFigure = f1; Assert.Same(p1.CurrentFigure, f1); Path2D p2 = new Path2D(); Assert.Null(p2.CurrentFigure); Assert.Equal(0, p2.Points.Count); }
public void CreateNewTest() { Path2D p1 = new Path2D(); Assert.Equal(0, p1.Figures.Count); Point2D[] points = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Path2D p2 = new Path2D(points); Assert.Equal(1, p2.Figures.Count); Assert.Equal(4, p2.CurrentFigure.Points.Count); Assert.False(p2.CurrentFigure.IsClosed); Path2D p3 = new Path2D(points, true); Assert.True(p3.CurrentFigure.IsClosed); Figure2D figure = new Figure2D(points, true); Path2D p4 = new Path2D(new Figure2D[] {figure}); Assert.Equal(1, p4.Figures.Count); Path2D p5 = new Path2D(new Figure2D[] {}); Assert.Null(p5.CurrentFigure); Assert.Equal(0, p5.Points.Count); }
/// <summary> /// Creates a new GdiRenderObject instance. /// </summary> /// <param name="text">The text to draw.</param> /// <param name="font">The font to use to render the text.</param> /// <param name="bounds">The location and size to draw the text.</param> /// <param name="fill"> /// The brush used to fill the path when the state is <see cref="RenderState.Normal"/>. /// </param> /// <param name="highlightFill"> /// The brush used to fill the path when the state is <see cref="RenderState.Highlighted"/>. /// </param> /// <param name="selectFill"> /// The brush used to fill the path when the state is <see cref="RenderState.Selected"/>. /// </param> /// <param name="outline"> /// The pen used to outline the path when the state is <see cref="RenderState.Normal"/>. /// </param> /// <param name="highlightOutline"> /// The pen used to outline the path when the state is <see cref="RenderState.Highlighted"/>. /// </param> /// <param name="selectOutline"> /// The pen used to outline the path when the state is <see cref="RenderState.Selected"/>. /// </param> public CairoRenderObject(String text, FontFace font, Rectangle bounds, StyleBrush fill, StyleBrush highlightFill, StyleBrush selectFill, StylePen outline, StylePen highlightOutline, StylePen selectOutline) { _state = RenderState.Normal; Path = null; Image = null; Bounds = new Rectangle(); AffineTransform = null; ColorTransform = null; Text = text; Font = font; Bounds = bounds; Fill = fill; HighlightFill = highlightFill; SelectFill = selectFill; Outline = outline; HighlightOutline = highlightOutline; SelectOutline = selectOutline; Line = null; HighlightLine = null; SelectLine = null; }
/// <summary> /// Creates a new GdiRenderObject instance. /// </summary> /// <param name="image">The symbol to draw.</param> /// <param name="imageBounds">The location and size to draw the symbol.</param> /// <param name="transform">The affine transform applied to the symbol before drawing.</param> /// <param name="colorTransform">The color transform applied to the symbol before drawing.</param> public CairoRenderObject(Surface image, Rectangle imageBounds, CairoMatrix transform, CairoMatrix colorTransform) { _state = RenderState.Normal; Image = image; Bounds = imageBounds; AffineTransform = transform; ColorTransform = colorTransform; Path = null; Fill = null; HighlightFill = null; SelectFill = null; Line = null; HighlightLine = null; SelectLine = null; Outline = null; HighlightOutline = null; SelectOutline = null; Text = null; Font = null; }
/// <summary> /// Creates a new CairoRenderObject instance. /// </summary> /// <param name="path">The path to draw.</param> /// <param name="fill"> /// The brush used to fill the path when the state is <see cref="RenderState.Normal"/>. /// </param> /// <param name="highlightFill"> /// The brush used to fill the path when the state is <see cref="RenderState.Highlighted"/>. /// </param> /// <param name="selectFill"> /// The brush used to fill the path when the state is <see cref="RenderState.Selected"/>. /// </param> /// <param name="line"> /// The pen used to draw a line when the state is <see cref="RenderState.Normal"/>. /// </param> /// <param name="highlightLine"> /// The pen used to draw a line when the state is <see cref="RenderState.Highlighted"/>. /// </param> /// <param name="selectLine"> /// The pen used to draw a line when the state is <see cref="RenderState.Selected"/>. /// </param> /// <param name="outline"> /// The pen used to outline the path when the state is <see cref="RenderState.Normal"/>. /// </param> /// <param name="highlightOutline"> /// The pen used to outline the path when the state is <see cref="RenderState.Highlighted"/>. /// </param> /// <param name="selectOutline"> /// The pen used to outline the path when the state is <see cref="RenderState.Selected"/>. /// </param> public CairoRenderObject(Path2D path, StyleBrush fill, StyleBrush highlightFill, StyleBrush selectFill, StylePen line, StylePen highlightLine, StylePen selectLine, StylePen outline, StylePen highlightOutline, StylePen selectOutline) { _state = RenderState.Normal; Path = path; Fill = fill; HighlightFill = highlightFill; SelectFill = selectFill; Line = line; HighlightLine = highlightLine; SelectLine = selectLine; Outline = outline; HighlightOutline = highlightOutline; SelectOutline = selectOutline; Image = null; Bounds = new Rectangle(); AffineTransform = new CairoMatrix(); ColorTransform = null; Text = null; Font = null; }
public void AddPath(Path2D path, SVGMatrix matrix) { }
/// <summary> /// Creates a new Path2D object from an specified Path2D object. /// </summary> public Path2D(Path2D path) { return; }
public void GetHashCodeTest() { Point2D[] points1 = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Path2D p1 = new Path2D(); Path2D p2 = new Path2D(); Path2D p3 = new Path2D(points1); Figure2D f1 = new Figure2D(points1, true); Path2D p4 = new Path2D(points1, true); Path2D p5 = new Path2D(f1); Assert.Equal(p1.GetHashCode(), p2.GetHashCode()); Assert.Equal(p4.GetHashCode(), p5.GetHashCode()); Assert.NotEqual(p1.GetHashCode(), p3.GetHashCode()); Assert.NotEqual(p3.GetHashCode(), p4.GetHashCode()); }
public void ToStringTest() { Point2D[] points1 = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Path2D p1 = new Path2D(points1); Rectangle2D bounds = new Rectangle2D(Point2D.Zero, Size2D.Unit); String expected = String.Format("[{0}] 1 figure of Point2D points; Bounds: {1}", typeof (Path2D), bounds); Assert.Equal(expected, p1.ToString()); }
public override IEnumerable <DependencyObject> RenderText(string text, StyleFont font, Rectangle2D layoutRectangle, Path2D flowPath, StyleBrush fontBrush, Matrix2D transform) { throw new NotImplementedException(); }
public static Path2D Convert(Path2D path) { return(path); }
///<exclude/> public bool Equals(Path2D other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other._Tm.Equals(_Tm) && other._Waypoints.SequenceEqual(_Waypoints); }
public void SetPath() { _pathFollow = (PathFollow2D)GetParent(); _path2D = (Path2D)_pathFollow.GetParent(); }
public override IEnumerable <Object> RenderText(String text, StyleFont font, Rectangle2D layoutRectangle, Path2D flowPath, StyleBrush fontBrush, Matrix2D transform) { throw new Exception("The method or operation is not implemented."); }
public override void _Ready() { _path = GetNode <Path2D>("Path2D"); }
public override void _Ready() { leftLever = GetNode <Sprite>("LeverLeft"); rightLever = GetNode <Sprite>("LeverRight"); mainPathLeft = GetNode <Path2D>("MainPathLeft"); mainPathRight = GetNode <Path2D>("MainPathRight"); leftTimer = GetNode <Timer>("LeftTimer"); rightTimer = GetNode <Timer>("RightTimer"); global = GetNode <Global>("/root/Global"); GD.Randomize(); if (global.colorsData.Count < 6) { global.colorsData.Clear(); global.AddData(global.colorsData); } if (global.unusedColorsData.Count <= 6) { global.unusedColorsData.Clear(); global.AddData(global.unusedColorsData); } if (global.spawnColorsData_Left.Count >= 0) { global.spawnColorsData_Left.Clear(); global.AddSpawnColorsData("Left"); } if (global.spawnColorsData_Right.Count >= 0) { global.spawnColorsData_Right.Clear(); global.AddSpawnColorsData("Right"); } if (global.midColors.Count >= 0) { global.midColors.Clear(); } int rand = (int)GD.RandRange(0, 10); if (rand < 4) { leftTimer.Start(); global.firstLeft = true; } else { rightTimer.Start(); global.firstLeft = false; } GD.Print("startover"); global.setCount = 1; global.StartWaveTimer(); }
public void CloneTest() { Point2D[] points1 = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Path2D p1 = new Path2D(points1, true); Path<Point2D, Rectangle2D> p2 = p1.Clone(); Assert.Equal(p1, p2); Path2D p3 = (p1 as ICloneable).Clone() as Path2D; Assert.Equal(p1, p3); p2.NewFigure(points1, false); Assert.NotEqual(p1, p2); }
public void EqualityTest() { Path2D p1 = new Path2D(); Path2D p2 = new Path2D(); Assert.True(p1.Equals(p2)); Point2D[] points1 = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Point2D[] points2 = new Point2D[] {new Point2D(0, 0), new Point2D(2, 0), new Point2D(2, 2), new Point2D(0, 2)}; Path2D p3 = new Path2D(points1); Path2D p4 = new Path2D(points1); Assert.True(p3.Equals(p4)); Path2D p5 = new Path2D(p3.CurrentFigure); Assert.True(p3.Equals(p5)); Path2D p6 = new Path2D(points1, true); Assert.False(p3.Equals(p6)); Figure2D f1 = new Figure2D(points1, false); Path2D p7 = new Path2D(new Figure2D[] {f1}); Assert.True(p3.Equals(p7)); Figure2D f2 = new Figure2D(points2, true); Path2D p8 = new Path2D(new Figure2D[] {f1, f2}); Assert.False(p3.Equals(p8)); p3.NewFigure(points2, true); Assert.True(p8.Equals(p3)); p8 = null; Assert.False(p3.Equals(p8)); Assert.False(p3.Equals(new Object())); }
/// <summary> /// This will be called when we're exporting /// </summary> /// <param name="scenename"></param> /// <param name="layer"></param> /// <param name="numslices"></param> /// <param name="bmp"></param> /// <param name="lstPoly"></param> private void LayerSliced(string scenename, int layer, int numslices, Bitmap bmp, List <PolyLine3d> lstintersections, bool outline = false) { string path = ""; try { // if (m_buildparms.exportimages) { // get the model name String modelname = scenename; String outlinename = ""; // strip off the file extension path = SliceFile.GetSliceFilePath(modelname); if (outline) { outlinename = "_outline"; } String imname = Path.GetFileNameWithoutExtension(modelname) + outlinename + String.Format("{0:0000}", layer) + ".bmp"; String imagename = path + UVDLPApp.m_pathsep + imname; // create a memory stream for this to save into bmp.Tag = BuildManager.SLICE_NORMAL; // mark it as normal MemoryStream ms = new MemoryStream(); bmp.Save(ms, ImageFormat.Bmp); ms.Seek(0, SeekOrigin.Begin); // seek back to beginning if (!m_cancel) // if we're not in the process of cancelling { SceneFile.Instance().AddSlice(UVDLPApp.Instance().SceneFileName, ms, imname); } if (m_sf.m_config.exportpng) { //imagename var img = (Image)bmp; img.Save(imagename, ImageFormat.Bmp); //bmp.Save(imagename); } if (lstintersections != null) { StreamWriter sw; imname = Path.GetFileNameWithoutExtension(modelname) + String.Format("{0:0000}", layer) + ".svg"; imagename = path + UVDLPApp.m_pathsep + imname; if (m_sf.m_config.exportsvg < 3) { Path2D vectorPath = new Path2D(lstintersections); sw = vectorPath.GenerateSVG(UVDLPApp.Instance().m_printerinfo.m_PlatXSize, UVDLPApp.Instance().m_printerinfo.m_PlatYSize, m_sf.m_config.exportsvg == 2); } else { Slice sl = new Slice(); sl.m_segments = lstintersections; sl.Optimize(); sw = GenerateSVG(sl.m_opsegs, m_sf.m_config.exportsvg == 4); } if (!m_cancel) { SceneFile.Instance().AddVectorSlice(UVDLPApp.Instance().SceneFileName, (MemoryStream)sw.BaseStream, imname); } } RaiseSliceEvent(eSliceEvent.eLayerSliced, layer, numslices); } } catch (Exception ex) { string s = ex.StackTrace; DebugLogger.Instance().LogError(ex.Message); } }
public void CurrentFigureTest2() { Point2D[] points = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Figure2D f1 = new Figure2D(points, true); Path2D p1 = new Path2D(); p1.NewFigure(points, false); Assert.Throws<InvalidOperationException>(delegate { p1.CurrentFigure = f1; }); }
public static Path2D Convert(Path2D path) { return path; }
public void EnumPointsTest() { Point2D[] points1 = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Path2D p1 = new Path2D(points1); Int32 i = 0; foreach (Figure2D figure in p1) { foreach (Point2D point in figure) { Assert.Equal(points1[i++], point); } } IEnumerator e1 = p1.GetEnumerator(); IEnumerator e2 = (p1 as IEnumerable).GetEnumerator(); Assert.True(e1.MoveNext()); Assert.True(e2.MoveNext()); Assert.True(e2.Current.Equals(e1.Current)); Assert.False(e1.MoveNext()); Assert.False(e2.MoveNext()); }
/// <summary> /// Overrides <see cref="CADability.Curve2D.GeneralCurve2D.Intersect (ICurve2D)"/> /// </summary> /// <param name="IntersectWith"></param> /// <returns></returns> public override GeoPoint2DWithParameter[] Intersect(ICurve2D IntersectWith) { // gesucht sind alle Schnittpunkte, also auch in der Verlängerung! Line2D l2d = IntersectWith as Line2D; if (l2d != null) { GeoPoint2D ip; if (Geometry.IntersectLL(startPoint, endPoint, l2d.StartPoint, l2d.EndPoint, out ip)) { double pos1 = this.PositionOf(ip); double pos2 = l2d.PositionOf(ip); GeoPoint2DWithParameter pwp = new GeoPoint2DWithParameter(); pwp.p = ip; pwp.par1 = pos1; pwp.par2 = pos2; return(new GeoPoint2DWithParameter[] { pwp }); } else { return(new GeoPoint2DWithParameter[0]); } } Circle2D c2d = IntersectWith as Circle2D; if (c2d != null) { GeoPoint2D[] isp = Geometry.IntersectLC(startPoint, endPoint, c2d.Center, c2d.Radius); GeoPoint2DWithParameter[] res = new GeoPoint2DWithParameter[isp.Length]; for (int i = 0; i < isp.Length; ++i) { res[i].p = isp[i]; res[i].par1 = this.PositionOf(isp[i]); res[i].par2 = c2d.PositionOf(isp[i]); } return(res); } Ellipse2D e2d = IntersectWith as Ellipse2D; if (e2d != null) { GeoPoint2D[] isp = Geometry.IntersectEL(e2d.center, e2d.majorAxis.Length, e2d.minorAxis.Length, e2d.majorAxis.Angle, startPoint, endPoint); GeoPoint2DWithParameter[] res = new GeoPoint2DWithParameter[isp.Length]; for (int i = 0; i < isp.Length; ++i) { res[i].p = isp[i]; res[i].par1 = this.PositionOf(isp[i]); res[i].par2 = e2d.PositionOf(isp[i]); } return(res); } Polyline2D p2d = IntersectWith as Polyline2D; if (p2d != null) { GeoPoint2DWithParameter[] res = p2d.Intersect(this); // sorum geht es for (int i = 0; i < res.Length; ++i) { double t = res[i].par1; res[i].par1 = res[i].par2; res[i].par2 = t; } return(res); } Path2D pa2d = IntersectWith as Path2D; if (pa2d != null) { GeoPoint2DWithParameter[] res = pa2d.Intersect(this); // sorum geht es for (int i = 0; i < res.Length; ++i) { double t = res[i].par1; res[i].par1 = res[i].par2; res[i].par2 = t; } return(res); } BSpline2D b2d = IntersectWith as BSpline2D; if (b2d != null) { GeoPoint2DWithParameter[] res = b2d.Intersect(this); // sorum geht es for (int i = 0; i < res.Length; ++i) { double t = res[i].par1; res[i].par1 = res[i].par2; res[i].par2 = t; } return(res); } return(base.Intersect(IntersectWith)); }
/// <summary> /// Adds a path to the current path. /// </summary> /// <param name="path"></param> /// <param name="transform"></param> public void AddPath(Path2D path, SVGMatrix transform = null) { return; }
public void BoundsTest() { Path2D p1 = new Path2D(); Assert.True(p1.Bounds == Rectangle2D.Empty); Point2D[] points1 = new Point2D[] {new Point2D(0, 0), new Point2D(1, 0), new Point2D(1, 1), new Point2D(0, 1)}; Point2D[] points2 = new Point2D[] {new Point2D(0, 0), new Point2D(10, 0), new Point2D(10, 1), new Point2D(0, 1)}; Point2D[] points3 = new Point2D[] {new Point2D(0, 0), new Point2D(-1, 0), new Point2D(-1, -1), new Point2D(0, -1)}; p1.NewFigure(points1, true); Assert.Equal(p1.Bounds, new Rectangle2D(0, 0, 1, 1)); p1.NewFigure(points2, true); Assert.Equal(p1.Bounds, new Rectangle2D(0, 0, 10, 1)); p1.NewFigure(points3, true); Assert.Equal(p1.Bounds, new Rectangle2D(-1, -1, 10, 1)); }