|
EasyToUse Dynamic Color Gradiant Generator |
da_flo
Member #1,907
February 2002
|
Quote: If you observe your pictures closely(don't know why i immediately spotted it), you will find that those "dark lines" are appearing along curves of other pixels that are not on the polynomial but for which there are always at least TWO points on the polynomial with EQUAL distance to the points on the "dark line". Yes. I immediatly noticed that. Quote: Don't know what is causing it though, but i suppose your algorithm could be reporting a wrong distance I thought it was that at first, but I can't see where my algo would fail. It's behaving as expected in the other cases. Well, I know that's no proof , but I just think it works correctly. (I can't really explain) Quote: It could also be caused by the inaccuracy I somehow doubt it. I thought of it too, but I have difficulty to see why. And I'm quite sure there is a mathematical reason to this, which is perhaps visually accentuated by the algorithm and the inaccuracy of the lookup table. Anyway, I have thought of an algorithm which will get rid of the inaccuracy of my current method when the slope of the polynomial is too high, but I'll have to drop the lookup tables. It will be reliable in all cases, and will have a custom precision. I'll code it and try it if I find enough time (damn... Speedhack is beginning tomorrow ) In fact, the inaccuracy problem appears above all when the range is small and the slope of the curve is big. Here are some pictures which show it quite nicely : Also, I tried to play with funky polynomials, which have lots of extrema (so necessarily of higher degree), so with several areas where 2 points have the smallest distance, and sometimes even 3. I thought it will be fun. And it was. See : In the fourth picture, I played with the exp modifier so that we can see things better (I was still using the old modifier code, by the way). It caused some nice bug because of the lookup table and the accuracy of the distance calculation method, as you can see... ________________________________________________________________________ I also had some nice ideas about your C++ port, Dennis. Well, don't worry, normally this won't disturb your current development (otherwise I'll begin to feel guilty ). First, your whole code isn't really specifically related to allegro. You only use a putpixel and a bitmap in the rendering function. So I think it would be nice to keep the core module (the one which handle the ca list, and has the rendering method) independent of allegro or any graphics API. You could have a 'virtual void plot(int x, int y, int r, int g, int b)' virtual method which will be called from by rendering method. Then all we have to do is to derive a new graphics API specific class from the core class, which will have the bitmap or the device context as a member and implement the plot method. That way the gradient generator can easily be used with allegro, wxwidgets, or any other graphics/GUI API. Then, for the polynomial thing, I think you should have a generic functional curve ca class, which will handle the distance calculation and the stuff, and have a virtual method to compute the coordinates of the points on the curve. That way we can easily have derived class for polynomials or any other kind of functions. We could have cool sine waves, or anything the user/programmer will think of. (easy to use since all the user has to do is derive a new class and implement the value calculation. It's just a few lines). Also, since you want to keep different kinds of distance calculations for those functionnal curves, you'll probably want the distance calculation to be virtual, so that we can have different derived classes depending on the algorithm wanted, no ? :) The more I think about your C++ port, the more I think it's going to be great. It will be really nice to use, it will be a true new API that programmers will be able to use. :) I don't know how you're going to handle it though. Do you think you'll make it a lib, or only header files and source modules the user will have to add to their project ? Well, perhaps a lib is a bit too much for it... I don't know. :). I'm really enjoying playing with your code (the old C version ;)), and I'm really getting interested in this project. If you need help, I'd be really happy to contribute. If you want me to code some modules, such as the functionnal curves and other fancy maths object, I'd be glad to help you. :) |
Richard Phipps
Member #1,632
November 2001
|
too..many..smilies..
|
da_flo
Member #1,907
February 2002
|
Ooops. I didn't notice. I just put them when I felt like it (eh, I was perhaps feeling really happy in this post. ). And I forgot I put that much... Sorry. |
Dennis
Member #1,090
July 2003
|
Don't worry the C++ port, will be excellent. There is really no need in giving me hints on how to do the class hierarchy(I even felt a little insulted when you pointed on those obvious things with virtual functions. Again don't worry about that. Each attractor class will have just one single function(and that is NOT the distance function;)) that is called by the render method of the gradient class and it will of course be virtual and by that every derived attractor will be free to add thousands of other functions to its' private scope and then act on the given pixel as weird or cool as it wants.) Other features that i have planned: And now, please wait patiently for the port. It will take a lot longer than i originally thought, because there are so many NEW features i think of, that i want to have in it and also i won't release it until the GUI is done and everything is working. (Will take at least a week if not longer, because also i can't stop playing around with the old version sometimes.;D And thanks for offering but i don't want your help, because i want to code everything myself.(at least for the initial release)) Your polynomial tests are looking interesting, especially those where the polynomials are "dotted".:) --- 0xDB | @dennisbusch_de --- |
da_flo
Member #1,907
February 2002
|
Quote: Don't worry the C++ port, will be excellent. I'm not worrying. Quote: Targetsystem stays Allegro, so the thing will be crossplatform. Okay then. But I still think it would be better if it did not directly depend on allegro, and if we could use any graphics or GUI API with it. Quote: There is really no need in giving me hints on how to do the class hierarchy(I even felt a little insulted when you pointed on those obvious things with virtual functions.
I didn't intend to insult you. Sorry if I there was a misunderstanding. Quote: Each attractor class will have just one single function(and that is NOT the distance function;))
Quote: every derived attractor will be free to add thousands of other functions to its' private scope and then act on the given pixel as weird or cool as it wants.
Uh ? What will this single function be ? I can't really see your class design, and I'm really curious about it. Quote: And now, please wait patiently for the port. But I am waiting patiently for it. Quote: And thanks for offering but i don't want your help, because i want to code everything myself.(at least for the initial release) I understand. That's pretty normal. Sorry, I was really getting excited about your work and about this gradient generator, and I've perhaps gone a bit too far in my previous post. ( PS : I don't want to look stubborn, but I still think some of my ideas were really interesting. And also you didn't say anything about the fact having an abstract class for functionnal curves, so that we can have any functionnal curve, and not only polynomial attractors. ) ______________________________________________________________________________ In other news, I kept playing with the polynomial attractors, and I now have an accurate distance calculation algorithm. So rendered the same example as before, y=x^2 with a range of 10, and here is the result : yay.png. Then I still have to improve it, because it has some serious problems, particularly when the polynomial curve goes really far beyond the y bounds of the screen, for example for high degrees and/or small units. I quickly becomes a memory hell and either it's awfully (and uselessly) slow or it screws everythings up. |
Dennis
Member #1,090
July 2003
|
da_flo said:
Uh ? What will this single function be ?
The function will be cleverly choosen.;) da_flo said: I still think some of my ideas were really interesting. And also you didn't say anything about the fact having an abstract class for functionnal curves, so that we can have any functionnal curve, and not only polynomial attractors. I'm not saying that i will not add that. Also i'm not saying that i will add it. But if i add it, it would be done properly, so that the user can enter the function definition in a freeform string, just like if he'd write it down to paper. That would require writing an advanced string parser though and usage of clever operator and operands stacks and trees. Since the other features i planned will already be taking more time, it is more likely that it will not be in. But of course, i you still want to, you can later add it yourself.8-) But i don't want to distract you from speedhack now, and as i already said the C++ port is not nearly done yet. (Some parts of it are still in the planning phase...;)) --- 0xDB | @dennisbusch_de --- |
da_flo
Member #1,907
February 2002
|
Quote: But i don't want to distract you from speedhack now, and as i already said the C++ port is not nearly done yet. (Some parts of it are still in the planning phase...;)) Well, I'm having annoying computer problems, particularly with my network connection. All of this is pissing me off, and I haven't started speedhack yet. I'm in such a bad mood that i don't even know if I'm going to do it, finally. And you're not distracting me at all. You're only answering to my questions and my ideas. It's rather me that have been distracting you from your C++ port for the past few days. And the fact that the C++ port isn't nearly quite done isn't a problem. I still have many things to do with functionnal curves attractors and my distance calculation algorithms . (by the way, did you look at my new pictures and what I said about my new accurate algo ?) |
Dennis
Member #1,090
July 2003
|
da_flo said: It's rather me that have been distracting you from your C++ port for the past few days. yes...>:( (don't take that too seriously;)) da_flo said: by the way, did you look at my new pictures and what I said about my new accurate algo ?
I looked at the pictures and i think you did not post your new algo. --- 0xDB | @dennisbusch_de --- |
da_flo
Member #1,907
February 2002
|
Quote: Would it not be sufficient to have one additional table where for each y it holds a list including multiple values for the missing x pixels? hmm. I thought about it in my bed yesterday night (I didn't even had this idea before...), and I didn't think it would really work easily. But after all, if I look at it more closely, perhaps it would work. But my method is not really more complicated or eats much more computing or memory power, and is really elegant mathematically speaking, IMO. |
Dennis
Member #1,090
July 2003
|
I think i just found the best and fastest method of all(:)): Hope it gets clear, I was too lazy to give a more detailed explaination.:) [edit] Because of the y rising downwards you have to switch some plus and minus and blah in the above description but the idea stays the same. The fun thing: NO squareroots are involved!!! ('cause the tracelength-count can directly be taken...;))[/edit] [edit2]it can be optimized even more by just storing a 'high' and a 'low' for each x position(don't extra store 'rise' and 'fall') then for the trace position a simple low<=y<high(or high<=y<low for y rising downwards) will do sufficient for stopping the trace[/edit2] [edit3] [EDIT4](too bad i spotted a flaw: For a pixel to the bottem right or left of the minimum in the above example, it would report a wrong distance...>:()[/edit4] [edit5] --- 0xDB | @dennisbusch_de --- |
da_flo
Member #1,907
February 2002
|
Okay. I'll take a closer look at it later. (Must... stay... away... from... allegro.cc) |
Dennis
Member #1,090
July 2003
|
da_flo said: Must... stay... away... from... allegro.cc Yeah, i must say i'm really becoming obsessed about the thing.:D Make sure you don't miss my edits above as they describe pitfalls you could encounter, if you were very tired already.;) ------------------ --- 0xDB | @dennisbusch_de --- |
da_flo
Member #1,907
February 2002
|
Quote:
da_flo said: Yeah, i must say i'm really becoming obsessed about the thing.:D I meant : I must stay away from allegro.cc. For speedhack reasons... Quote: I thought about portability again and i plan now, as you suggested, to keep the core functionality system independent. (Nothing more to add) Quote: So far so good. The basic planning phase should be completed soon. Okay. Keep going and good luck ! PS : Hey, you will be able to post new message now |
Dennis
Member #1,090
July 2003
|
Well then here's the IOTD code: col_att_list3 test; init_ca_list3(&test); add_to_ca_list3(&test,CA_POINT,CA_ABSORB,1.8,1.0,320,240,0,255,255,200,NULL); add_to_ca_list3(&test,CA_VBAR,CA_ATTRACT,1.8,0.33,320,0,255,255,100,320,NULL); add_to_ca_list3(&test,CA_HBAR,CA_ATTRACT,1.8,0.33,0,240,255,255,100,240,NULL); add_to_ca_list3(&test,CA_POLYNOMIAL,CA_ABSORB,1.8,0.39,0,0,100,100,0,200, make_polynomial(5,100,320,240,-1.0,0.0,5.0,0.0,-4.0,0.0)); add_to_ca_list3(&test,CA_POLYNOMIAL,CA_ATTRACT,1.8,0.39,0,0,50,150,255,200, make_polynomial(5,100,320,240,-1.0,0.0,5.0,0.0,-4.0,0.0)); render_col_grad_to_bitmap3(backb,&test); /* backb must be a valid 32bpp bitmap 640x480 in dimensions */ save_tga("./polycool.tga",backb,NULL); kill_ca_list3(&test); (you can make backb 1600x1200 but then you must also multiply all positions and ranges by 2.5) I'll try to resist coming back for a whole week.:) --- 0xDB | @dennisbusch_de --- |
Edward Sheets
Member #4,734
June 2004
|
Dennis said: I'll try to resist coming back for a whole week.:) Don't do that! This has been one of the most educational and productive threads ever Good job with the Dynamic Color Gradient Generator. It's very kool. --- Note: carving a pentagram on the top of a container of spoiled yogurt does not summon a yogurt demon. -Kikaru |
Dennis
Member #1,090
July 2003
|
Hey, thanks a lot!:) But i definitely need to cut back on my visits, or else nothing ever gets done. (As everyone can see i could not even resist coming back for a few hours:P) [edit sunday 14th] [edit Monday 15th] [edit Wednesday 17th] --- 0xDB | @dennisbusch_de --- |
da_flo
Member #1,907
February 2002
|
Okay I'm back after this exhausting speedhack and a small break. As for the distance calculation, I'll post a detailed comment once I'm motivated enough to analyse your method in details and give a good explanation of mine.;) (Seems like I'm getting tired of writing long and complicated posts. But be sure I'll do it !). I'll just say now that my method is flawless too, quite quick too, and above all mathematically very clear and elegant ! (well, that's why it seems appealing to me. We don't have quite the same concerns sometimes Quote: made plans and calculations for a POINTE class(point attractor with an elliptic range) Nice idea. That way of generalizing is really the one I like to play with. Quote: also played with the thought of a rotated ELLIPTIC attractor class and thought of making POINTE rotated as well
In fact, I was thinking of making every attractor rotated, even POINT for consitency. Also, having elliptic attractors will be quite nice. And there should be a way to easily calculate the distance to an ellipse, using the properties of the normals to an ellipse. (I would have to dig into my geometry courses, though ) |
Dennis
Member #1,090
July 2003
|
da_flo said: And there should be a way to easily calculate the distance to an ellipse,
It is in fact easy and i already made all the calculations, generalized for rotated ellipse and point"e". I think you don't even need to dig in any geometry books for that. Just draw a sketch of a cartesian coordinate system(y grows downwards) then put a rotated(angle grows clockwise) ellipse somewhere with attributes "center(x0,y0)","width","height","angle(rotation around its center)", then start using your brain.:) (**see the difference: ..I don't feed you every (annoying) detail, by that i give you the chance to find a way(which may turn out to be different from mine) yourself and i don't already lead your thoughts into any specific direction.) da_flo said: (Note : I am not giving you hints, just explaining my method in details;)) Very wise of you to put that comment.(Kept me from exploding into 1000 pieces, but maybe it is just me who gets angry that easily.);) [edit] [progress Thursday 18th] [progress Saturday 20th] [progress Thursday 23rd] --- 0xDB | @dennisbusch_de --- |
|
|