diff options
Diffstat (limited to 'otherlibs/labltk/example/eyes.ml')
-rw-r--r-- | otherlibs/labltk/example/eyes.ml | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/otherlibs/labltk/example/eyes.ml b/otherlibs/labltk/example/eyes.ml index 021ea700c..eaa335809 100644 --- a/otherlibs/labltk/example/eyes.ml +++ b/otherlibs/labltk/example/eyes.ml @@ -20,20 +20,22 @@ let _ = let top = openTk () in let fw = Frame.create top in pack [fw]; - let c = Canvas.create fw width: 200 height: 200 in + let c = Canvas.create width: 200 height: 200 fw in let create_eye cx cy wx wy ewx ewy bnd = - let o2 = Canvas.create_oval c + let o2 = Canvas.create_oval x1:(cx - wx) y1:(cy - wy) x2:(cx + wx) y2:(cy + wy) outline: `Black width: 7 fill: `White - and o = Canvas.create_oval c + c + and o = Canvas.create_oval x1:(cx - ewx) y1:(cy - ewy) x2:(cx + ewx) y2:(cy + ewy) - fill:`Black in + fill:`Black + c in let curx = ref cx and cury = ref cy in - bind c events:[`Motion] extend:true fields:[`MouseX; `MouseY] + bind events:[`Motion] extend:true fields:[`MouseX; `MouseY] action:(fun e -> let nx, ny = let xdiff = e.ev_MouseX - cx @@ -46,9 +48,10 @@ let _ = else e.ev_MouseX, e.ev_MouseY in - Canvas.move c tag: o x: (nx - !curx) y: (ny - !cury); + Canvas.move canvas:c x: (nx - !curx) y: (ny - !cury) o; curx := nx; cury := ny) + c in create_eye 60 100 30 40 5 6 0.6; create_eye 140 100 30 40 5 6 0.6; |