[Oberon] SystemV - Simple Graph

Jörg Straube joerg.straube at iaeth.ch
Tue Mar 5 16:13:08 CET 2019


Either you keep Line() as is, as Line() normally falls back to ReplConst() in case of horizontal or vertical lines. Or you replace Line() diectly by ReplConst(). In your example that‘s not too difficult.. Just try.
Jörg

> Am 05.03.2019 um 15:24 schrieb Tomas Kral <thomas.kral at email.cz>:
> 
> Hi,
> 
> Currently pursuing the idea of `Ellipse Solid Fill'.
> I borrow this algo, believe is Bresenham, and use two pairs
> of horizontal lines.
> 
>  PROCEDURE Ellipse*(col, x0, y0, a, b, mode: INTEGER);
>    VAR x, y, y1, aa, bb, d, g, h: INTEGER;
>  BEGIN aa := a*a; bb := b*b;
>    h := (aa DIV 4) - b*aa + bb; g := (9*aa DIV 4) - 3*b*aa + bb; x := 0; y := b;
>    WHILE g < 0 DO
> 
>      (*Dots - Bresenham algo*)
>      (*D.Dot(col, x0+x, y0+y, mode);
>      D.Dot(col, x0-x, y0+y, mode);
>      D.Dot(col, x0-x, y0-y, mode);
>      D.Dot(col, x0+x, y0-y, mode);*)
> 
>      (*Fills - TODO replace with ReplConst() and optimise*)
>      Line(col, x0-x, y0+y, x0+x, y0+y, mode);
>      Line(col, x0-x, y0-y, x0+x, y0-y, mode);
> 
>      IF h < 0 THEN d := (2*x+3)*bb; INC(g, d)
>      ELSE d := (2*x+3)*bb - 2*(y-1)*aa; INC(g, d + 2*aa); DEC(y)
>      END ;
>      INC(h, d); INC(x)
>    END ;
>    y1 := y; h := (bb DIV 4) - a*bb + aa; x := a; y := 0;
>    WHILE y <= y1 DO
> 
>      (*Dots - Bresenham algo*)
>      (*D.Dot(col, x0+x, y0+y, mode);
>      D.Dot(col, x0-x, y0+y, mode);
>      D.Dot(col, x0-x, y0-y, mode);
>      D.Dot(col, x0+x, y0-y, mode);*)
> 
>      (*Fills - TODO replace with ReplConst() and optimise*)
>      Line(col, x0-x, y0+y, x0+x, y0+y, mode);
>      Line(col, x0-x, y0-y, x0+x, y0-y, mode);
> 
>      IF h < 0 THEN INC(h, (2*y+3)*aa) ELSE INC(h, (2*y+3)*aa - 2*(x-1)*bb); DEC(x) END ;
>      INC(y)
>    END
>  END Ellipse;
> 
> I feel up to replacing `Line' with `ReplConst', but cannot optimise
> further. I have got this nice algo for Circle from Joerg (gladly keeping similar algos from the list on file), looking for simplicity.
> 
>  PROCEDURE CircleFill*(col, x0, y0, r, mode: INTEGER);
>    VAR x, y, r2, lim: INTEGER;
>  BEGIN r2 := r*r;
>    FOR y := 0 TO r DO
>      lim := r2 - y*y; x := 0; WHILE x*x <(*[=]*) lim DO INC(x) END;
>      D.ReplConst(col, x0-x, y0+y, 2*x, 1, mode);
>      D.ReplConst(col, x0-x, y0-y, 2*x, 1, mode)
>    END
>  END CircleFill;
> 
> Many thanks.
> 
> -- 
> Tomas Kral <thomas.kral at email.cz>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list