Article From:https://www.cnblogs.com/lonelyxmas/p/9688770.html
WPF heart-shaped algorithm

Today on the Internet to find the heart-shaped algorithm formula, I will write down the formula marked in the blog, mainly for the convenience of later viewing!

private int maxStep = 520; private double radius; private double centerPt; private void CreateHeartLine() { /*RootCvsIs the Canvas control * /CenterPt = RootCvs.Width / 2;Radius = RootCvs.Width / 6;For (int i = 0; I < maxStep; i++){Var rect = new RectangLe{Height = 5,Width = 5,Fill = Brushes.Red};Double angle = 2 * Math.PI / maxStep* I;Double r = 2 * radius * (1 - Math.Sin (angle));/ / circular heart//double x = centerPt + radius * (2 * Math.Cos (angle) - Math.Cos (2 * angle));//double y = centerPt + radius * (2 * Math.Sin (angle) - Math.Sin (2 * angle));/ / peach heartDouble x = centerPt + 16 * (Math.Sin (angle) * Math.Sin (angle) * Math.Sin (Angle) * 10; / /Double y = centerPt + (13 * Math.Cos (angle) - 5 * Math.Cos (2 * angl)E) - 2 * Math.Cos (3 * angle) - Math.Cos (4 * angle) * 10; / /Canvas.SetLeft (rect, x);Canvas.SetTop (rect, y);RootCvs.Children.Add (rect);}}

 

Link of this Article: WPF heart line algorithm

Leave a Reply

Your email address will not be published. Required fields are marked *