[Oberon] FPGA - Display3.Mod - porting

Tomas Kral thomas.kral at email.cz
Wed Nov 7 12:51:46 CET 2018


> I wish to port some of the drawing primitives to Oberon-7, so we could
> draw filled rectangles, polygons, ellipses, splines, etc.

Studying `Display3.Mod', code seems a way too complex, I have started
coding something simple on my own. Looking into `Curves.Mod' for
inspiration.

Circle does not use SIN(x) or COS(y) at all, how is that possible? I
have always thought we need some trigonometry to draw a circle.

Reading wiki about the concept of flood fill, I think that is needed
only for curved shapes, rectangles can be filled without flood,
correct?

Now tricky part may come with pattern filling, I remember ATARI elipse
demo, filled with Fuji logo and clipped. How to do in Oberon?  

MODULE Graph; (*Simple graph primitives, implementing fill*)
  IMPORT SYSTEM, Display := Display, O := Out, Oberon;

  PROCEDURE Circle*(col: INTEGER; x0, y0, r: LONGINT);
    VAR x, y, u: LONGINT;
  BEGIN u := 1 - r; x := r; y := 0;
    WHILE y <= x DO
      Display.Dot(col, x0+x, y0+y, Display.replace);
      Display.Dot(col, x0+y, y0+x, Display.replace);
      Display.Dot(col, x0-y, y0+x, Display.replace);
      Display.Dot(col, x0-x, y0+y, Display.replace);
      Display.Dot(col, x0-x, y0-y, Display.replace);
      Display.Dot(col, x0-y, y0-x, Display.replace);
      Display.Dot(col, x0+y, y0-x, Display.replace);
      Display.Dot(col, x0+x, y0-y, Display.replace);
      IF u < 0 THEN INC(u, 2*y+3) ELSE INC(u, 2*(y-x)+5); DEC(x) END ;
      INC(y)
    END
  END Circle;

END Graph.


-- 
Tomas Kral <thomas.kral at email.cz>


More information about the Oberon mailing list