码迷,mamicode.com
首页 > 编程语言 > 详细

WPF 心形线算法

时间:2018-09-22 01:02:07      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:new   class   void   int   creat   math   otc   can   rectangle   

原文:WPF 心形线算法

今天在网上查找下心形算法公式,自己便按照公式写下来标记在博客,主要是方便以后查看!

private int maxStep = 520; private double radius; private double centerPt; private void CreateHeartLine() { /*RootCvs是Canvas控件*/ 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)); //圆形心 //double x = centerPt + radius * (2 * Math.Cos(angle) - Math.Cos(2 * angle)); //double y = centerPt + radius * (2 * Math.Sin(angle) - Math.Sin(2 * angle)); //桃形心 double x = centerPt + 16 * (Math.Sin(angle) * Math.Sin(angle) * Math.Sin(angle)) * 10;// double y = centerPt + (13 * Math.Cos(angle) - 5 * Math.Cos(2 * angle) - 2 * Math.Cos(3 * angle) - Math.Cos(4 * angle)) * 10;// Canvas.SetLeft(rect, x); Canvas.SetTop(rect, y); RootCvs.Children.Add(rect); } }

 

WPF 心形线算法

标签:new   class   void   int   creat   math   otc   can   rectangle   

原文地址:https://www.cnblogs.com/lonelyxmas/p/9688770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!