hi,
anthony wrote:You seemed to have done well.
Though I would have broken up the lone LONG line into a multi-line statement so as to make it easier to read and figure out what is going on. I have broken it up for UNIX/Linux. but you can also do this (differentally) for DOS scripts
I've try but i got an error and because it was not my priority, i fell tried.
anthony wrote:
Interesting use of round rectangle to make long cylinders and matching ellipses
I would never have thought of it!
At the begenning i've used circle but i've found it much more difficult and less accurate.
anthony wrote: Very well done. This example could be a good IM demo!
I'm so surprised because it's my first drawing and i spent considerable time !
thank you very much, it's an honor
anthony wrote:Also your generation of a second image -size 320x100 xc:none seems to be useless!
i've tried with only one but i had difficulties to put the text at the good location
anthony wrote:
I also would not recommend the use of strokewidth 0 See
Draw, Stroke and Strokewidth Better to create a larger font and shrink if you only want a 'thin' border. Stroke widths smaller than 1 has always been a little awkward in IM draw.
well I replaced it by a stroke of "1" and with the shadow color.
it makes much better !
anthony wrote:
Question where did you get Garfield font from?
there
anthony wrote:That can be put in a script and you can now easilly insert bug lines like
-write x:
that will display and wait between the various statements. Makes debugging and figuring out the command a LOT easier. See
Basics, Complex Image Processing and Debugging
Very interesting, if I knew I had much less difficulty because I do not know the first thing in computer graphics!
anthony wrote:
All that is needed is needed is to do some pixel math to draw the cylinder at different percentages
In fact, the script is already done and everything is calculated and proportional.
My goal was to create a dynamic icon for "zenity". Here's the script:
Code: Select all
#!/bin/bash
trap 'end 1' SIGINT SIGKILL
font="${1:-./Garfield.ttf}"
imgXSize="${2:-320}"
imgYSize="${3:-200}"
resultat=.$$_resultat.png
borderColor=snow4
cylindreOutColor=snow2
cylindreInColor=snow
progressOutColor=chartreuse3
progressInColor=chartreuse2
texteColor=red
progressYmax=$(((imgYSize*95)/100))
progressYmin=$(((imgYSize*55)/100))
progressXmin=$(((imgXSize*5)/100))
progressXmax=$((imgXSize-progressXmin))
wc=$(((progressYmax-progressYmin)/4))
hc=$(((progressYmax-progressYmin)/2))
fontSize=$(((imgYSize*2)/5)) # 40%
fontShadow=firebrick3
end()
{
# [ -f "${resultat}" ] && rm "${resultat}"
exit $1
}
makeIcon()
{
texte="$1"
pct=$2
max=$((progressXmin+pct*(progressXmax-progressXmin)/100));
((max<progressXmin+2*wc)) && max=$((progressXmin+2*wc))
resultat=image.png
convert -size ${imgXSize}x${imgYSize} xc:none -stroke ${borderColor} -fill ${cylindreOutColor} -draw "roundrectangle ${progressXmin},${progressYmin},${progressXmax},${progressYmax} ${wc},${hc}" \
-fill ${cylindreInColor} -draw "roundrectangle $((progressXmax-2*wc)),${progressYmin},${progressXmax},${progressYmax} ${wc},${hc}" \
-fill ${progressOutColor} -draw "roundrectangle ${progressXmin},${progressYmin},${max},${progressYmax} ${wc},${hc}" \
-fill ${progressInColor} -draw "roundrectangle $((max-2*wc)),${progressYmin},${max},${progressYmax} ${wc},${hc}" \
-fill none -draw "roundrectangle $((progressXmax-2*wc)),${progressYmin},${progressXmax},${progressYmax} ${wc},${hc}" \
-strokewidth 2 -draw "roundrectangle ${progressXmin},${progressYmin},${progressXmax},${progressYmax} ${wc},${hc}" \
\( +clone -background ${borderColor} -shadow 80x3+5+5 \) +swap -background none -layers merge \
-size ${imgXSize}x$((imgYSize/2)) xc:none -strokewidth 1 -stroke ${fontShadow} -gravity center -font ${font} \
-pointsize ${fontSize} -fill ${texteColor} label:"${texte}" \( +clone -background ${fontShadow} \
-shadow 80x3+5+5 \) +swap -background none -layers merge "${resultat}"
echo "icon:${resultat}"
echo "tooltip:${texte}"
}
{
for ((x=0;x<=100;x++))
do
makeIcon "${x} %" ${x}
done
#makeIcon "OK !" 100
read -s -n1
} | zenity --listen --notification --window-icon=info --text "0 %"
end 0
anthony wrote:
In such as script I would create two completely separate images, one to draw the cylinder and another to draw the label according to 'user arguments'. Then just append the images rather than overlay as you get more freedom to modify positions or adjust things, for new situations and needs.
I created such a script, then modified it to generate an animation of each of the drawing steps for just the cylinder (not the shadowing or label...
I would be interested in such a script, could you post it?
I do not know the MVG script but I do not think this is a good solution because the icon must be processed as quickly as possible and this makes an additional share. That is why I asked if there was a better approach than mine. Namely, is it possible to reduce the time of creating the icon?
I keep this method still below the elbow!
Thank's a lot for evry things