Code: Select all
// input params
pixel_size = 2
treshold = 128 //lower value - brighter output and vice versa
// end of input params
img = load_pixi( "crikey.gif" ) // put your animated gif here or any picture
in_width = get_pixi_xsize (img)
ih_height = get_pixi_ysize (img)
xsize = in_width * pixel_size
ysize = ih_height * pixel_size
hx = xsize / 2
hy = ysize / 2
resize_pixi( 0, xsize, ysize )
//video_export_gif("animated_out.gif")
start:
clear( BLACK )
pixi( img, 0, 0, pixel_size, 0)
y = -hy
while( y < hy )
{
x = -hx
while( x < hx )
{
col = get_dot (x,y)
red = get_red (col)
grn = get_green (col)
blu = get_blue (col)
L = red * red * 241/1000 + grn * grn * 691/1000 + blu * blu * 68/1000 // calculating percieved brightness of a color
sqrt
if rslt>treshold
{
fbox (x,y,pixel_size,pixel_size,WHITE)
}
else
{
fbox (x,y,pixel_size,pixel_size,BLACK)
}
x=x+pixel_size
}
y=y+pixel_size
}
frame( 25 )
go start
sqrt:
rslt = L
div = L
if L <= 0 { ret }
while (1){
div = (L / div + div) / 2
if rslt > div { rslt = div }
else { ret }
}
ret