SimonN / LixD

Lix: Lemmings-like game with puzzles, editor, multiplayer
https://www.lixgame.com
132 stars 16 forks source link

Re-shade matt/marble #245

Open SimonN opened 7 years ago

SimonN commented 7 years ago

Lix 0.9.0.

Most blocks in matt/marble were shaded with GIMP's bevel tool. This leaves 2 flat rows of pixels on the left, and 2 flat rows of pixels on the top. Blocks with fat edges look sloppy.

Re-shade the blocks.

SimonN commented 7 years ago

Here's a script that could work on rectangular blocks: It cuts off the offending rows and upscales the remainder to fill the 2 rows of void.

The script uses ImageMagick's convert and composite.

I have no good idea to automate the diagonal blocks.

#!/bin/bash

xl=$(convert "$1" -format %w info:)
yl=$(convert "$1" -format %h info:)
echo -n "\`$1' is ${xl}x${yl}"

# crop 2 rows from start and 1 row from end, in both directions.
convert "$1" \
    -crop $((xl-3))x$((yl-3))+2+2 \
    -filter Lanczos \
    -adaptive-resize $((xl-1))x$((yl-1))\! \
    oneTooSmall.png

# crop only 2 rows from start, this will be our canvas
convert "$1" \
    -crop $((xl-2))x$((yl-2)) \
    -scale ${xl}x${yl}\! \
    hardScaled.png

# print the earlier pic on the canvas
composite oneTooSmall.png hardScaled.png "$1"

rm oneTooSmall.png hardScaled.png

xl=$(convert "$1" -format %w info:)
yl=$(convert "$1" -format %h info:)
echo ", now ${xl}x${yl}."
SimonN commented 6 years ago

Example: Cutting off two rows from the left and top will improve the big Marble blocks.

Example to cut off two rows of pixels

SimonN commented 6 years ago

Better script: Cut hardScaled.png such that it keeps the bottom dark parts:

#!/bin/bash
# https://github.com/SimonN/LixD/issues/245

xl=$(convert "$1" -format %w info:)
yl=$(convert "$1" -format %h info:)
echo -n "\`$1' is ${xl}x${yl}"

# crop 2 rows from start and 1 row from end, in both directions.
convert "$1" \
    +repage \
    -crop $((xl-3))x$((yl-3))+2+2 \
    -filter Lanczos \
    -adaptive-resize $((xl-1))x$((yl-1))\! \
    oneTooSmall.png

# crop only 2 rows from start, this will be our canvas
convert "$1" \
    +repage \
    -crop $((xl-2))x$((yl-2))+2+2 \
    -scale ${xl}x${yl}\! \
    hardScaled.png

# print the earlier pic on the canvas
composite oneTooSmall.png hardScaled.png "$1"

rm oneTooSmall.png hardScaled.png

xl=$(convert "$1" -format %w info:)
yl=$(convert "$1" -format %h info:)
echo ", now ${xl}x${yl}."