Pattern Bezier Curve (C #)

Source: Internet
Author: User
Tags rand
pattern Bezier Curve (C #) author Jlgzw Bezier is a French engineer. The Bezier curve he invented can be said to be a wonderful curve that creates beautiful images. A Bezier curve is uniquely defined by 4 dots, including "Start", "End", and "control points." Where the position of the "control point" determines the shape of the curve.
Here's a little program that I've modeled on the screen saver "Bezier curves" that Windows brings. It can also set the number of Bezier curves and the number of rings, just modify the icount and inumber these two variables.
//----------------------------------------------
RandomBezier.cs @2007 by JL Gzw
//----------------------------------------------
Using System;
Using System.Drawing;
Using System.windows.forms;class Randombezier:form
{
Variable icount represents the number of Bezier curves
const int icount = 2;
Variable inumber the number of rings
const int inumber = 3;      Private point[] Ptarr = new point[4 * icount-(iCount-1)]; public static void Main ()
{
Application.Run (New Randombezier ());
}
Public Randombezier ()
{
Text = "pattern Bezier curve";
This. BackColor = Color.Black;

Timer timer = new timer ();
Timer. Interval = 100;
Timer. Tick + = new EventHandler (Timerontick);
Timer. Start ();
}
void Timerontick (Object obj, EventArgs ea)
{
Random rand = new Random (); Graphics Grfx = CreateGraphics ();
Erases the old Bezier curve.
for (int j = 0; J < Inumber; J + +)
{
for (int i = 0; i < 4 * icount-(iCount-1); i++)
{
Ptarr[i]. X + 5;
Ptarr[i]. Y + 5;
}
Grfx. DrawBeziers (New Pen (Color.Black, 1), Ptarr);
Point Ptbeg = new Point (0,0);
Gets the coordinates of the new Bezier curve.
for (int i = 0; i < 4 * icount-(iCount-1); i++)
{
Ptarr[i] = new Point (rand. Next (Math.min (Clientsize.width, clientsize.height)),
Rand. Next (Math.min (Clientsize.width, clientsize.height));

Ptbeg = ptarr[0];
}
Ptarr[4 * icount-(ICOUNT-1)-1] = Ptbeg;

Color color = Color.FromArgb (rand. Next (256), Rand. Next (256), Rand. Next (256));
Draw a new Bezier curve. The number of outer loop control loops.
for (int j = 0; J < Inumber; J + +)
{
Grfx.              DrawBeziers (New Pen (color, 1), Ptarr); for (int i = 0; i < 4 * icount-(iCount-1); i++)
{
Ptarr[i]. X = 5;
Ptarr[i]. Y-= 5;
}
} Grfx. Dispose ();
}
}

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.