Forum
Filling drawings - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: Filling drawings (/showthread.php?tid=2607)



Filling drawings - baltasarq - 02-07-2025

There's no function or command "fill", allowing to pass two coordinates and making the computer to fill all delimited pixels with the current color.


Code:
circle 50, 50, 30
fill 50, 50

In the eighties, I used to fill a circle with a for loop:


Code:
circle 50, 50, 30
for i = 1 to 30
    circle 50, 50, i
next i
I suppose I could do something like this for rectangles, as well. This is, however, slow, ugly (certain pixels remain unplotted), and clumsy. Is there an alternate way?
Thanks,


RE: Filling drawings - boriel - 02-08-2025

There is a Fill library. Which actually fills a Drawing using a UDG pattern (not only solid).

See an example here:

https://github.com/boriel-basic/zxbasic/blob/main/examples/spfill.bas 

To use UDG you have either to compile with --sinclair or do POKE UInteger 23672, <address of UDG>

There is a thread about this routine here:
https://www.boriel.com/forum/showthread.php?tid=439


RE: Filling drawings - baltasarq - 02-08-2025

> boriel' Wrote:> There is a Fill library. Which actually fills a Drawing using a UDG pattern (not only solid).

Great!
I looked up the wiki but didn't find anything. I guess I could've looked it up in the forum...

My next question is.., what if you just want solid filling? Do you still have to provide an address to an UDG?

Thanks,



RE: Filling drawings - boriel - 02-09-2025

Yes, define it with 255 (all eight bytes). Since this CHAR already exist in the ROM, you can use a simple
POKE to use that char.