Anonymous user
ALGOL 68/prelude/graph 2d.a68: Difference between revisions
m
rename some objects
(A simple tookit for producing basic 2d graphs available for various RC tasks) |
m (rename some objects) |
||
Line 17:
INT axis 2d = 2, axis 3d = 3, flex axis = 0;
MODE NOARG=BITS; # required when partial parameterisation is not supported #
MODE POINT = [axis 2d]GREAL;
Line 90:
);
# A crude CLASS declaration #
MODE GRAPHDD = STRUCT (
PROC(NOARG)
WINDOW window,
GREAL border,
Line 104 ⟶ 105:
MODE CURVE = UNION(GENPOINT, []POINT, FUNCTIONINTERVAL);
MODE
PROC (NOARG)REF GRAPHDD init,
PROC (LINEOPTION #options#)VOID begin options,
Line 119 ⟶ 120:
);
OP
GREAL zoom = 1;
Line 127 ⟶ 128:
# Bind the Attributes to the Instance #
PROC
PROC init of graph 2d = (REF GRAPHDD self, NOARG skip)REF GRAPHDD: (
title OF self := sub title OF self := EMPTY;
Line 216 ⟶ 217:
# label x axis axis #
point := (pan and zoom OF (
draw move (window, label start, point[y axis]-pan);
draw text (window, "c", "c", (label OF axis OF self)[x axis] ORELSE "X Axis");
Line 224 ⟶ 225:
# draw x axis axis #
point := (pan and zoom OF (
draw line point (window, point);
draw move (window, point[x axis], point[y axis]-pan);
Line 230 ⟶ 231:
# label y axis axis #
point := (pan and zoom OF (
draw text angle (window, 90);
draw move (window, point[x axis]-pan, label start);
Line 239 ⟶ 240:
# draw y axis axis #
draw move point(window, point);
point := (pan and zoom OF (
draw line point(window, point);
draw move (window, point[x axis]-pan, point[y axis]);
Line 255 ⟶ 256:
draw device (window, type OF window OF self, sprintf(($g(0)"x axis"g(0)$, pixels OF window OF self)));
(init pan and zoom OF (
(decorate OF (
);
Line 263 ⟶ 264:
BOOL first := TRUE;
POINT prev specimen;
(begin options OF (
#FOR POINT point IN # gen point #DO#(
## (POINT point)VOID: (
POINT next specimen = (pan and zoom OF (
IF UPB next specimen = 2 AND FALSE THEN # simple case: the single line #
IF first THEN first := FALSE; draw move point ELSE draw line point FI (window, next specimen)
Line 281 ⟶ 282:
FI
# OD#));
(end options OF (
);
Line 287 ⟶ 288:
PROC gen curve = (YIELDPOINT yield)VOID:
FOR i TO UPB curve DO yield(curve[i]) OD;
(add curve gen point OF (
);
Line 300 ⟶ 301:
OD
);
(add curve gen point OF (
),
PROC add curve of graph 2d = (REF GRAPHDD self, CURVE curve, LINEOPTION option)VOID:(
CASE curve IN
(GENPOINT gen): (add curve gen point OF (
([]POINT array): (add curve array point OF (
(FUNCTIONINTERVAL function interval): (add curve function interval OF (
OUT
raise undefined("add curve type")
Line 321 ⟶ 322:
OP INIT = (REF GRAPHDD object)REF GRAPHDD: init of graph 2d(object,~);
SKIP</lang>
|