Skip to content

Commit 1834d3e

Browse files
Merge pull request #13 from mayTermux/dev
Awesomeshot: Gradient Border Color v.1.1.0
2 parents 13a20a4 + aaca776 commit 1834d3e

File tree

3 files changed

+192
-11
lines changed

3 files changed

+192
-11
lines changed

awesomeshot

+126-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Copyright (c) 2021 - 2022 xShin
77

8-
version=1.0.9
8+
version=1.1.0
99

1010
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-${HOME}/.config}
1111
config_file="${XDG_CONFIG_HOME}/awesomeshot/awesomeshot.conf"
@@ -138,18 +138,62 @@ first_border_color="${hex_color[0]}"
138138
# NOTE: make sure this value is small, otherwise it will look weird
139139
first_border_size=7
140140
141+
# This variable serves to convert tiny first border (background image) when editing the image,
142+
# change this value to blank or whatever for disable convert and "yes" for enable function
143+
convert_first_border=""
144+
145+
# This variable serves to set tiny first border color (background image), change this value
146+
# to "none" for transparent background, if you want to custom the color, you can
147+
# change this value with hex color or use the one in the array list.
148+
first_border_color="${hex_color[0]}"
149+
150+
# This variable serves to set how many size of the first border
151+
# NOTE: make sure this value is small, otherwise it will look weird
152+
first_border_size=7
153+
141154
# This variable serves to convert border (background image) when editing the image,
142155
# change this value to blank or whatever for disable convert and "yes" for enable function
143156
convert_second_border="yes"
144157
145158
# This variable serves to set border color (background image), change this value
146159
# to "none" for transparent background, if you want to custom the color, you can
147160
# change this value with hex color or use the one in the array list.
148-
second_border_color="${hex_color[0]}"
161+
# NOTE: if convert_second_border enable and second_border_color value not none
162+
# will be conflict
163+
#second_border_color="${hex_color[0]}"
164+
second_border_color="none"
149165
150166
# This variable serves to set how many size of the second border
151167
second_border_size=50
152168
169+
# This variable serves to convert border with gradient color,
170+
# change this value to blank or whatever for disable convert and "yes" for enable function
171+
convert_second_border_gradient="yes"
172+
173+
# This variable serves to convert gradient color method
174+
# More information: https://legacy.imagemagick.org/Usage/misc/
175+
# List available method:
176+
# - saddle
177+
# - mesh
178+
interpolate_method="saddle"
179+
180+
second_border_gradient_color=(
181+
"#C850C0"
182+
"#FFCC70"
183+
"#4158D0"
184+
"#FE7FAA"
185+
)
186+
187+
saddle_color_top_left="${second_border_gradient_color[0]}"
188+
saddle_color_top_right="${second_border_gradient_color[1]}"
189+
saddle_color_bottom_left="${second_border_gradient_color[2]}"
190+
saddle_color_bottom_right="${second_border_gradient_color[0]}"
191+
192+
mesh_color_top_left="${second_border_gradient_color[1]}"
193+
mesh_color_top_right="${second_border_gradient_color[1]}"
194+
mesh_color_bottom_left="${second_border_gradient_color[3]}"
195+
mesh_color_bottom_right="${second_border_gradient_color[3]}"
196+
153197
# This variable serves to convert the shadow of image, change this value
154198
# to blank or whatever for disable function and "yes" for enable function.
155199
convert_shadow="yes"
@@ -213,8 +257,9 @@ footer_background="none"
213257
open_image=""
214258
EOF
215259

216-
# init file_name
260+
# init
217261
file_name=""
262+
interpolate_file_name=""
218263

