Exercises

Compilation Target

Create a line drawing of an archery target with three concentric scoring bands, as shown in Figure pictures:target1.

Simple archery target

For bonus credit add a stand so we can place the target on a range, as shown in Figure pictures:target2.

Archery target with a stand

<div class="solution"> The simplest solution is to create three concentric circles using the on method:

Image
  .circle(20)
  .on(Image.circle(40))
  .on(Image.circle(60))

For the extra credit we can create a stand using two rectangles:

Image
  .circle(20)
  .on(Image.circle(40))
  .on(Image.circle(60))
  .above(Image.rectangle(6, 20))
  .above(Image.rectangle(20, 6))

</div>

Stay on Target

Colour your target red and white, the stand in brown (if applicable), and some ground in green. See Figure pictures:target3 for an example.

Colour archery target

<div class="solution"> The trick here is using parentheses to control the order of composition. The fillColor(), strokeColor(), and strokeWidth() methods apply to a single image---we need to make sure that image comprises the correct set of shapes:

Image
  .circle(20).fillColor(Color.red)
  .on(Image.circle(40).fillColor(Color.white))
  .on(Image.circle(60).fillColor(Color.red))
  .above(Image.rectangle(6, 20).fillColor(Color.brown))
  .above(Image.rectangle(20, 6).fillColor(Color.brown))
  .above(Image.rectangle(80, 25).noStroke.fillColor(Color.green))

</div>

Images→