added gif image generation

This commit is contained in:
davidovski 2021-10-31 00:31:46 +01:00
parent 83ea97d28f
commit 3a396753ef
9 changed files with 78 additions and 6 deletions

5
build.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
python gif.py
python build.py
./sync.sh

64
gif.py Normal file
View file

@ -0,0 +1,64 @@
import glob
import math
import random
from PIL import Image
def color(hex_value):
h = hex_value.lstrip('#')
while len(h) < 8:
h += "f"
return tuple(int(h[i:i+2], 16) for i in (0, 2, 4, 6))
def rgb_to_v(c):
r, g, b = c[0]/255.0, c[1]/255.0, c[2]/255.0
mx = max(r, g, b)
v = mx*100
return v
replace = color("#f58f44")
colors = [
color("#191919"),
color("#282a2e"),
color("#373b41"),
color("#f58f44")
]
sorted(colors, key=rgb_to_v)
p = len(colors)
def make(filename, inp=None):
w = int(256 / p) * p
h = int(256 / p) * p
frames = []
for i in range(int(p*1*math.pi)):
if inp is None:
image = Image.new("RGBA", (w, h), colors[0])
else:
image = Image.open(inp)
for x in range(image.width):
for y in range(image.height):
f = 2
r = random.randint(-f, f)
z = (i) - (y/(p/4)) + r
v = math.floor( (math.sin(z) + 1) * len(colors) * 0.5)
c = colors[v]
if inp is not None:
existing = image.getpixel((x, y))
if existing == replace:
image.putpixel((x,y), c)
else:
image.putpixel((x,y), c)
frames.append(image)
frames[0].save(filename, format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0)
make("images/bg.gif")
make("images/remotecontrol.gif", inp="images/remotecontrol.png")

View file

@ -1,5 +1,6 @@
https://git.davidovski.xyz/davidovski.git
https://git.davidovski.xyz/xibuild.git
https://git.davidovski.xyz/xilinux/xibuild.git
https://git.davidovski.xyz/xilinux/xipkg.git
https://git.davidovski.xyz/dot.git
https://github.com/davidovski/glsl-mandelbrot.git
https://github.com/davidovski/dungeon-generator.git

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 KiB

After

Width:  |  Height:  |  Size: 229 KiB

BIN
images/remotecontrol.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -23,9 +23,9 @@ body {
background-color: var(--bg-light);
background-image: url("/images/bg.gif");
background-repeat: repeat;
background-attachment: fixed;
/*background-image: url("https://davidovski.xyz/images/bg.png");*/
background-position: absolute;
color: var(--fg);
font-family: mononoki;
font-size: 16px;
@ -38,6 +38,11 @@ a {
text-decoration: none;
}
a:hover {
color: var(--cyan);
text-decoration: underline;
}
h1 {
color: var(--white);
}

View file

@ -1,8 +1,5 @@
#!/bin/bash
python build.py
rsync -Lta --no-perms --no-owner --no-group --delete --exclude=sync.sh -z -e ssh ./html/ cheetah:/srv/www/davidovski/html
ssh -t cheetah "ln -s /srv/shared/site/* /srv/www/davidovski/html/"
# git push # push after everything to keep it all backed up

View file

@ -7,7 +7,7 @@
<p>if you want to contact me, you can message me on matrix <code>@davidovski:matrix.org</code> (i will make my own homeserver soon ok?) or discord <code>iksvo#6239</code>. I'll be also happy to reply to any emails, linked at the top of the page</p>
</div>
<div class="image">
<img src="/images/remotecontrol.png">
<img src="/images/remotecontrol.gif">
</div>
</div>
<hr>