Log In  

Cart #sesatereke-0 | 2021-10-13 | Code ▽ | Embed ▽ | No License

Someone on Twitter asked for this, and this seemed like the easiest place to share the code.

function preplace_in_circle(centerx,centery,radius,checkcol,newcol)
    local topleft={x=centerx-radius,y=centery-radius}
    local bottomright={x=centerx+radius,y=centery+radius}
    for x=topleft["x"],bottomright["x"] do
        for y=topleft["y"],bottomright["y"] do
            if (x-centerx)^2+(y-centery)^2<radius^2 then
                if (pget(x,y)==checkcol) pset(x,y,newcol)
end
end
end
end
function psetin_circle(centerx,centery,radius,checkcol,col)
    local topleft={x=centerx-radius,y=centery-radius}
    local bottomright={x=centerx+radius,y=centery+radius}
    for x=topleft["x"],bottomright["x"] do
        for y=topleft["y"],bottomright["y"] do
            if (x-centerx)^2+(y-centery)^2<radius^2 then
                 pset(x,y,col)
            end
        end
    end
end
P#98594 2021-10-13 19:01

as you may have noticed, pico cannot maintain 30fps using fullscreen pset operations.
such effect should be done using copy to memory/spritesheet and then masking with a sprite (or tline).

P#98599 2021-10-13 20:49

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 14:13:50 | 0.009s | Q:16