WPF Heart-line algorithm

Source: Internet
Author: User
Tags cos

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.