0

This is probably an elementary question. However, I have completed reading the 9th Chapter of Java Programming for the Absolute Beginner and have approached the Challenges section. I cannot quite understand the question.

The question asks:

"Create a Canvas that paints a gradient that’s dark on one side and slowly
gets lighter as it moves to the other side."  

This might be helpful information: prior to this challenge question, the word 'gradient' has not appeared within code methods or within the text. I have not yet learned anything about animation as the question states "moves to the other side."

An answer to this question can potentially aid many new Java programmers in understanding Graphics and Canvas.

I DO NOT want a coding answer (unless necessary), just this question explained in more basic terms along with what procedures I must take. Thank you very much for your time and cooperation regarding this matter.

Jarrod
  • 9,349
  • 5
  • 58
  • 73
  • 3
    I think they're referring to this http://en.wikipedia.org/wiki/Gradient – cangrejo Dec 30 '12 at 18:22
  • 1
    If they have taught for loops... Then you can create a loop that creates a single square of color... Start dark e.g. 0,0,0 (RGB) and increase each color by 1 on each loop until you are at 255,255,255 (white) – scunliffe Dec 30 '12 at 18:25
  • 1
    @scunliffe Or just use [the GradientPaint class](http://docs.oracle.com/javase/7/docs/api/java/awt/GradientPaint.html) which handles that for you. – FThompson Dec 30 '12 at 18:28
  • @Vulcan quite true I was just trying to give enough basic info to solve the challenge without a code solution. Thought the exercise might be like "reverse a string... Without using (or before you've learned) the .reverse() method" – scunliffe Dec 30 '12 at 22:46

1 Answers1

3

By "gradient" they mean a color gradient, that is, a gradual transition from one color to another across a two-dimensional region.

When they say "slowly" and "as it moves", they don't mean animation; the image itself will be static. You can think of it as meaning that if your eye were to move across the region from one side to the other, you would slowly see the color change from dark to light.

That is — they want something like this:

gradient, dark on one side, light on the other

ruakh
  • 175,680
  • 26
  • 273
  • 307