diff options
author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2000-04-03 07:57:36 +0000 |
---|---|---|
committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2000-04-03 07:57:36 +0000 |
commit | 151d3466468edb1ecc98d9475abc90ca14418f8f (patch) | |
tree | 30c9c43e63b0db2c27f1ab9b7fcc771fa2c4bc5c /otherlibs/labltk/example/eyes.ml | |
parent | ed84ab0c2c15dce7ea022ada7801a70825be27c7 (diff) |
change Canvas, pour des labels/ordre plus naturels
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3029 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
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; |