Log In  
Follow
JehtBlack
[ :: Read More :: ]

Apologies if this is a duplicate, I'm new to the forums and couldn't find anything similar when searching.

I was making some centred variants of graphics functions and found that omitting the colour parameter would result in the pen colour being set to black

I've broken it down so you can use the following snippet to observe the issue (pico-8 0.2.3)

function pen_col()
 return peek(0x5f25)&0xf
end

cls(1)
color() -- reset pen colour

print("default colour",0,0)
assert(pen_col()==6)

print("nil produces black",0,6,nil)
assert(pen_col()==0)

print("draw state is now black",0,12)
assert(pen_col()==0)

color() -- reset pen colour
_c=nil
print("colour parameter containing nil is black",0,18,_c)
assert(pen_col()==0)

color() -- reset pen colour
print("back to default colour",0,24)
assert(pen_col()==6)

In my usage this means that if I wrap for example print, I'll want to forward the colour value, but allow for it to be omitted, in order to work around the bug I have to read the current pen colour from the draw state to prevent draw state defaulting to black.

I'd consider this a bug since passing nil colour should behave the same as omitting the colour parameter from the built in draw functions.

P#98821 2021-10-18 17:52

Follow Lexaloffle:          
Generated 2024-04-19 18:07:08 | 0.061s | Q:6