DIRECTORY Commander, Controls, Draw2d, G2dTool, Imager, ImagerColor, RealFns, Rope, VFonts, ViewerOps; G2dAnimLawsCmdImpl: CEDAR PROGRAM IMPORTS Controls, Draw2d, G2dTool, Imager, ImagerColor, RealFns, VFonts, ViewerOps ~ BEGIN G2dAnimLaws: Commander.CommandProc ~ { ViewerOps.OpenIcon[Controls.OuterViewer[ name: "Classical Animation Laws", graphicsHeight: 400, drawProc: Display, noOpen: TRUE].parent]; }; Pi: REAL ~ 3.1415926535; PiOver2: REAL ~ 0.5*Pi; Function: TYPE ~ PROC [t: REAL] RETURNS [v: REAL]; ConstantLaw: Function ~ {v ¬ t}; AccelerationLaw: Function ~ {v ¬ 1.0-RealFns.Cos[PiOver2*t]}; DecelerationLaw: Function ~ {v ¬ RealFns.Sin[PiOver2*t]}; AccThenDecLaw: Function ~ {v ¬ 0.5*(1.0-RealFns.Cos[Pi*t])}; ValueVsEffortLaw: Function ~ {v ¬ 0.5*(1.0+RealFns.Cos[Pi*t])}; Display: Controls.DrawProc ~ { color: BOOL ¬ viewer.column = color; font: Imager.Font ¬ VFonts.DefaultFont[]; DrawFunction: PROC [function: Function, label: Rope.ROPE, r, g, b: REAL ¬ 0.0] ~ { delta: REAL ~ 0.02; p1: Imager.VEC ¬ [0.0, viewer.ch*function[0.0]]; IF color THEN Imager.SetColor[context, ImagerColor.ColorFromRGB[[r, g, b]]]; FOR t: REAL ¬ delta, t+delta WHILE t <= 1.0 DO p0: Imager.VEC ¬ p1; p1 ¬ [viewer.cw*t, viewer.ch*function[t]]; Draw2d.Line[context, p0, p1]; ENDLOOP; Draw2d.Label[context, [viewer.cw*0.2-0.5*VFonts.StringWidth[label, font], viewer.ch*function[0.2]], label]; }; IF color THEN Draw2d.Clear[context, ImagerColor.ColorFromRGB[[0.5, 0.5, 0.5]]]; DrawFunction[ConstantLaw, "constant", 1.0, 0.0, 0.0]; DrawFunction[AccelerationLaw, "acceleration", 0.0, 1.0, 0.0]; DrawFunction[DecelerationLaw, "deceleration", 0.0, 0.0, 1.0]; DrawFunction[AccThenDecLaw, "acceleration then deceleration", 1.0, 1.0, 1.0]; DrawFunction[ValueVsEffortLaw, "value of this slide vs. effort", 0.0, 0.0, 0.0]; }; G2dTool.Register["AnimLaws", G2dAnimLaws, "\nDraw animation laws."]; END. Š G2dAnimLawsCmdImpl.mesa Copyright Σ 1985, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, July 20, 1992 1:06 pm PDT ΚΤ•NewlineDelimiter –"cedarcode" style™™Jšœ Οeœ6™BJ™&J˜JšΟk œ]˜fJ˜—šΠbnœžœž˜!JšžœK˜R—šœž˜J˜šΟb œ˜&˜(J˜!J˜J˜Jšœžœ ˜—J˜J˜—Jšœžœ˜Jšœ žœ ˜J˜Jš œ žœžœžœžœžœ˜2J˜JšΟn œ˜ JšŸœ.˜=JšŸœ*˜9JšŸ œ/˜<š‘œ/˜?J˜—š œ˜Jšœžœ˜$J˜)š‘ œžœ"žœ žœ ˜RJšœžœ˜Jšœ žœ"˜0Jšžœžœ?˜Lšžœžœžœ ž˜.Jšœ žœ˜J˜*J˜Jšžœ˜—J˜kJ˜—JšžœžœB˜OJ˜5J˜=J˜=J˜MJ˜PJ˜J˜—J˜DJ˜—Jšžœ˜—…—b ΐ