<> <> <> <> DIRECTORY RandomDemo, Imager, Rope, ImagerColorOperator, ImagerPixelArray, Process, RuntimeError; RandomDemoClient2: CEDAR PROGRAM IMPORTS RandomDemo, Imager, ImagerColorOperator, ImagerPixelArray, Process, Rope, RuntimeError = BEGIN anImage: ImagerPixelArray.PixelArray _ NIL; nextImage: Rope.ROPE _ NIL; imageList: LIST OF Rope.ROPE _ NIL; tempList: LIST OF Rope.ROPE _ NIL; NextImage: PROC [] = { Next: PROC [] RETURNS [name: Rope.ROPE_NIL] = { IF tempList#NIL THEN tempList _ tempList.rest; IF tempList=NIL THEN tempList _ imageList; IF tempList#NIL THEN RETURN [tempList.first] }; anImage _ NIL; FOR i: INT IN [0..RandomDemo.Rand[3]] DO nextImage _ Next[] ENDLOOP; }; SetUpImage: PROC [] = BEGIN DO name: Rope.ROPE _ NIL; pa: ImagerPixelArray.PixelArray _ NIL; Process.Pause[Process.MsecToTicks[100]]; WHILE anImage#NIL DO Process.Pause[Process.MsecToTicks[1000]] ENDLOOP; name _ nextImage; IF Rope.IsEmpty[name] THEN LOOP; pa _ ImagerPixelArray.FromAIS[name ! RuntimeError.UNCAUGHT => {pa _ NIL; CONTINUE} ]; IF pa#NIL THEN anImage _ pa; ENDLOOP END; RandomRotation: PROC[] = { RandomRotate: PROC[] = { Imager.TranslateT[RandomDemo.context, [RandomDemo.screenW/2, RandomDemo.screenH/2]]; Imager.RotateT[RandomDemo.context, RandomDemo.Rand[360]]; Imager.TranslateT[RandomDemo.context, [-RandomDemo.screenW/2, -RandomDemo.screenH/2]]; }; IF RandomDemo.Rand[5]=1 THEN RandomRotate[] }; ShowAis: PROC = BEGIN pa: ImagerPixelArray.PixelArray _ anImage; NextImage[]; IF pa#NIL THEN { RandomRotation[]; Imager.SetSampledColor[RandomDemo.context, pa, NIL, colOp]; Imager.MaskRectangle[RandomDemo.context, [0, 0, RandomDemo.screenw, RandomDemo.screenh]]; RandomDemo.Pause[1500]; }; END; IncludeImage: PROC [r: Rope.ROPE] = { IF ~Rope.IsEmpty[r] THEN imageList _ CONS[r, imageList]; }; colOp: Imager.ColorOperator _ ImagerColorOperator.GrayLinearColorModel[255.0, 0.0, 0, NIL]; IncludeImage["/Cedar/ais/NewParc.AIS"]; IncludeImage["/Cedar/ais/TheGang.AIS"]; IncludeImage["/Cedar/ais/monk.AIS"]; IncludeImage["/Cedar/ais/Doone.AIS"]; RandomDemo.Register[proc: ShowAis, time: 5000, weight: 0.5]; TRUSTED {Process.Detach[FORK SetUpImage[]]}; END.