replace color with transparent using ~PAL or similar?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Gwledig
Posts: 569
Joined: March 30th, 2009, 5:10 pm
Location: UK

replace color with transparent using ~PAL or similar?

Post by Gwledig »

Hi I'm trying to make a colour in an image/icon transparent, I can make the whole thing transparent with O~() but just want to replace a particular colour, which I can do for non-transparent colors with ~PAL() e.g. icons/jewelry_necklace_amber.png~PAL(0,0,0 > red)~O(0%)

The above replaces the black background of the icon with red, and applies a general opacity setting to the image, but does anyone know how to set the opacity of a particular colour?

gwledig

Moved to WML Workshop ― shadowm
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: replace color with transparent using ~PAL or similar?

Post by Sapient »

I don't think there's currently a way to do that with the existing ImagePathFunctions, sorry.
It might be a good feature request, though.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Gwledig
Posts: 569
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: replace color with transparent using ~PAL or similar?

Post by Gwledig »

Thanks anyway. I get a reasonable outcome by replacing the background colour with the background colour of the area where the unit will appear (a kind of grey chasm background) and applying a partial opacity to the whole thing, this makes the unit look faded but it looks more like a regular units now, I am thinking in particular of non core unit artwork which can be used as multiplayer distributable unit art, not the greatest outcome but kindof works, e.g. "image.png~PAL(0,0,0 > 34, 56, 34)~O(70%)" this replaces the background black colour with the rgb values specified and partial opacity for the whole icon.
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: replace color with transparent using ~PAL or similar?

Post by beetlenaut »

Is there a reason you can't use an image editor to select and erase the color?
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Gwledig
Posts: 569
Joined: March 30th, 2009, 5:10 pm
Location: UK

Re: replace color with transparent using ~PAL or similar?

Post by Gwledig »

its for a multiplayer scenario and I'm working on the basis that a host can run a game & players can join without DL the scenario.
Maintainer of Conquest (Original Gameplay), Conquest+, Conquest+ Space/Ranged, Chaoz Battle of the Wizards, Lazersquad (squad game), WesCraft (building MP game)
Post Reply