Java-Gaming.org Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (681)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (746)
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  
  How to display a color picker  (Read 2970 times)
0 Members and 1 Guest are viewing this topic.
Offline RylandAlmanza

Junior Devvie


Medals: 3



« Posted 2012-03-09 19:10:59 »

So, I need a color picker for my voxel editor. I know how to get the mouse position, and after some research, I know how to get the color of a pixel on the screen. The only thing I need help with is how to display the color picker. What I thought of is a for loop that iterates 255 times for the red values, 255 times for the green values, and 255 times for the blue values. Then it creates a 1 pixel quad for each pixel. Probably not very efficient, right? How should I do this? Thanks!
Offline Matthias

Senior Devvie


Medals: 3
Projects: 1


TWL - Themable Widget Library


« Reply #1 - Posted 2012-03-09 22:32:44 »

TWL has a color picker widget (in addition to many other useful widgets). You can test the color picker in the TWL Demo or in the TWL Theme Editor (both are webstart links). The editor is completely written using TWL.
Offline RylandAlmanza

Junior Devvie


Medals: 3



« Reply #2 - Posted 2012-03-09 23:30:52 »

I've looked at TWL. Would you mind if I just stole some of your code for the color picker (It's open source, right?) I'd rather just use the color picker, and not include a bunch of tools for a full gui. Also, should I choose to use TWL in another project, will I just have to add some TWL stuff, and everything I've already programmed will work as-is? Or will I have to completely restructure my game?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #3 - Posted 2012-03-10 17:35:22 »

A very simple way to make a color picker is to use textures like so:



If the hue slider is at the middle, for example, that means the hue will be 360 * (1 - sliderY / sliderHeight) = 180, i.e. cyan. Render that (with full saturation/value) behind the saturation/value box in order to recolor it.
Apply the same idea to determine the saturation (% of width) and value (1 - % of height) and finally convert the HSV to RGB.

Code example using slick:
http://pastebin.com/NcAMpYd2

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

 
GrandCastle (28 views)
2016-07-01 09:13:47

GrandCastle (30 views)
2016-07-01 09:09:45

CopyableCougar4 (84 views)
2016-06-25 16:56:52

Hydroque (117 views)
2016-06-22 02:17:53

SwampChicken (119 views)
2016-06-20 13:22:57

SwampChicken (120 views)
2016-06-20 13:22:49

SwampChicken (112 views)
2016-06-20 13:22:26

Hydroque (157 views)
2016-06-15 08:22:50

Hydroque (152 views)
2016-06-13 06:40:55

DarkCart (255 views)
2016-05-29 02:30:33
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17
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!