[Oberon] PO2013 - Simple Arc

Tomas Kral thomas.kral at email.cz
Fri Jun 26 11:23:51 CEST 2020


Hi,

Just revising `Arc' procedure in simple graph, I have coded this. In
fact it just draws quarter circle, based on +/- hint, not sure if good idea.

I do not need exact RAD segments, that would probably require Math trigo, but wish to somehow get it better if
possible.

  PROCEDURE Arc*(col, x0, y0, r, mode: INTEGER);
    VAR x, y, sx, sy, u: INTEGER;
  BEGIN u := 1 - r; x := r; y := 0; sx := 1; sy := 1;
  IF x0 < 0 THEN sx := -1 END ; x0 := ABS(x0);
    IF y0 < 0 THEN sy := -1 END ; y0 := ABS(y0);
    WHILE y <= x DO
      IF (sx > 0) & (sy > 0) THEN
        Dot(col, x0+x, y0+y, mode);
        Dot(col, x0+y, y0+x, mode)
      ELSIF (sx < 0) & (sy > 0) THEN
        Dot(col, x0-y, y0+x, mode);
        Dot(col, x0-x, y0+y, mode)
      ELSIF (sx < 0) & (sy < 0) THEN
        Dot(col, x0-x, y0-y, mode);
        Dot(col, x0-y, y0-x, mode)
      ELSE (*(sx > 0) & (sy < 0)*)
        Dot(col, x0+y, y0-x, mode);
        Dot(col, x0+x, y0-y, mode)
      END ;
      IF u < 0 THEN INC(u, 2*y+3) ELSE INC(u, 2*(y-x)+5); DEC(x) END ;
      INC(y)
    END
  END Arc;

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


More information about the Oberon mailing list