Anonymous user
Animation: Difference between revisions
m
→{{header|Standard ML}}: shortened
(→{{header|Standard ML}}: rem. compilation) |
m (→{{header|Standard ML}}: shortened) |
||
Line 2,766:
<lang Standard ML>open XWindows ;
open Motif ;
structure TTd = Thread.Thread ;
structure TTm = Thread.Mutex ;
val bannerWindow = fn () =>
Line 2,781:
val main = XmCreateMainWindow shell "main" [ XmNmappedWhenManaged true ] ;
val canvas = XmCreateDrawingArea main "drawarea" [ XmNwidth (#tw dim), XmNheight (#th dim)] ;
val usegc = DefaultGC (XtDisplay canvas) ;
val buf = XCreatePixmap (RootWindow (XtDisplay shell)) (Area{x=0,y=0,w = #tw dim, h= (#th dim) }) 24 ;
Line 2,790:
XCopyArea buf (XtWindow canvas) usegc ( XPoint {x=00,y=0} ) (Area{x= (#tw dim) - pos ,y=0,w = pos, h= #th dim }) ;
XFlush (XtDisplay canvas) ) ;
fun shift s = ( drawparts ( s mod (#tw dim)) ; Posix.Process.sleep (Time.fromReal 0.1) ; shift ( s + (!direct)) ) ;
val swdir = fn () => direct :=
▲ val finish = fn (w,s,t) =>
▲ ( if !on <> nothr then if TTd.isActive (toThr (!on)) then TTd.kill (toThr (!on)) else () else () ;
▲ on := thr (TTd.fork (fn () => shift 0,[]) ) ; t ) ;
in
(
XtSetCallbacks canvas [ (XmNexposeCallback , setimg) ,
XtAddEventHandler canvas [ ButtonPressMask ] false (fn (w,ButtonPress a)=> movimg ()|_=> ()) ;
XtManageChild canvas ;▼
XtManageChild
XtRealizeWidget shell (* add loop here to compile *)
)
|