logo linethick = 0.5
set drawcolor = "teal"

repeat untilbreak [     // repeat once for every bottle ...
  clear
  pointlist clearall
  logo linecolor = "lightgray"
  pu; moveto center 0; pd; moveto center winhigh  // make the center line...

  message "Click with mouse several times.\nThen click on 'Generate' when done." "Generate|Colors etc.|Quit"

  // let user click to define some points...
  set first = yes
  pointlist startcapture
  pu
  repeat untilbreak [
    getkey
    set k = whichkey
    if :k = "Generate" or :k = "Quit" [ break ]
    elseif :k = "colors etc." [
      set drawcolor = colorchoice "Select a line color"
      logo backcolor = colorchoice "Select a background color"
      logo linethick = buttonchoice "Select a line thickness" "0.5|1|2|3|4|5|8|12"
      samemessage
      continue
      ]
    moveto whereclick
    if :first = yes [ pd; set first = no ]
    ]
  pointlist endcapture
  pu
  if :k = "Quit"  [ break ]
  if pointlist size < 1 [ continue ]  // no points 

  // generate side curve..
  pointlist startcapture
  pointlist curvefill
  pointlist endcapture

  // do a dotfill to even things out..
  pointlist startcapture
   pointlist dotfill 12
  pointlist endcapture

  // now for every point in curve, generate an ellipse around the center line...
  // the width of each ellipse is controlled by a point on the side curve..
  clear
  set npts = pointlist size
  set i = 1
  logo linecolor = :drawcolor
  repeat :npts [
    set px = pointx :i
    set py = pointy :i
    if :px > center [ set ewide = calc :px - center ]
    else [ set ewide = calc center - :px ]
    set ehigh = calc :ewide * 0.3
    moveto center :py
    pd
    ellipse :ewide :ehigh
    pu
    incr i by 1
    ]

  repeat untilbreak [
    set k = buttonchoice "Done." "Start another|Print|Quit"
    if :k = "Quit" [ break ]
    elseif :k = "Print" [ printpicture ]
    else [ break ]
    ]
  if :k = "Quit" [ break ]
  ]
