News:

Beta test the new forum at https://simutrans.forum/
Want to praise Simutrans?
Your feedback is important for us ;D.

Color replacement in makeobj

Started by wlindley, December 14, 2020, 02:11:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wlindley

Where would I find the right place to insert some code to do the player-color and alternate-player-color translation, to happen after reading an image?

I would like to add code to Makeobj so mapcolor= for factories (and perhaps a new mapcolor2= ) would map the player color range to the mapcolor range.  The idea being that you could draw a single shop for a whole variety of goods (or a whole set of similar mill buildings) without having multiple image files.  This logic would either be enabled only for factories (which do not currently have player color pixels as that would make no sense (they would always be grey for the public player)) or I could add another parameter in the datfile.

I had started a previous thread ("Modifying Building colours") on this topic, but perhaps now I can get some guidance with this section of code being revisited.

prissi

makeobj does not replace colors at all. The new code does not touch this. Player colors are replaced with special colors in the pak files. Hence, if you want building using player color replacement, the simutrans code needs changes, not makeobj. Then one could add two player_color1 player_color2 parameter to the building definition and during drawing pass these player colors to the actual drawing routine.

Other than that, there are tools that can replace one color like image_magic. You cann call this before calling makeobj usign image magic

convert $NAME.png -fuzz 0% -fill 'rgb(255,0,0)' -opaque 'rgb(0,255,0)' foo.png

which will convert all green to red.