Added script for generating screenshots

This commit is contained in:
1deterministic 2019-07-11 13:48:59 -03:00
parent 5d7511a69c
commit 7a89a0fd94
2 changed files with 90 additions and 5 deletions

View file

@ -3,7 +3,6 @@
build=./build
color_schemes=./color-schemes
if [ ! -d $build ]; then
mkdir $build
fi
@ -12,13 +11,17 @@ for i in $color_schemes/*;
do
for f in $i/*;
do
[ -d $f ] && $(
name=$(basename $f)-$(basename $(dirname $f))
if [ -d $f ]; then
(name=$(basename $f)-$(basename $(dirname $f))
if [ ! -d $build/$name ]; then
mkdir $build/$name
fi
if [ ! -d $build/$name/screenshots ]; then
mkdir $build/$name/screenshots
fi
cp $f/background.png $build/$name &&
cp $f/box.png $build/$name &&
cp $f/bullet.png $build/$name &&
@ -28,8 +31,10 @@ do
cp $f/progress-bar.png $build/$name &&
cp $f/progress-box.png $build/$name &&
sed "s/::NAME::/$name/g" plymouth > $build/$name/$name.plymouth &&
cat script > $build/$name/$name.script
)
cat script > $build/$name/$name.script &&
python3 -B ./create-screenshots.py --path=$build/$name) || exit 1
fi
done;
done;

80
create-screenshots.py Normal file
View file

@ -0,0 +1,80 @@
from PIL import Image
import os
import sys
SCREENSHOTS_FOLDER = "screenshots"
def create_screenshots(path, resolutions):
color_scheme = {
"background": Image.open(os.path.join(path, "background.png")).convert("RGBA"),
"logo": Image.open(os.path.join(path, "logo.png")).convert("RGBA"),
"progress-bar": Image.open(os.path.join(path, "progress-bar.png")).convert("RGBA"),
"progress-box": Image.open(os.path.join(path, "progress-box.png")).convert("RGBA"),
"box": Image.open(os.path.join(path, "box.png")).convert("RGBA"),
"entry": Image.open(os.path.join(path, "entry.png")).convert("RGBA"),
"lock": Image.open(os.path.join(path, "lock.png")).convert("RGBA"),
"bullet": Image.open(os.path.join(path, "bullet.png")).convert("RGBA")
}
for r in resolutions:
x = r["width"]
y = r["height"]
background_x = 0
background_y = 0
logo_x = (x // 2) - (color_scheme["logo"].size[0] // 2)
logo_y = (y // 2) - (color_scheme["logo"].size[1] // 2)
progress_box_x = (x // 2) - (color_scheme["progress-box"].size[0] // 2)
progress_box_y = int(y * 0.65) - (color_scheme["progress-box"].size[1] // 2)
progress_bar_x = (x // 2) - (color_scheme["progress-box"].size[0] // 2)
progress_bar_y = int(y * 0.65) - (color_scheme["progress-box"].size[1] // 2)
box_x = (x // 2) - (color_scheme["box"].size[0] // 2)
box_y = int(4 * y / 5) - (color_scheme["box"].size[1] // 2)
lock_x = box_x + (color_scheme["box"].size[0] // 2) - ((color_scheme["lock"].size[0] + color_scheme["entry"].size[0]) // 2)
lock_y = box_y + (color_scheme["box"].size[1] // 2) - (color_scheme["lock"].size[0] // 2)
entry_x = lock_x + color_scheme["lock"].size[0]
entry_y = box_y + (color_scheme["box"].size[1] // 2) - (color_scheme["entry"].size[1] // 2)
bullet_y = entry_y + (color_scheme["entry"].size[1] // 2) - (color_scheme["bullet"].size[1] // 2)
image = Image.new("RGBA", (x, y))
image.paste(color_scheme["background"].resize((x, y)), (0, 0), color_scheme["background"].resize((x, y)))
image.paste(color_scheme["logo"], (logo_x, logo_y), color_scheme["logo"])
image.paste(color_scheme["progress-box"], (progress_box_x, progress_box_y), color_scheme["progress-box"])
image.paste(color_scheme["progress-bar"].resize((color_scheme["progress-bar"].size[0] // 2, color_scheme["progress-bar"].size[1])), (progress_bar_x, progress_bar_y), color_scheme["progress-bar"].resize((color_scheme["progress-bar"].size[0] // 2, color_scheme["progress-bar"].size[1])))
image.save(os.path.join(path, SCREENSHOTS_FOLDER, f"{x}x{y}.png"))
image.paste(color_scheme["box"], (box_x, box_y), color_scheme["box"])
image.paste(color_scheme["lock"], (lock_x, lock_y), color_scheme["lock"])
image.paste(color_scheme["entry"], (entry_x, entry_y), color_scheme["entry"])
for i in range(0, 10):
image.paste(color_scheme["bullet"], (entry_x + (i * color_scheme["bullet"].size[0]), bullet_y), color_scheme["bullet"])
image.save(os.path.join(path, SCREENSHOTS_FOLDER, f"{x}x{y}-encrypted.png"))
if __name__ == "__main__":
path = ""
resolutions = [
{"width": 1024, "height": 768},
{"width": 1280, "height": 720},
{"width": 1360, "height": 768},
{"width": 1366, "height": 768},
{"width": 1600, "height": 900},
{"width": 1920, "height": 1080},
{"width": 2560, "height": 1080},
{"width": 2560, "height": 1440},
{"width": 3840, "height": 2160}
]
# find args
for arg in sys.argv[1:]:
if arg.startswith("--path="):
path = arg.replace("--path=", "")
# validate args
if not os.path.isdir(path):
print(f"Error: {path} is not a valid path")
exit(0)
print(f"Creating screenshots for {path}")
create_screenshots(path, resolutions)