i''m designing a simple particle system that in it''s current state makes fireworks. It''s very pretty. But what i''d like to do is draw a particle (a single pixel) and a "light trail" behind it. So i get the time the particle was "born" and the present time and then i can do the math to plot where the pixel will be, then i''d like to backtrack, say, 10 pixels and draw it''s "light trail".
The problem is this:
I have to backtrack 10 *pixels*, not 10 units of time. Why is this a problem? consider this simple example. Let''s plot an arc with some arbitrary math function:
*******************
* XXXXXXX*
* XXX *
* XX *
* X *
* X *
* X *
* X *
* X *
*X *
*X *
*X *
*X *
*******************
My original plan was to step through the X-axis and just find the last 10 Y-points. This is pretty simple:
for (int x=0; x < 10; x++) {
y = some_math_function( x );
}
This will spit out a Y point for whatever you plug in for the last 10 steps. The problem is that
this leaves holes! By that i mean, look at the theoretical graph above. If i use this technique to try to "Draw" this graph on the screen in pixels, it would come out like this:
*******************
* XXXXXXX*
* XXX *
* XX *
* X *
* X *
* X *
* *
* X *
* *
* *
* *
*X *
*******************
You see the holes at the bottom left where it starts? This occurs because there are several places in between the first X and the second X point that could give back valid Y coords. If i reverse my technique and step through the Y coords and derive the X, i would leave gaps on the other side of the graph
How can i create some drawing function that leaves no holes when plotting an arc?
If i was simply drawing a line, i could find which axis to step through so that it would not make any holes. But with an arc, the only solution i can think of is to step through the X
and Y and mix the two together afterward (but this is very sloppy of course).
I''m stumped. Any ideas? Advice is much appreciated. Thank you.