Results 1 to 5 of 5
Thread: Need help with creating colors
- 02-15-2012, 07:39 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Need help with creating colors
I am supposed to:
Create a new scenario called test-pattern that uses a loop and an array to produce the image below on the standard Greenfoot scenario screen (a super method call with parameters 600, 600, and 1). Use the array to store the RGB values of the colors.
This is what I have:
[I]import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class Chart here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Chart extends World
{
Color[] palette = { new Color(255,255,255), new Color(204,255,0), new Color(0,0,255), new Color(0,255,0), new Color(255,0,255), new Color(255,0,0), new Color(0,0,102), new Color(0,0,0), };
/**
* Constructor for objects of class Chart.
*
*/
public Chart()
{
// Create a new world with 600x600 cells with a cell size of 1x1 pixels.
super(600, 600, 1);
makeColor();
}
public void makeColor()
{
for(int i = 0; i < palette.length; i++)
{
addObject(new Color(palette), (i*75), 600);
}
}
}
I am getting the error:
cannot find symbol - constructor Color(java.awt.Color) (referenced above in bold).
I am taking a six week course in Java using Greenfoot. This, I am sure, is a very simple explanation and I am missing something very simple. Can someone please explain? Thank you.
- 02-15-2012, 08:16 PM #2
Re: Need help with creating colors
Your palette variable is an array of Color Objects, right? And you're passing it into Color's constructor. Where in the API do you see a Color constructor that takes an array of Colors as an argument?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 02-16-2012, 10:30 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 2
- Rep Power
- 0
Re: Need help with creating colors
Thank you for your help. I got it!
- 07-05-2012, 11:05 AM #4
Member
- Join Date
- Jul 2012
- Posts
- 10
- Rep Power
- 0
Re: Need help with creating colors
I have this same issue. any suggestions?
-
Re: Need help with creating colors
Similar Threads
-
How do i add colors
By ytrewqc in forum New To JavaReplies: 1Last Post: 11-01-2011, 02:15 PM -
Convert 24 bit colors to 16 bit
By i4ba1 in forum Advanced JavaReplies: 2Last Post: 12-09-2010, 01:23 AM -
Rectangle and Colors
By urbim in forum Java AppletsReplies: 0Last Post: 07-11-2009, 03:03 PM -
Colors and shapes.
By Torgero in forum New To JavaReplies: 14Last Post: 10-13-2008, 05:25 PM -
change colors
By calblue in forum New To JavaReplies: 1Last Post: 12-02-2007, 11:52 PM


LinkBack URL
About LinkBacks


Bookmarks