Skip to content

Commit

Permalink
refactor(create-pointer.sh): streamline if-then syntax and loop synta…
Browse files Browse the repository at this point in the history
…x for readability

feat(create-pointer.sh): modify arrow image to include an ellipse at the base for better visual representation
The if-then syntax and the loop syntax have been streamlined to improve readability and maintainability of the code. The arrow image has been modified to include an ellipse at the base, which provides a better visual representation of the pointer.
  • Loading branch information
robinmordasiewicz committed Nov 27, 2023
1 parent 7441da9 commit 9abc96e
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 50 deletions.
Binary file removed 225-arrow.png
Binary file not shown.
Binary file removed 315-arrow.png
Binary file not shown.
100 changes: 50 additions & 50 deletions create-pointer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,72 @@
#

outputfolder="docs/img/overlays"
if [[ ! -d "$outputfolder" ]]
then
mkdir -p "$outputfolder"
if [[ ! -d "$outputfolder" ]]; then
mkdir -p "$outputfolder"
fi

# Create base arrow image
convert -size 72x384 \
xc:transparent \
-strokewidth 0 \
-stroke red \
-fill red \
-draw "polygon 36,4 4,76 27,65 27,380 45,380 45,65 68,76" \
-draw "ellipse 36,371 9,9 0,360" \
-draw "polygon 36,4 4,76 27,65 27,371 45,371 45,65 68,76" \
${outputfolder}/pointer.png

width=10
wfact=$((1000 * width))
depth=40
icontr=$(convert xc: -format "%[fx:(0.5*$depth-100)]" info:)

for entry in 0 45 90 135 180 225 270 315
do
# Rotate the pointer
convert -rotate ${entry} -background 'rgba(0,0,0,0)' ${outputfolder}/pointer.png ${outputfolder}/pointer-${entry}.png
for entry in 0 45 90 135 180 225 270 315; do
# Rotate the pointer
convert -rotate ${entry} -background 'rgba(0,0,0,0)' ${outputfolder}/pointer.png ${outputfolder}/pointer-${entry}.png

# Add the bezel
convert ${outputfolder}/pointer-${entry}.png -bordercolor none -border 10x10 -write mpr:img \
-alpha extract -write mpr:alpha \
+level 0,1000 -white-threshold 999 \
-morphology Distance:-1 Euclidean:$width,1000 -level 0,"$wfact" \
-shade 120x45 -auto-level -brightness-contrast 0,"$icontr" \
\( +clone -fill "gray(50%)" -colorize 100% \) +swap \( mpr:alpha -threshold 0 \) \
-compose over -composite \
\( mpr:img -alpha off \) +swap -compose hardlight -composite \
mpr:alpha -alpha off -compose copy_opacity -composite \
-shave 10x10 \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
# Add the bevel
convert ${outputfolder}/pointer-${entry}.png -bordercolor none -border 10x10 -write mpr:img \
-alpha extract -write mpr:alpha \
+level 0,1000 -white-threshold 999 \
-morphology Distance:-1 Euclidean:$width,1000 -level 0,"$wfact" \
-shade 120x45 -auto-level -brightness-contrast 0,"$icontr" \
\( +clone -fill "gray(50%)" -colorize 100% \) +swap \( mpr:alpha -threshold 0 \) \
-compose over -composite \
\( mpr:img -alpha off \) +swap -compose hardlight -composite \
mpr:alpha -alpha off -compose copy_opacity -composite \
-shave 10x10 \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png

# Add a white border
convert ${outputfolder}/pointer-${entry}.png \
-bordercolor none -border 20 \
\( -clone 0 -fill white -colorize 100 \) \
\( -clone 0 -alpha extract -write mpr:alpha -morphology edgeout disk:2 \) \
-alpha off -compose over -composite \
\( mpr:alpha -morphology dilate disk:2 \) \
-alpha off -compose copy_opacity -composite \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
# Add a white border
convert ${outputfolder}/pointer-${entry}.png \
-bordercolor none -border 20 \
\( -clone 0 -fill white -colorize 100 \) \
\( -clone 0 -alpha extract -write mpr:alpha -morphology edgeout disk:2 \) \
-alpha off -compose over -composite \
\( mpr:alpha -morphology dilate disk:2 \) \
-alpha off -compose copy_opacity -composite \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png

# Add a black border
convert ${outputfolder}/pointer.png \
-bordercolor none -border 20 \
\( -clone 0 -fill black -colorize 100 \) \
\( -clone 0 -alpha extract -write mpr:alpha -morphology edgeout disk:1 \) \
-alpha off -compose over -composite \
\( mpr:alpha -morphology dilate disk:1 \) \
-alpha off -compose copy_opacity -composite \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
# Add a black border
convert ${outputfolder}/pointer-${entry}.png \
-bordercolor none -border 20 \
\( -clone 0 -fill black -colorize 100 \) \
\( -clone 0 -alpha extract -write mpr:alpha -morphology edgeout disk:1 \) \
-alpha off -compose over -composite \
\( mpr:alpha -morphology dilate disk:1 \) \
-alpha off -compose copy_opacity -composite \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png

# Add the drop shadow
convert ${outputfolder}/pointer-${entry}.png \
\( +clone -background black -shadow 50x10+10+10 \) \
+swap \
-background none \
-layers merge \
+repage \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
# Add the drop shadow
convert ${outputfolder}/pointer-${entry}.png \
\( +clone -background black -shadow 50x10+10+10 \) \
+swap \
-background none \
-layers merge \
+repage \
tmp.png
mv tmp.png ${outputfolder}/pointer-${entry}.png
done
Binary file added docs/img/overlays/pointer-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer-135.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer-180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer-225.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer-270.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer-315.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer-45.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer-90.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/overlays/pointer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed github-fork-border.png
Binary file not shown.
Binary file removed github-profile-border.png
Binary file not shown.

0 comments on commit 9abc96e

Please sign in to comment.