Beziers and Moving Vector Graphics
Posted: Thu Feb 07, 2013 2:33 am
Hi All,
Yes, I'm still messing about with animated vector graphics - got to a point where I really needed to understand the GraphicsPaths a bit better before I could improve my graphics path editor.
Discovered some interesting stuff - so here's another FS 'Art-Club' update - and it comes with a FREE GAME!!
(skip to the very bottom of the post if you don't fancy all the boring technical talk - it's the .fsm file called 'Vector Graphics Demo').
The first thing I found came after seeing how MyCo made a rounded rectangle path using the bezier curves (you can draw them directly, but paths don't have that shape). It turns out that the GDI graphics engine that FS uses represents all curves as beziers under the hood - and I managed to find out the maths behind describing the curves - here are a few examples (including MyCo's original shape, and a slightly improved version).
Some of the bezier data is even visible using an undocumented Ruby method...
...it accepts one argument, but I haven't worked out what the argument is for yet - it always returns the list of points in the shape (including the bezier handles), but is missing the data that would show which refer to lines and which to beziers.
So why is that useful?
Once you have curves all in bezier form, you can move the shape around the screen, scale it, rotate it, skew it in all manner of ways by just transforming the points - no arc angles to measure, or circle diameters, just move the bezier handles in the exact same way as all the others.
So I've added some new stuff to the new GUI classes I've been writing, including a very compact and fast way to define transformations, and a 'Shape' class that can store and transform, multi-layer vector sprites, complete with colour information. Still plenty of work to do, but I am afr enough along to have something to show...
You understand, of course, that once you have vector graphics that can be animated, there's just something that every programmer of a certain age just has to do with them....
My best score so far is 28,510 on level 5!!
Yes, I'm still messing about with animated vector graphics - got to a point where I really needed to understand the GraphicsPaths a bit better before I could improve my graphics path editor.
Discovered some interesting stuff - so here's another FS 'Art-Club' update - and it comes with a FREE GAME!!
(skip to the very bottom of the post if you don't fancy all the boring technical talk - it's the .fsm file called 'Vector Graphics Demo').
The first thing I found came after seeing how MyCo made a rounded rectangle path using the bezier curves (you can draw them directly, but paths don't have that shape). It turns out that the GDI graphics engine that FS uses represents all curves as beziers under the hood - and I managed to find out the maths behind describing the curves - here are a few examples (including MyCo's original shape, and a slightly improved version).
Some of the bezier data is even visible using an undocumented Ruby method...
Code: Select all
myPath = GraphicsPath.new
myPath.addEllipse([0,0,10,10])
myPath.getPathData('?')...it accepts one argument, but I haven't worked out what the argument is for yet - it always returns the list of points in the shape (including the bezier handles), but is missing the data that would show which refer to lines and which to beziers.
So why is that useful?
Once you have curves all in bezier form, you can move the shape around the screen, scale it, rotate it, skew it in all manner of ways by just transforming the points - no arc angles to measure, or circle diameters, just move the bezier handles in the exact same way as all the others.
So I've added some new stuff to the new GUI classes I've been writing, including a very compact and fast way to define transformations, and a 'Shape' class that can store and transform, multi-layer vector sprites, complete with colour information. Still plenty of work to do, but I am afr enough along to have something to show...
You understand, of course, that once you have vector graphics that can be animated, there's just something that every programmer of a certain age just has to do with them....
My best score so far is 28,510 on level 5!!