219264
function getUserConfig() {
220265

@@ -230,6 +275,8 @@ function getUserConfig() {
230275

231276
fi
232277

278+
checkConfig
279+
233280
}
234281

235282
function generateDefaultConfig() {
@@ -337,6 +384,10 @@ function autoRun() {
337384
if [ "${convert_second_border}" == "yes" ]; then
338385
convertSecondBorder
339386
fi
387+
388+
if [ "${convert_second_border_gradient}" == "yes" ]; then
389+
convertSecondBorderGradient
390+
fi
340391

341392
if [ "${convert_footer}" == "yes" ]; then
342393
convertFooter
@@ -514,7 +565,7 @@ function convertTitleBar(){
514565
}
515566

516567
function convertTitleBarText() {
517-
subtitle "[+]*Set*Title*Bar*Text"
568+
subtitle "[+]*Set*Title*Bar*Text*"
518569

519570
echo -n "${titlebar_text}" |
520571
convert "${file_name}" \
@@ -571,8 +622,54 @@ function convertSecondBorder() {
571622
check
572623
}
573624

625+
function interpolateSaddle() {
626+
interpolate_file_name="interpolate_saddle"
627+
convert \
628+
\( \
629+
xc:${saddle_color_top_left} xc:${saddle_color_top_right} +append \
630+
\) \
631+
\( \
632+
xc:${saddle_color_bottom_left} xc:${saddle_color_bottom_right} +append \
633+
\) -append -size $size_wh \
634+
xc: +swap -fx 'v.p{i/(w-1),j/(h-1)}' \
635+
${XDG_CONFIG_HOME}/awesomeshot/backgrad/${interpolate_file_name}.png
636+
}
637+
638+
function interpolateMesh() {
639+
interpolate_file_name="interpolate_mesh"
640+
convert \
641+
\( \
642+
xc:${mesh_color_top_left} xc:${mesh_color_top_right} +append \
643+
\) \
644+
\( \
645+
xc:${mesh_color_bottom_left} xc:${mesh_color_bottom_right} +append \
646+
\) -append -size ${size_wh} \
647+
xc: +swap -interpolate Mesh -fx 'v.p{i/(w-1),j/(h-1)}' \
648+
${XDG_CONFIG_HOME}/awesomeshot/backgrad/${interpolate_file_name}.png
649+
}
650+
651+
function convertSecondBorderGradient() {
652+
subtitle "[+]*Set*Image*Second*Border*Gradient*"
653+
size_wh=$(identify -format %wx%h $file_name)
654+
if [ ! -d "${XDG_CONFIG_HOME}/awesomeshot/backgrad" ]; then
655+
mkdir ${XDG_CONFIG_HOME}/awesomeshot/backgrad
656+
fi
657+
658+
case ${interpolate_method} in
659+
"saddle"|"Saddle" )
660+
interpolateSaddle
661+
;;
662+
"mesh"|"Mesh" )
663+
interpolateMesh
664+
;;
665+
esac
666+
667+
composite -gravity center "$file_name" ${XDG_CONFIG_HOME}/awesomeshot/backgrad/${interpolate_file_name}.png "$file_name"
668+
check
669+
}
670+
574671
function convertFooter() {
575-
subtitle "[+]*Set*Image*Footer"
672+
subtitle "[+]*Set*Image*Footer*"
576673
echo -n "${footer_text}" |
577674
convert "$file_name" \
578675
-gravity ${footer_position} \
@@ -604,15 +701,15 @@ function stat() {
604701

605702
if [ "${2}" == "Success" ]; then
606703

607-
echo -e " [ ${COLOR_SUCCESS}${1}${COLOR_DEFAULT} ] > ${3}"
704+
echo -e " [ ${COLOR_SUCCESS}${1}${COLOR_DEFAULT} ]\n ${COLOR_SUCCESS}|\n ╰─${COLOR_DEFAULT} ${3}"
608705

609706
elif [ "${2}" == "Warning" ]; then
610707

611-
echo -e " [ ${COLOR_WARNING}${1}${COLOR_DEFAULT} ] > ${3}"
708+
echo -e " [ ${COLOR_WARNING}${1}${COLOR_DEFAULT} ]\n ${COLOR_WARNING}|\n ╰─${COLOR_DEFAULT} ${3}"
612709

613710
elif [ "${2}" == "Danger" ]; then
614711

615-
echo -e " [ ${COLOR_DANGER}${1}${COLOR_DEFAULT} ] > ${3}"
712+
echo -e " [ ${COLOR_DANGER}${1}${COLOR_DEFAULT} ]\n ${COLOR_DANGER}|\n ╰─${COLOR_DEFAULT} ${3}"
616713

617714
fi
618715

@@ -736,6 +833,15 @@ function help() {
736833
737834
second_border_size This variable serves to set how many size of the second border
738835
836+
convert_second_border_gradient This variable severs to convert border with gradient color,
837+
change this value to blank or whatever for disable convert and 'yes' for enable function
838+
839+
interpolate_method This variable serves to convert gradient color method
840+
More information: https://legacy.imagemagick.org/Usage/misc/
841+
List available method:
842+
- saddle
843+
- mesh
844+
739845
convert_shadow This variable serves to convert the shadow of image, change this value
740846
to blank or whatever for disable function and 'yes' for enable function.
741847
@@ -792,6 +898,18 @@ function version() {
792898
echo -e "awesomeshot v.${version}"
793899
}
794900

901+
function checkConfig() {
902+
if [[ $convert_second_border == "yes" && $convert_second_border_gradient == "yes" ]]; then
903+
if [ $second_border_color != "none" ]; then
904+
stat "ERROR" "Danger" "Conflict detected on config '${COLOR_WARNING}convert_second_border${COLOR_DEFAULT}' and '${COLOR_WARNING}convert_second_border_gradient${COLOR_DEFAULT}' enable at the same time"
905+
echo -e "
906+
both variable can be enable if '${COLOR_WARNING}second_border_color${COLOR_DEFAULT}' value is none
907+
"
908+
exit 1
909+
fi
910+
fi
911+
}
912+
795913
case "${1}" in
796914
-a|--auto )
797915
main autoRun

awesomeshot.1

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH AWESOMESHOT 1 "26 April 2022" "Awesomeshot 1.0.9" "User Commands"
1+
.TH AWESOMESHOT 1 "27 May 2022" "Awesomeshot 1.1.0" "User Commands"
22

33
.SH NAME
44
Awesomeshot
@@ -253,6 +253,25 @@ This variable serves to set how many size of the second border
253253
\fR
254254
.TP
255255

256+
\fB\/convert_second_border_gradient\fR
257+
.IP
258+
This variable severs to convert border with gradient color,
259+
change this value to blank or whatever for disable convert and 'yes' for enable function
260+
\fR
261+
.TP
262+
263+
\fB\/interpolate_method\fR
264+
.IP
265+
This variable serves to convert gradient color method
266+
More information: (\fI\,https://legacy.imagemagick.org/Usage/misc/\fR)
267+
List available method:
268+
.IP
269+
- saddle
270+
.IP
271+
- mesh
272+
\fR
273+
.TP
274+
256275
\fB\/convert_shadow\fR
257276
.IP
258277
This variable serves to convert the shadow of image, change this value
@@ -361,4 +380,4 @@ change this value with hex color or use the one in the array list.
361380
.IP
362381
This variable serves to open the result of image (when editing finished), change this value
363382
to blank or whatever for disable function and 'yes' for enable function.
364-
\fR
383+
\fR

awesomeshot.conf

+45-1
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,62 @@ first_border_color="${hex_color[0]}"
114114
# NOTE: make sure this value is small, otherwise it will look weird
115115
first_border_size=7
116116

117+
# This variable serves to convert tiny first border (background image) when editing the image,
118+
# change this value to blank or whatever for disable convert and "yes" for enable function
119+
convert_first_border=""
120+
121+
# This variable serves to set tiny first border color (background image), change this value
122+
# to "none" for transparent background, if you want to custom the color, you can
123+
# change this value with hex color or use the one in the array list.
124+
first_border_color="${hex_color[0]}"
125+
126+
# This variable serves to set how many size of the first border
127+
# NOTE: make sure this value is small, otherwise it will look weird
128+
first_border_size=7
129+
117130
# This variable serves to convert border (background image) when editing the image,
118131
# change this value to blank or whatever for disable convert and "yes" for enable function
119132
convert_second_border="yes"
120133

121134
# This variable serves to set border color (background image), change this value
122135
# to "none" for transparent background, if you want to custom the color, you can
123136
# change this value with hex color or use the one in the array list.
124-
second_border_color="${hex_color[0]}"
137+
# NOTE: if convert_second_border enable and second_border_color value not none
138+
# will be conflict
139+
#second_border_color="${hex_color[0]}"
140+
second_border_color="none"
125141

126142
# This variable serves to set how many size of the second border
127143
second_border_size=50
128144

145+
# This variable serves to convert border with gradient color,
146+
# change this value to blank or whatever for disable convert and "yes" for enable function
147+
convert_second_border_gradient="yes"
148+
149+
# This variable serves to convert gradient color method
150+
# More information: https://legacy.imagemagick.org/Usage/misc/
151+
# List available method:
152+
# - saddle
153+
# - mesh
154+
interpolate_method="saddle"
155+
156+
second_border_gradient_color=(
157+
"#C850C0"
158+
"#FFCC70"
159+
"#4158D0"
160+
"#FE7FAA"
161+
)
162+
163+
saddle_color_top_left="${second_border_gradient_color[0]}"
164+
saddle_color_top_right="${second_border_gradient_color[1]}"
165+
saddle_color_bottom_left="${second_border_gradient_color[2]}"
166+
saddle_color_bottom_right="${second_border_gradient_color[0]}"
167+
168+
mesh_color_top_left="${second_border_gradient_color[1]}"
169+
mesh_color_top_right="${second_border_gradient_color[1]}"
170+
mesh_color_bottom_left="${second_border_gradient_color[3]}"
171+
mesh_color_bottom_right="${second_border_gradient_color[3]}"
172+
129173
# This variable serves to convert the shadow of image, change this value
130174
# to blank or whatever for disable function and "yes" for enable function.
131175
convert_shadow="yes"

0 commit comments

Comments
 (0)