RawDrawImage color changes

Started by spook1, Fri 23/04/2004 14:44:49

Previous topic - Next topic

spook1

In my simulation of electrical circuits I have wires that must change color as a current flows through it.

if the current is low, the wire is normal (gold)
if the current is larger the wire must be dark-red.
if the current is further increaed the wire must turn orange
if the current further increases the wire must become white

because I have 30 elments I cannot create a view with all the different colors and use SetViewFrame. In an earlier demo I did this:
i calculated the curent through the wire, and picked the right viewframe with the current value.

Now I am looking for a scripted solution, where I can influence the color of a single sprite.
is something like this possible? Maybe using color channels or aplha channels ??
I am not familiar with this stuff.
is there anyone who can reflect on my question?

regards,
martijn

Pumaman

Is the wire just a line of pixels? If so, you should be able to use the RawDrawLine feature to draw it in any colour? Or if not, could you be more specific about how the wires are drawn?

spook1

wires are just sprites. in former versions they were objects, now they are metallic looking bars and resistors as well as light bulbs,

cheers, martijn

Pumaman

Is the problem then that you have 30 different wires, all different shapes, and you don't want to have to draw 4 different graphics for each one?

spook1

yes, but I guess that a simpler solution is going to be more complex ;-)

cheers

Scorpiorus

Hmm, that's rather problematic but you could probably RawDrawImage the sprite then use RawDrawImageTransparent() to draw some mask sprite over the current one with the desired transparency level.

spook1

thanks. I'll try that next time. Now I have solved the question by drawing 40 different sprites. If interested you can download demo from: http://www.xs4all.nl/~koops/ags/spacespy_devel17.zip

Scorpiorus

Looks nice :)

Btw, looking at the shape of wires it could be a good idea to go with RawDrawRectangle/Line() as CJ suggested.

~Cheers

SMF spam blocked by CleanTalk