override public Task Rebuild() { this.DebugDepth("Rebuild"); bool valuesChanged = false; using (RebuildLock()) { Sides = agg_basics.Clamp(Sides, 3, 360, ref valuesChanged); Height = Math.Max(Height, .001); Diameter = Math.Max(Diameter, .1); using (new CenterAndHeightMantainer(this)) { if (!Advanced) { var path = new VertexStorage(); path.MoveTo(0, -Height / 2); path.LineTo(Diameter / 2, -Height / 2); path.LineTo(Diameter / 2, Height / 2); path.LineTo(0, Height / 2); Mesh = VertexSourceToMesh.Revolve(path, Sides); } else { var path = new VertexStorage(); path.MoveTo(0, -Height / 2); path.LineTo(Diameter / 2, -Height / 2); path.LineTo(DiameterTop / 2, Height / 2); path.LineTo(0, Height / 2); Mesh = VertexSourceToMesh.Revolve(path, Sides, MathHelper.DegreesToRadians(StartingAngle), MathHelper.DegreesToRadians(EndingAngle)); } } } if (valuesChanged) { Invalidate(InvalidateType.DisplayValues); } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }
private void RenderProbingPath(Graphics2D graphics2D) { var firstPosition = probePoints.First(); var path = new VertexStorage(); path.MoveTo(firstPosition.X, firstPosition.Y); foreach (var position in probePoints) { var center = new Vector2(position.X, position.Y); path.LineTo(center); } // Render total path before probe points graphics2D.Render( new Stroke(path), theme.AccentMimimalOverlay); }
public static VertexStorage Offset(this IVertexSource a, double distance) { List <List <IntPoint> > aPolys = a.CreatePolygons(); ClipperOffset offseter = new ClipperOffset(); offseter.AddPaths(aPolys, JoinType.jtMiter, EndType.etClosedPolygon); var solution = new List <List <IntPoint> >(); offseter.Execute(ref solution, distance * 1000); Clipper.CleanPolygons(solution); VertexStorage output = solution.CreateVertexStorage(); output.Add(0, 0, ShapePath.FlagsAndCommand.Stop); return(output); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); bool valuesChanged = false; using (RebuildLock()) { InnerDiameter = agg_basics.Clamp(InnerDiameter, 0, OuterDiameter - .1, ref valuesChanged); Sides = agg_basics.Clamp(Sides, 3, 360, ref valuesChanged); using (new CenterAndHeightMaintainer(this)) { var startingAngle = StartingAngle; var endingAngle = EndingAngle; if (!Advanced) { startingAngle = 0; endingAngle = 360; } var innerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter); var path = new VertexStorage(); path.MoveTo(OuterDiameter / 2, -Height / 2); path.LineTo(OuterDiameter / 2, Height / 2); path.LineTo(innerDiameter / 2, Height / 2); path.LineTo(innerDiameter / 2, -Height / 2); path.LineTo(OuterDiameter / 2, -Height / 2); var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle)); var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle)); Mesh = VertexSourceToMesh.Revolve(path, Sides, startAngle, endAngle); } } if (valuesChanged) { Invalidate(InvalidateType.DisplayValues); } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); bool valuesChanged = false; using (RebuildLock()) { var latitudeSides = LatitudeSides.ClampIfNotCalculated(this, 3, 180, ref valuesChanged); var longitudeSides = LongitudeSides.ClampIfNotCalculated(this, 3, 360, ref valuesChanged); var diameter = Diameter.Value(this); using (new CenterAndHeightMaintainer(this)) { if (longitudeSides != lastLongitudeSides || latitudeSides != lastLatitudeSides || diameter != lastDiameter) { var radius = diameter / 2; var angleDelta = MathHelper.Tau / 4 / latitudeSides; var angle = 0.0; var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); for (int i = 0; i < latitudeSides; i++) { angle += angleDelta; path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); } Mesh = VertexSourceToMesh.Revolve(path, longitudeSides); } lastDiameter = diameter; lastLongitudeSides = longitudeSides; lastLatitudeSides = latitudeSides; } } Invalidate(InvalidateType.DisplayValues); Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); bool valuesChanged = false; RoundSegments = agg_basics.Clamp(RoundSegments, 3, 360 / 4 - 2, ref valuesChanged); if (valuesChanged) { Invalidate(InvalidateType.DisplayValues); } using (RebuildLock()) { using (new CenterAndHeightMaintainer(this)) { var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(Width, 0); if (Round) { var range = 360 / 4.0; for (int i = 1; i < RoundSegments - 1; i++) { var angle = range / (RoundSegments - 1) * i; var rad = MathHelper.DegreesToRadians(angle); path.LineTo(Width - Math.Sin(rad) * Width, Height - Math.Cos(rad) * Height); } } path.LineTo(0, Height); Mesh = VertexSourceToMesh.Extrude(path, Depth); Mesh.Transform(Matrix4X4.CreateRotationX(MathHelper.Tau / 4)); } } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); using (RebuildLock()) { double pointsToMm = 0.352778; var printer = new TypeFacePrinter(Text.Value(this), new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize.Value(this))) { ResolutionScale = 10 }; var scaledLetterPrinter = new VertexSourceApplyTransform(printer, Affine.NewScaling(pointsToMm)); var vertexSource = new VertexStorage(); foreach (var vertex in scaledLetterPrinter.Vertices()) { if (vertex.IsMoveTo) { vertexSource.MoveTo(vertex.position); } else if (vertex.IsLineTo) { vertexSource.LineTo(vertex.position); } else if (vertex.IsClose) { vertexSource.ClosePolygon(); } } vertexSource = (VertexStorage)vertexSource.Union(vertexSource); this.VertexSource = vertexSource; // set the mesh to show the path this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); return(Task.CompletedTask); }
private VertexStorage CombinePaths(IVertexSource a, IVertexSource b, ClipType clipType) { List <List <IntPoint> > aPolys = VertexSourceToClipperPolygons.CreatePolygons(a); List <List <IntPoint> > bPolys = VertexSourceToClipperPolygons.CreatePolygons(b); Clipper clipper = new Clipper(); clipper.AddPaths(aPolys, PolyType.ptSubject, true); clipper.AddPaths(bPolys, PolyType.ptClip, true); List <List <IntPoint> > intersectedPolys = new List <List <IntPoint> >(); clipper.Execute(clipType, intersectedPolys); VertexStorage output = VertexSourceToClipperPolygons.CreateVertexStorage(intersectedPolys); output.Add(0, 0, ShapePath.FlagsAndCommand.Stop); return(output); }
public static void DrawTo(Graphics2D graphics2D, Mesh mesh, Matrix4X4 matrix, Vector2 offset, double scale, Color silhouetteColor) { graphics2D.Rasterizer.gamma(new gamma_power(.3)); VertexStorage polygonProjected = new VertexStorage(); for (int i = 0; i < mesh.Faces.Count; i++) { var face = mesh.Faces[i]; if (mesh.Faces[i].normal.TransformNormal(matrix).Z > 0) { polygonProjected.remove_all(); polygonProjected.MoveTo((new Vector2(mesh.Vertices[face.v0].Transform(matrix)) + offset) * scale); polygonProjected.LineTo((new Vector2(mesh.Vertices[face.v1].Transform(matrix)) + offset) * scale); polygonProjected.LineTo((new Vector2(mesh.Vertices[face.v2].Transform(matrix)) + offset) * scale); } graphics2D.Render(polygonProjected, silhouetteColor); } graphics2D.Rasterizer.gamma(new gamma_none()); }
void VertexAnimation_Completed(object sender, EventArgs e) { if (sender is ClockGroup) { return; } var control = (IGraphControl)Storyboard.GetTarget((sender as AnimationClock).Timeline); if (!VertexStorage.ContainsKey(control)) { return; //just in case of... who knows what? } control.SetPosition(VertexStorage[control], false); VertexStorage.Remove(control); var story = CreateStory(control, 0, 1, null); story.Completed += story_Completed; story.Begin(control as Control, HandoffBehavior.Compose); }
override public Task Rebuild() { this.DebugDepth("Rebuild"); using (RebuildLock()) { using (new CenterAndHeightMantainer(this)) { var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(Width, 0); path.LineTo(Width / 2, Height); var mesh = VertexSourceToMesh.Extrude(path, Depth); mesh.Transform(Matrix4X4.CreateRotationX(MathHelper.Tau / 4)); Mesh = mesh; } } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); using (RebuildLock()) { using (new CenterAndHeightMaintainer(this)) { var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(Math.Sqrt(2), 0); path.LineTo(0, Height); var mesh = VertexSourceToMesh.Revolve(path, 4); mesh.Transform(Matrix4X4.CreateRotationZ(MathHelper.DegreesToRadians(45)) * Matrix4X4.CreateScale(Width / 2, Depth / 2, 1)); Mesh = mesh; } } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }
public static VertexStorage Offset(this IVertexSource a, double distance, JoinType joinType = JoinType.jtMiter, double scale = 1000) { var aPolys = a.CreatePolygons(scale); aPolys = aPolys.GetCorrectedWinding(); var offseter = new ClipperOffset(); offseter.AddPaths(aPolys, joinType, EndType.etClosedPolygon); var solution = new Polygons(); offseter.Execute(ref solution, distance * scale); Clipper.CleanPolygons(solution); VertexStorage output = solution.CreateVertexStorage(); output.Add(0, 0, ShapePath.FlagsAndCommand.Stop); return(output); }
private void make_arrows(VertexStorage ps) { ps.remove_all(); ps.MoveTo(1330.599999999999909, 1282.399999999999864); ps.LineTo(1377.400000000000091, 1282.399999999999864); ps.LineTo(1361.799999999999955, 1298.000000000000000); ps.LineTo(1393.000000000000000, 1313.599999999999909); ps.LineTo(1361.799999999999955, 1344.799999999999955); ps.LineTo(1346.200000000000045, 1313.599999999999909); ps.LineTo(1330.599999999999909, 1329.200000000000045); ps.ClosePolygon(); ps.MoveTo(1330.599999999999909, 1266.799999999999955); ps.LineTo(1377.400000000000091, 1266.799999999999955); ps.LineTo(1361.799999999999955, 1251.200000000000045); ps.LineTo(1393.000000000000000, 1235.599999999999909); ps.LineTo(1361.799999999999955, 1204.399999999999864); ps.LineTo(1346.200000000000045, 1235.599999999999909); ps.LineTo(1330.599999999999909, 1220.000000000000000); ps.ClosePolygon(); ps.MoveTo(1315.000000000000000, 1282.399999999999864); ps.LineTo(1315.000000000000000, 1329.200000000000045); ps.LineTo(1299.400000000000091, 1313.599999999999909); ps.LineTo(1283.799999999999955, 1344.799999999999955); ps.LineTo(1252.599999999999909, 1313.599999999999909); ps.LineTo(1283.799999999999955, 1298.000000000000000); ps.LineTo(1268.200000000000045, 1282.399999999999864); ps.ClosePolygon(); ps.MoveTo(1268.200000000000045, 1266.799999999999955); ps.LineTo(1315.000000000000000, 1266.799999999999955); ps.LineTo(1315.000000000000000, 1220.000000000000000); ps.LineTo(1299.400000000000091, 1235.599999999999909); ps.LineTo(1283.799999999999955, 1204.399999999999864); ps.LineTo(1252.599999999999909, 1235.599999999999909); ps.LineTo(1283.799999999999955, 1251.200000000000045); ps.ClosePolygon(); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { var aabb = this.GetAxisAlignedBoundingBox(); var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(Diameter / 2, 0); path.LineTo(0, Height); Mesh = VertexSourceToMesh.Revolve(path, Sides); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); }
public static VertexStorage MergePaths(this IVertexSource a, IVertexSource b, ClipType clipType) { List <List <IntPoint> > aPolys = a.CreatePolygons(); List <List <IntPoint> > bPolys = b.CreatePolygons(); var clipper = new Clipper(); clipper.AddPaths(aPolys, PolyType.ptSubject, true); clipper.AddPaths(bPolys, PolyType.ptClip, true); var outputPolys = new List <List <IntPoint> >(); clipper.Execute(clipType, outputPolys); Clipper.CleanPolygons(outputPolys); VertexStorage output = outputPolys.CreateVertexStorage(); output.Add(0, 0, ShapePath.FlagsAndCommand.Stop); return(output); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); bool changed = false; using (RebuildLock()) { Sides = agg_basics.Clamp(Sides, 3, 360, ref changed); using (new CenterAndHeightMaintainer(this)) { var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(Diameter / 2, 0); path.LineTo(0, Height); Mesh = VertexSourceToMesh.Revolve(path, Sides); } } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return(Task.CompletedTask); }
public override void OnBoundsChanged(EventArgs e) { base.OnBoundsChanged(e); var rect = this.LocalBounds; var centerY = rect.YCenter; // Tab - core var radius = 3.0; var tabShape2 = new VertexStorage(); tabShape2.MoveTo(rect.Left + radius, rect.Bottom); tabShape2.curve3(rect.Left, rect.Bottom, rect.Left, rect.Bottom + radius); tabShape2.LineTo(rect.Left, rect.Top - radius); tabShape2.curve3(rect.Left, rect.Top, rect.Left + radius, rect.Top); tabShape2.LineTo(rect.Right - 8, rect.Top); tabShape2.LineTo(rect.Right, centerY); tabShape2.LineTo(rect.Right - 8, rect.Bottom); tabShape2.LineTo(rect.Left, rect.Bottom); tabShape = new FlattenCurves(tabShape2); }
public DropDownList(string noSelectionString, Color textColor, Direction direction = Direction.Down, double maxHeight = 0, bool useLeftIcons = false, double pointSize = 12) : base(direction, maxHeight) { this.pointSize = pointSize; UseLeftIcons = useLeftIcons; // Always Down, unless Up directionArrow = (this.MenuDirection == Direction.Up) ? DropArrow.UpArrow : DropArrow.DownArrow; MenuItems.CollectionChanged += MenuItems_CollectionChanged; this.noSelectionString = noSelectionString; mainControlText = new TextWidget(noSelectionString, pointSize: pointSize, textColor: textColor) { AutoExpandBoundsToText = true, VAnchor = VAnchor.Bottom | VAnchor.Fit, HAnchor = HAnchor.Left | HAnchor.Fit, Margin = new BorderDouble(10, 7, 7, 7), }; AddChild(mainControlText); NormalColor = whiteTransparent; var borderColor = new Color(textColor, 40); this.MenuItemsBorderWidth = 1; this.MenuItemsBackgroundColor = Color.White; this.MenuItemsBorderColor = borderColor; this.MenuItemsPadding = new BorderDouble(10, 7, 7, 7); this.MenuItemsBackgroundHoverColor = new Color("#EC6788FF"); this.MenuItemsTextHoverColor = Color.Black; this.MenuItemsTextColor = Color.Black; this.HoverColor = whiteSemiTransparent; this.BackgroundColor = new Color(255, 255, 255, 0); this.Border = 1; this.BorderColor = borderColor; }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); bool changed = false; using (RebuildLock()) { LatitudeSides = agg_basics.Clamp(LatitudeSides, 3, 180, ref changed); LongitudeSides = agg_basics.Clamp(LongitudeSides, 3, 360, ref changed); var aabb = this.GetAxisAlignedBoundingBox(); var radius = Diameter / 2; var angleDelta = MathHelper.Tau / 4 / LatitudeSides; var angle = 0.0; var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); for (int i = 0; i < LatitudeSides; i++) { angle += angleDelta; path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); } Mesh = VertexSourceToMesh.Revolve(path, LongitudeSides); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); if (changed) { base.OnInvalidate(new InvalidateArgs(this, InvalidateType.Properties)); } }
override public Task Rebuild() { this.DebugDepth("Rebuild"); using (RebuildLock()) { double pointsToMm = 0.352778; var printer = new TypeFacePrinter(Text, new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize)) { ResolutionScale = 10 }; var scaledLetterPrinter = new VertexSourceApplyTransform(printer, Affine.NewScaling(pointsToMm)); var vertexSource = new VertexStorage(); foreach (var vertex in scaledLetterPrinter.Vertices()) { if (vertex.IsMoveTo) { vertexSource.MoveTo(vertex.position); } else if (vertex.IsLineTo) { vertexSource.LineTo(vertex.position); } else if (vertex.IsClose) { vertexSource.ClosePolygon(); } } this.VertexSource = vertexSource; base.Mesh = null; } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); return(Task.CompletedTask); }
private void InsetPath() { var path = this.Children.OfType <IPathObject>().FirstOrDefault(); if (path == null) { // clear our existing data VertexSource = new VertexStorage(); return; } var aPolys = path.VertexSource.CreatePolygons(); var offseter = new ClipperOffset(); var outlineWidth = OutlineWidth.Value(this); var ratio = Ratio.Value(this); offseter.AddPaths(aPolys, InflatePathObject3D.GetJoinType(OuterStyle), EndType.etClosedPolygon); var outerLoops = new List <List <IntPoint> >(); offseter.Execute(ref outerLoops, outlineWidth * ratio * 1000); Clipper.CleanPolygons(outerLoops); offseter.AddPaths(aPolys, InflatePathObject3D.GetJoinType(InnerStyle), EndType.etClosedPolygon); var innerLoops = new List <List <IntPoint> >(); offseter.Execute(ref innerLoops, -outlineWidth * (1 - ratio) * 1000); Clipper.CleanPolygons(innerLoops); var allLoops = outerLoops; allLoops.AddRange(innerLoops); VertexSource = allLoops.CreateVertexStorage(); (VertexSource as VertexStorage).Add(0, 0, ShapePath.FlagsAndCommand.Stop); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { var aabb = this.GetAxisAlignedBoundingBox(); var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(Width, 0); path.LineTo(0, Height); Mesh = VertexSourceToMesh.Extrude(path, Depth); Mesh.Transform(Matrix4X4.CreateRotationX(MathHelper.Tau / 4)); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); }
public static Mesh CreateSphere(double diameter = 1, int sides = 30, int latitudeSides = 30, double startingAngleDeg = 0, double endingAngleDeg = 360) { var path = new VertexStorage(); var angleDelta = MathHelper.Tau / 2 / latitudeSides; var angle = -MathHelper.Tau / 4; var radius = diameter / 2; path.MoveTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); for (int i = 0; i < latitudeSides; i++) { angle += angleDelta; path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); } var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngleDeg)); var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngleDeg)); var steps = Math.Max(1, (int)(sides * MathHelper.Tau / Math.Abs(MathHelper.GetDeltaAngle(startAngle, endAngle)) + .5)); return(VertexSourceToMesh.Revolve(path, steps, startAngle, endAngle)); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { var aabb = this.GetAxisAlignedBoundingBox(); var startingAngle = StartingAngle; var endingAngle = EndingAngle; if (!Advanced) { startingAngle = 0; endingAngle = 360; } var innerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter); var path = new VertexStorage(); path.MoveTo(OuterDiameter / 2, -Height / 2); path.LineTo(OuterDiameter / 2, Height / 2); path.LineTo(innerDiameter / 2, Height / 2); path.LineTo(innerDiameter / 2, -Height / 2); path.LineTo(OuterDiameter / 2, -Height / 2); var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle)); var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle)); Mesh = VertexSourceToMesh.Revolve(path, Sides, startAngle, endAngle); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); }
internal IVertexSource GetGlyphForCharacter(char character) { if (_ofTypeface != null) { // TODO: MAKE SURE THIS IS OFF!!!!!!! It is un-needed and only for debugging //glyphs.Clear(); } // TODO: check for multi character glyphs (we don't currently support them in the reader). Glyph glyph = null; if (!glyphs.TryGetValue(character, out glyph)) { // if we have a loaded ttf try to create the glyph data if (_ofTypeface != null) { var storage = new VertexStorage(); var translator = new VertexSourceGlyphTranslator(storage); var glyphIndex = _ofTypeface.LookupIndex(character); var ttfGlyph = _ofTypeface.GetGlyphByIndex(glyphIndex); // Typography.OpenFont.IGlyphReaderExtensions.Read(translator, ttfGlyph.GlyphPoints, ttfGlyph.EndPoints); // glyph = new Glyph(); glyph.unicode = character; glyph.horiz_adv_x = _ofTypeface.GetHAdvanceWidthFromGlyphIndex(glyphIndex); glyphs.Add(character, glyph); // Wrap glyph data with ClosedLoopGlyphData to ensure all loops are correctly closed glyph.glyphData = new ClosedLoopGlyphData(storage); } } return(glyph?.glyphData); }
public override Task Rebuild() { this.DebugDepth("Rebuild"); bool changed = false; using (RebuildLock()) { var sides = Sides.ClampIfNotCalculated(this, 3, 360, ref changed); var diameter = Diameter.ClampIfNotCalculated(this, .01, 1000000, ref changed); var height = Height.ClampIfNotCalculated(this, .01, 1000000, ref changed); using (new CenterAndHeightMaintainer(this)) { var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(diameter / 2, 0); path.LineTo(0, height); Mesh = VertexSourceToMesh.Revolve(path, sides); } } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); return(Task.CompletedTask); }
public static VertexStorage CreateVertexStorage(this List <List <IntPoint> > polygons, double scaling = 1000) { VertexStorage output = new VertexStorage(); foreach (List <IntPoint> polygon in polygons) { bool first = true; foreach (IntPoint point in polygon) { if (first) { output.Add(point.X / scaling, point.Y / scaling, ShapePath.FlagsAndCommand.MoveTo); first = false; } else { output.Add(point.X / scaling, point.Y / scaling, ShapePath.FlagsAndCommand.LineTo); } } output.ClosePolygon(); } return(output); }
override public Task Rebuild() { this.DebugDepth("Rebuild"); bool valuesChanged = false; using (RebuildLock()) { LatitudeSides = agg_basics.Clamp(LatitudeSides, 3, 180, ref valuesChanged); LongitudeSides = agg_basics.Clamp(LongitudeSides, 3, 360, ref valuesChanged); using (new CenterAndHeightMantainer(this)) { var radius = Diameter / 2; var angleDelta = MathHelper.Tau / 4 / LatitudeSides; var angle = 0.0; var path = new VertexStorage(); path.MoveTo(0, 0); path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); for (int i = 0; i < LatitudeSides; i++) { angle += angleDelta; path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); } Mesh = VertexSourceToMesh.Revolve(path, LongitudeSides); } } if (valuesChanged) { Invalidate(InvalidateType.DisplayValues); } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); return(Task.CompletedTask); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); bool changed = false; using (RebuildLock()) { Sides = agg_basics.Clamp(Sides, 3, 180, ref changed); var aabb = this.GetAxisAlignedBoundingBox(); var path = new VertexStorage(); path.MoveTo(Width / 2, 0); for (int i = 1; i < Sides; i++) { var angle = MathHelper.Tau * i / 2 / (Sides - 1); path.LineTo(Math.Cos(angle) * Width / 2, Math.Sin(angle) * Width / 2); } var mesh = VertexSourceToMesh.Extrude(path, Depth); mesh.Transform(Matrix4X4.CreateRotationX(MathHelper.Tau / 4)); Mesh = mesh; if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); if (changed) { base.OnInvalidate(new InvalidateArgs(this, InvalidateType.Properties)); } }
public PathStorage(string svgDString) { vertices = new VertexStorage(); ParseSvgDString(svgDString); }
public PathStorage() { vertices = new VertexStorage(); }
public void ShareVertexData(PathStorage pathStorageToShareFrom) { vertices = pathStorageToShareFrom.vertices; }