[Oberon] FPGA - Simple Graph Fill

Tomas Kral thomas.kral at email.cz
Fri Nov 9 09:31:58 CET 2018


> In short, from a given (x, y), evaluate F(x+1, y-1/2) which dictates
> wether to go East or South-East for the next pixel.

Hi,

I have this simple example, drawing a circle, and attempting to fill
it, starting off the centre.

Fill goes well east and north, and fills exactly one quadrant.
Uncommenting west south then the recursive does not stop.

GraphTest.DoCircle 11 300 200 4 ~ colour x y radius
GraphTest.DoFill 0 8 300 200 ~ target replacement x y

 col x   y
   0 300 200  east start
   0 301 200  
   0 302 200
   0 303 200
  11 304 200  east stop col # target col
   0 303 201  north start
  11 304 201  east resume
  11 303 202  north resume
   0 302 201
   0 303 201
  11 304 201
  11 303 202
.... never terminates

CONST ppw = 8; dpt = 4; bpl = dpt*128; (*pixels per word, depth, bytes
per line*)

  PROCEDURE Fill*(tgc, rpc, x, y: INTEGER);
    VAR c, a: INTEGER; (*tgc, rpc - target replacement colour*)
  BEGIN
    a := D.Base + (x DIV ppw)*4 + y*bpl;
    S.GET(a, c); c := ASR(c, -(x MOD ppw * 4)) MOD 10H;
    O.Int(c, 4); O.Int(x, 4); O.Int(y, 4); O.Ln;
    IF c = tgc THEN
      D.Dot(rpc, x, y, D.replace);
      Fill(tgc, rpc, x+1, y); (*east*)
      Fill(tgc, rpc, x, y+1); (*north*)
      (*Fill(tgc, rpc, x-1, y); (*west*)
      Fill(tgc, rpc, x, y-1); (*south*)*)
    END
  END Fill;

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


More information about the Oberon mailing list