Answer in C#. DO NOT PUT A JAVA CODE AS THE ANSWER, C# ONLY!!!
Concept Summary: 1. Graphics Java/C# 2. Colors 3. Drawing Lines Objective: In this assignment you'll be drawing all the possible red, green, blue, purple and white shades next to each other in a window. When you are done, your output should look like this: Color Choices Java Initial Steps: 1) Create a Group object. 2) Create a Canvas of size 300x300 3) Create a GraphicsContext, set it to your canvas.getGraphicsContext2D0); 4) Add your canvas to your group C# Initial Steps: 1) In Form 1.Designer.es add an protected override void OnPaint(PaintEventArgs e) a) It should auto complete a basic method with a base.onPaint(e) 2) Create a Graphics object assign it e.Graphics 3) Make a variable of type Pen; Both Languages: 1) Remember an RGB (red, green, blue) value for a color is made up of 3 numbers each between and 255. So solid red is 255,0,0 as you want ALL the red, none of the green and none of the Blue. Solid blue is 0,0,255, and solid purple is made up of red and blue, so it'd be 255,0,255. 2) You'll want to be able to alter your pen using RGB (red green blue) values in between drawing each line. a) Java: ge.setStroke(Color.rgb(255,0,0)); //Assumes you called your graphics context gc, will set the pen to red. b) C#: Color myColor-Color.FromArgb(255,0,0); myPen = new Pen(myColor); //Assumes you called your pen myPen, makes pen red. 3) For the red stripe you are going to use a loop from 0 -> 255. a) Set up your pen with the color 0,0,0. b) Draw a line from x=10, y=0 to x=50, y=0 c) Repeat steps a and b, but this time the color should be 1,0,0, and the y values should be I. Leave the x values the same each time. d) Repeat steps a and b, but this time the color should be 2,0,0 and the y values should be 2. e) 1) Repeat steps a and b all the way until y=255 and color is 255,0,0. 4) Repeat for the green stripe. a) Set up your pen with 0,0,0 b) Draw a line from x=60, y=0 to x=100, y=0. c) Repeat steps a and b, but this time the color should be 0,1,0 and the y should be 1. e) Repeat steps a and b, but this time the color should be 0,255,0 and the y should be 255 5) Repeat for the blue stripe. a) These steps are the same, except i) Colors go from 0,0,0 to 0,0,255 ii) Lines are from x=110, y=0 to x=150, y=0 through x=110, y=255 to x=150, y=255. 6) Repeat for the purple stripe. a) These steps are the same, except: 1) Colors go from 0,0,0 to 255,0,255 (ie, both red and blue increment together) ii) Lines are from x=160, y=0 to x-200, y through x=160,y=255 to x=200, y=255. 7) Repeat for the white strip a) These steps are the same, except: i) Colors go from 0,0,0 to 255,255,255 (i.e. all 3 colors increment together) ii) Lines are from x=210, y=0 to x=250, y=0 through x=210, y=255 to x=250, y=255. Final steps: C#: You are done. Java: Make a new Scene: Scene myScene=new Scene(root); Set the primaryStage setScene(myScene): //This assumes you called your group root Sample Output: C#: Form - Java: (Shown at the top of the doc)