Results 1 to 2 of 2
- 04-03-2009, 07:40 PM #1
Senior Member
- Join Date
- Jan 2009
- Location
- NJ, USA
- Posts
- 183
- Rep Power
- 5
[SOLVED] Expected Range: Red Green Blue
I get the following error:
Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: Color parameter outside of expected range: Red Green Blue
However, from what I've done I do not see how.
Take R (R, G, and B work the same way here). Regardless of what it becomes, I use R % 256, so the value should be between 0 and 255 (inclusive). How then is this value outside of the expected range (which is 0 to 255, right?)?
Java Code:for(int x = 0; x < WIDTH; x++) { for(int y = 0; y < HEIGHT; y++) { if(gen.nextInt(100) <= coverage) { int R = primColor.getRed(), G = primColor.getGreen(), B = primColor.getBlue(); R = (R + (gen.nextInt(2*range)-range)) % 256; G = (G + (gen.nextInt(2*range)-range)) % 256; B = (B + (gen.nextInt(2*range)-range)) % 256; g.setColor(new Color(R, G, B)); //error here g.fillRect(x, y, 1, 1); } } }Last edited by AndrewM16921; 04-03-2009 at 07:48 PM.
- 04-03-2009, 07:59 PM #2
Senior Member
- Join Date
- Jan 2009
- Location
- NJ, USA
- Posts
- 183
- Rep Power
- 5
Similar Threads
-
Writing integer pixel array(Range:0-255) into .txt file
By Mazharul in forum Java 2DReplies: 3Last Post: 08-24-2008, 01:51 PM -
What is the best way to represent range of number...
By zoe in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:13 AM -
Open Blue Lab 1.3.2
By levent in forum Java SoftwareReplies: 0Last Post: 08-01-2007, 04:22 PM -
Can I set a range in case statement?
By christina in forum New To JavaReplies: 1Last Post: 07-25-2007, 08:41 PM -
Open Blue Lab 1.2.10
By levent in forum Java SoftwareReplies: 0Last Post: 05-19-2007, 08:08 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks