Created
September 4, 2013 23:22
-
-
Save valexey/6444140 to your computer and use it in GitHub Desktop.
Oberon processing demo module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MODULE Tree; | |
IMPORT PageInit, P := Processing; | |
VAR | |
theta : REAL; | |
PROCEDURE Branch(h : REAL); | |
BEGIN | |
h := 0.66*h; | |
IF h > 2.0 THEN | |
P.PushMatrix; | |
P.Rotate(theta); | |
P.Line(0.0, 0.0, 0.0, -h); | |
P.Translate(0.0, -h); | |
Branch(h); | |
P.PopMatrix; | |
P.PushMatrix; | |
P.Rotate(-theta); | |
P.Line(0.0, 0.0, 0.0, -h); | |
P.Translate(0.0, -h); | |
Branch(h); | |
P.PopMatrix; | |
END | |
END Branch; | |
PROCEDURE Setup; | |
BEGIN | |
P.SetSize(640,360); | |
P.SetBackground(0H) | |
END Setup; | |
PROCEDURE Draw; | |
VAR | |
a : REAL; | |
BEGIN | |
P.SetBackground(0H); | |
P.SetFrameRate(30); | |
P.Stroke(0FF00FF00H); | |
a := P.MouseX/FLT(P.Width)*90.0; | |
theta := P.Radians(a); | |
P.Translate(FLT(P.Width)/2.0, FLT(P.Height)); | |
P.Line(0.0, 0.0, 0.0, -120.0); | |
P.Translate(0.0, -120.0); | |
Branch(120.0) | |
END Draw; | |
BEGIN | |
PageInit.CreateCanvas; | |
P.SetSetupProc(Setup); | |
P.SetDrawProc(Draw); | |
P.Start | |
END Tree. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment