Skip to content

Instantly share code, notes, and snippets.

@valexey
Created September 4, 2013 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valexey/6444140 to your computer and use it in GitHub Desktop.
Save valexey/6444140 to your computer and use it in GitHub Desktop.
Oberon processing demo module
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