It would be nice to add some color to our images. No surprises that Doodle has methods to do just this. In addition to layout, Doodle has some simple operators to add a splash of colour to our images. Try these out the methods described in Table pictures:color to see how they work.
fillColorfills the image with the given color. Example:
strokeColoroutlines the image with the given color. Example:
strokeWidthsets the width of the image outline. Example:
noFillremoves any fill from the image. Example:
noStrokeremoves any stroke from the image. Example:
Doodle has various ways of creating colours.
The simplest are the predefined colours on
We use these colors by writing
Color.blue, and so on.
Here is a small example illustrating these methods in action.
Image .circle(100) .fillColor(Color.wheat) .strokeColor(Color.midnightBlue) .strokeWidth(7)
Exercise: Evil Eye
Make the image in Figure pictures:evil-eye, designed to look like a traditional amulet protecting against the evil eye. I used
cornflowerBlue for the iris, and
darkBlue for the outer color, but experiment with your own choices!
Here's my amulet:
Image .circle(30) .fillColor(Color.black) .on(Image.circle(60).fillColor(Color.cornflowerBlue)) .on(Image.circle(90).fillColor(Color.white)) .on(Image.circle(150).fillColor(Color.darkBlue))