Passing color as argument when using StdDraw in java -


having trouble passing color argument if @ possible when using stddraw in java.

what passing color variable f.e. "red", "green", "blue" set pen color of drawing function different color each time run through loop.

here code more details of trying accomplish.

static void drawcirclesizecolor()     {     string[] mycolorarray = {"red","green","blue"};     double x = 20;     double y = 20;     double r = 20;     int c = 0;      (int = 0; <= 3.0; i++)     {          stddraw.setpencolor(color.getcolor(mycolorarray[c]));         stddraw.circle(x, y, r);         c++;         r--;     } 

hope understand going this

thanks -ee

import java.awt.color; 

declare array as:

color[] mycolorarray = {color.red,color.green,color.blue}; 

and use them

stddraw.setpencolor(mycolorarray[c)); 

class java.awt.color has static variables standard colors predefined


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -