begin placeDot
  # Place dot in random position.
  #
  circle random(2), random(2), 1
  color "orange"
  fill
end
begin fillDots densityPercent
  clip "inside"
  stripepath 3 / (densityPercent / 100), 0
  samplepath 3 / (densityPercent / 100), 0
  placeDot
end
begin dotDensityFill densityPercent
  # Draw dots inside polygon.
  #
  fillDots densityPercent
  # Draw polygon outline
  #
  color "black"
  linestyle 0.1
  stroke
end

newpage "eps", "tutorialrand3.eps", 60, 40
clearpath
box 3, 3, 20, 38
dotDensityFill 25

clearpath
box 23, 3, 40, 38
dotDensityFill 50

clearpath
box 43, 3, 59, 38
dotDensityFill 100
