Today on the Internet to find the next heart-shaped algorithm formula, I wrote down according to the formula marked in the blog, the main is convenient to view later!
private int maxstep = 520; private double radius; Private double centerpt; private void Createheartline () {/*rootcvs is a 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)); Round 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 Heart Double x = centerpt + * (Math.sin (angle) * Math.sin (angle) * Math.sin (angle)) * 10;// Double y = centerpt + (* 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 Heart-line algorithm