# A PinwheelState is the angle of rotation for 4 pinwheels
data PinwheelState:
  | pinwheels(
      p1a :: Number,
      p2a :: Number,
      p3a :: Number,
      p4a :: Number)
end

STARTING-PINWHEELS = pinwheels(60, 3, 25, 70)

# update-pinwheel :: Number -> Number
fun update-pinwheel(angle):
  angle + 6
end

# next-state-tick :: PinwheelState -> PinwheelState
fun next-state-tick(ps):
  pinwheels(
    update-pinwheel(ps.p1a),
    update-pinwheel(ps.p2a),
    update-pinwheel(ps.p3a),
    update-pinwheel(ps.p4a))
end

# draw-pinwheel :: Number -> Image
fun draw-pinwheel(angle):
  rotate(angle, PINWHEEL-IMG)
end

# draw-state :: PinwheelState -> Image
fun draw-state(ps):
  put-image(draw-pinwheel(ps.p1a),
    400, 100,
    put-image(draw-pinwheel(ps.p2a),
      320, 240,
      put-image(draw-pinwheel(ps.p3a),
        100, 400,
        put-image(draw-pinwheel(ps.p4a),
          500, 350,
          empty-scene(640, 480)))))
end

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.