Created
August 18, 2023 14:24
-
-
Save villares/67c4f95f4c863a6115db7c50f477cd1b to your computer and use it in GitHub Desktop.
Export PNG with transparent background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using py5 imported mode (https://py5coding.org to learn more) | |
def setup(): | |
size(600, 600) # drawing size | |
output_canvas = create_graphics(width, height) | |
background(255, 0, 0) # you can turn this off, this won't be recorded! | |
begin_record(output_canvas) # starts recording | |
# output_canvas.clear() # clears pixels (not necessary in this case) | |
color_mode(HSB) # this needs to be inside the recording! | |
no_stroke() # same as with the color_mode, has to be brought here | |
w = 60 | |
for j in range(10): | |
y = w / 2 + j * w | |
for i in range(10): # 0, 1, 2, ... 9 | |
x = w / 2 + i * w | |
d = random(10, w) | |
fill(d * 3, 255, 255) | |
circle(x + random(-15, 15), | |
y + random(-15, 15), d) | |
end_record() # end recording | |
output_canvas.save(f'out.png', drop_alpha=False) |
Author
villares
commented
Aug 18, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment