C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
DrawPolygon method Posted by Schwarzenegger on 27 Feb 2006 at 12:50 PM
Hello dear programmers!
Ok :

I'm creating a "paintBrush" (like windows have):
I want to create a polyline (what you can call "FreeHand") , anyway, I understood I suppose to have a dynamic array of Points (for instence:

"
Point[] curvePoints = new Point[];
"

But I get the following error:

Array creation must have array size or array initializer

"
Which means I'm doing something wrong in the defintion (I want a dynamic array) How do I define it?

Also You will have my gradedute, if you can show me how should I continue to create the poly line.. (what should I put in mouse move, down , up?)

Sincirly yours,

Rotem



Report
Re: DrawPolygon method Posted by IDK on 27 Feb 2006 at 1:47 PM
This is how it's done:

Point[] curvePoints = new Point[0];

in the mousedown event, add a point like this:

addPoint(curvePoints, new Point(e.X,e.Y));

You have to define the addPoint func to add a point.
(you could use a System.Collections.Array, wich have it predefined, but it lowers performance...)

The add func should look like this: (written from head...)
add(params Point[] p){
            Point[] tmp = new Point[curvePoints.Length + p.Length];
            curvedPoints.CopyTo(tmp, 0);
            p.CopyTo(tmp, curvedPoints.Length);
            curvedPoints = tmp;
}


I don't got time to write anymore...
Have fun with this code

Happy coding wishes
the one and only
Niklas Ulvinge aka IDK

Report
Re: DrawPolygon method Posted by Schwarzenegger on 3 Mar 2006 at 1:24 PM
Hi Niklas .

I just wanted to say thanks for your help (To be honest I havent managed to create the FreeHand, I just dont know what to do...)

Anyway thanks for your help..

Rotem



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.