Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Making color "see-thru" without changing it's color?  (Read 1088 times)
0 Members and 1 Guest are viewing this topic.
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Posted 2011-11-23 19:21:34 »

Alright, whenever you make a color translucent it reduces the overall intensity of the color, the color itself is reduced by the translucency given.

However, I wonder if there's a way to make a color translucent, or "see thru", without the color being changed?

Or is that not possible?

Example:

(photoshopped, color c found by eye)


I have color a, which I want to make translucent so it becomes color b, but I want it to be like color c.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline ShannonSmith
« Reply #1 - Posted 2011-11-23 19:29:32 »

The reason is it's now mixed with the color behind it, if the color behind it is white then it will appear to lose saturation because white is de-saturated. You could increase the saturation of the color while making it transparent if you want it to look less washed out.

Edit:
In your example above you are using additive blending which is not supported in the Java graphics stack without using a custom composite.
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #2 - Posted 2011-11-23 19:31:30 »

The reason is it's now mixed with the color behind it, if the color behind it is white then it will appear to lose saturation because white is de-saturated. You could increase the saturation of the color while making it transparent if you want it to look less washed out.


Is there some mathematical formula to do that?

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Catharsis

Senior Member


Medals: 5
Exp: 18 years


TyphonRT rocks!


« Reply #3 - Posted 2011-11-23 19:32:21 »

Hrm.. Of course when you are overlapping one or more translucent colors / shapes intensity will be modified, but are you commenting say compositing a translucent object on a white background where the background itself affects the color intensity. I suppose if you could work out some way to composite a scene without taking into account the background you'd accomplish this. Perhaps modifying directly a BufferedImage. This seems more like a compositing problem. I can't off the top of my head think of a non-custom way to accomplish this.  

Offline ShannonSmith
« Reply #4 - Posted 2011-11-23 19:34:55 »

The reason is it's now mixed with the color behind it, if the color behind it is white then it will appear to lose saturation because white is de-saturated. You could increase the saturation of the color while making it transparent if you want it to look less washed out.


Is there some mathematical formula to do that?

You could calculate it for a white background, but you won't be able to get any color component brighter than the alpha value. It sounds like you want additive blending, in which case you have to write a custom composite or directly manipulate the image buffer.

Offline Catharsis

Senior Member


Medals: 5
Exp: 18 years


TyphonRT rocks!


« Reply #5 - Posted 2011-11-23 19:40:37 »

Is there some mathematical formula to do that?

Not that I've played around with this, but I believe it's easier to modify saturation with HSV vs RGB.

http://en.wikipedia.org/wiki/HSL_and_HSV
http://en.literateprograms.org/RGB_to_HSV_color_space_conversion_(C)


Offline ShannonSmith
« Reply #6 - Posted 2011-11-23 19:41:05 »

Just divide the R/G/B values by the alpha to darken them and I think it will work.

Edit:
On second thought that won't work.
Offline loom_weaver

JGO Coder


Medals: 17



« Reply #7 - Posted 2011-11-23 19:42:20 »

Umm, even java.awt.Color accepts an alpha-channel.

[EDIT] never-mind, I didn't take a close enough look at your image.
Correct me if I'm wrong but isn't that what you are looking for?
Offline ShannonSmith
« Reply #8 - Posted 2011-11-23 20:11:08 »

Basically for each channel (rgb) you have have (255-alpha) colors to work with so if the color you are after is not in that range you can't do it.

Try setting each RGB component to (dest + alpha - 1.0)/alpha where dest is the color you are after when composting to a white background, if any work out to be outside the range 0.0 - 1.0 you can't do it.
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #9 - Posted 2011-11-23 21:45:14 »

Yea, thought so.

Was just curious about this. Thanks.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #10 - Posted 2011-11-24 03:16:51 »

Yea, thought so.

Was just curious about this. Thanks.

You can hack it. Make a list of colors you want to be able to see, or colors you don't want to see, and exchange the pixels Cheesy Sure, it's not going to run well if you do it in real-time.

Offline theagentd
« Reply #11 - Posted 2011-11-24 05:02:17 »

Maybe additive blending is what you want?

Myomyomyo.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #12 - Posted 2011-11-24 05:07:33 »

It looks a lot like subtracting the negative of the target from the source.  So white doesn't subtract anything at all, and black turns into, well, black.  I'm not sure if there's a built-in blending equation for that but I'm not a blending expert.

Offline nsigma
« Reply #13 - Posted 2011-11-24 10:06:35 »

A little hard to know exactly what you want given the background is monochrome.

Some links that might be of help


It looks a lot like subtracting the negative of the target from the source.  So white doesn't subtract anything at all, and black turns into, well, black.  I'm not sure if there's a built-in blending equation for that but I'm not a blending expert.

That description is really familiar, but I can't put my finger on the name for it.  Linear Burn seems closest (if not the same - not enough coffee yet!   Clueless )

Best wishes, Neil

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Catharsis

Senior Member


Medals: 5
Exp: 18 years


TyphonRT rocks!


« Reply #14 - Posted 2011-11-24 10:15:09 »

Yeah.. taking into account a background as others have mentioned I don't think you'll reach a satisfactory result per se with color modification or saturation. You might get close I suppose. Also it will help to know if you want to work with a 2D API IE Java2D / Android 2D API or GL. Off the top of my head thinking aloud could you have too buffers and do some minor compositing. IE have an RGBA image you draw the text and your translucent shapes into then have a separate image as your background then do a Porter-Duff replace op when blending the text/shape image on top of the background image. Could that possibly work out?

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (74 views)
2014-09-10 06:39:09

Tekkerue (38 views)
2014-09-09 02:24:56

mitcheeb (57 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (28 views)
2014-09-07 01:12:14

Longarmx (34 views)
2014-09-07 01:11:22

Longarmx (35 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!