Hi there!
It doesn't come often that I post some code I made since I focus only on my shmup project. To change this bad habit, I post a little class I made during those 4 last days.
Stroke help you to draw lines from an array of points. Stroke allow you to change the stroke appearance and behavior throught many functions, like its thickness, inner and outer colors, textures, start and end thickness, smoothness (or sweepness), lifetime and many other things.
At first, this was a class to help me
draw spaceship trails for my shmup, but with time it became a more general class.
I took exemple from sf::Shape and sf::Sprite to compose this class.
Here is a small exemple of what you can do with it :
http://www.megaupload.com/?d=63QNKJ1MAnd the Visual Studio project with sources :
http://www.megaupload.com/?d=VNW70BRAIn few words, you have 4 files :
- .cpp and .h of the Stroke class,
- my_utility.h, regrouping
some math function from the wiki and many other functions I added, like Spline/Bezier function, collisions detection, etc... Functions numbered 2 are for inverted Y axis reference. I apologize but I didn't take time to write english comments, thoses are french ones, but most of function name are explicit.
(Just in case, the ResampleBezier one convert an array of non-equidistant points generated from previous Bezier fonction to another array of equidistant ones of same size.)- The main.cpp used to create the exemple.
The sources are a bit commented but the class isn't documented.
I hope you will find some use for this class in your projects. :]
And of course, if you want to enhance the class with optimization or new features, feel free to do and share.
There is plainty of things to do about this class.
EDIT : Last version on the wiki!
A video :
A binary exemple (win32) : http://www.megaupload.com/?d=TACO1MWW
The sources of the binary : http://www.megaupload.com/?d=1U5BS38W
And the wiki : http://www.sfml-dev.org/wiki/en/sources/stroke