Page 1 of 1
create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T13:09:24-07:00
by roundsparrow
Hi,
I found a script for creating a clock face using bash + ImageMagick. I'm trying to take it one step further and create all the assets. script is here:
http://pantburk.info/?blog=89
What I'm trying to do is create a 1000x1000 PNG that matches this:
http://pantburk.info/upload/analogclock ... 0x1000.png - 12 squares around a circle.
I managed to create a hacky 1000x1000 PNG with:
convert -size 84x8 xc: -draw 'circle 0,0 12x12' -duplicate 12 +append +duplicate -virtual-pixel transparent -distort Arc 360,0,499,480
But I really don't want them distorted, and these parameters I came up with trial and error - not really understanding
Can soemone help me figure out how to duplicate 12 squares around a circle so it matches the bg_1000x1000.png?
Thank you.
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T13:16:43-07:00
by fmw42
why not just use that image? do you need to change something?
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T13:19:25-07:00
by roundsparrow
fmw42 wrote:why not just use that image? do you need to change something?
Yes, I need to be able to create variations of the shape... circles/squares/etc at different sizes and offsets around the circle.
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T13:22:29-07:00
by fmw42
You would then need to use -draw with those shapes at the right locations. You can rotate squares or rectangles with -draw rather than using -distort arc. see
http://www.imagemagick.org/script/magic ... aphics.php and
http://www.imagemagick.org/Usage/draw/
see the green circle example at
http://www.imagemagick.org/Usage/draw/#circles, which shows how to use translate so you can just place the circle at the right center point and use relative coordinates for the radius. You can do the same for rectangles and also include rotate angle in the command to include the rotation about the center of the rectangle. So you just need to compute the center points of each object and sizes.
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T14:17:06-07:00
by roundsparrow
I"m not able to make sense of how to apply iteration in the green circle example you provided.
What I do see is this "Moving hole" example at:
http://www.imagemagick.org/Usage/anim_opt/
But this is cloning the entire image to make multiple frames of an Animated GIF. Is it possible to adapt that example to draw on the same canvas in a loop? It seems to draw the desired shapes, then do a +clone -rotate 90 multiple times to create 4 copies. I've been trying to figure out the equalivlent command with "duplicate", etc - but I'm pretty lost here
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T14:34:45-07:00
by snibgo
"+distort SRT {angle}" can use fx: expressions. So (Windows BAT syntax):
Code: Select all
convert -size 80x10 xc:None -size 20x10 xc:red +append ^
-duplicate 11 ^
-virtual-pixel None ^
+distort SRT "%%[fx:360.0*t/n]" ^
-layers merge ^
c.png
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T14:54:22-07:00
by roundsparrow
got:
invalid argument for option ScaleRotateTranslate : 'Zero Scale Given'. I think I translated to bash correctly:
Code: Select all
convert -size 80x10 xc:None -size 20x10 xc:red +append \
-duplicate 11 \
-virtual-pixel None \
+distort SRT "%%[fx:360.0*t/n]" \
-layers merge \
c.png
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T14:55:49-07:00
by Bonzo
I assume you put the code into the command prompt? If so use this:
Code: Select all
convert -size 80x10 xc:None -size 20x10 xc:red +append ^
-duplicate 11 ^
-virtual-pixel None ^
+distort SRT "%[fx:360.0*t/n]" ^
-layers merge ^
c.png
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T14:57:50-07:00
by roundsparrow
yha, that was it, forgot % is var on Windows
The outcome size is a bit complex, but got close to a target of 960x960
Code: Select all
convert -size 909x10 xc:None -size 49x10 xc:red +append \
-duplicate 11 \
-virtual-pixel None \
+distort SRT "%[fx:360.0*t/n]" \
-layers merge \
clockticks.png
Thank you - this worked fine. I remember now the example pages always are 0 based pixel counting, so 909+49 = 960 total.
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T15:04:15-07:00
by Bonzo
It looks to me like the code is drawing a canvas 80px wide by 10px high. It is the drawing a 20px wide x 10px high rectangle on the canvas.
So I would say change -size 80x10 to -size 480x10
We crossed posts !
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T15:07:48-07:00
by roundsparrow
Bonzo wrote:]
We crossed posts !
yha
I changed some other prams to get visibility up on larger sizes - but I think I got the math figured out. This is great, thanks again.
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-15T15:20:36-07:00
by snibgo
Many variations are possible. This may be an easier method, for getting the maths right:
Code: Select all
convert -size 20x10 xc:red ^
-duplicate 11 ^
-virtual-pixel None ^
+distort SRT "40,5,%%[fx:360.0*t/n]" ^
-write info: ^
-layers merge ^
c.png
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-16T05:28:05-07:00
by roundsparrow
snibgo wrote:Many variations are possible. This may be an easier method
Thank you for the follow-up.
I also want to try and put text around the circle. Example:
http://ablogtowatch.wpengine.netdna-cdn ... ches-8.jpg - although this gets pretty complex - I likely want to do it in multiple arcs - as the text reverses direction at the 45, 50, 55 places
Re: create 12 squares around a circle - clock face ticks background PNG
Posted: 2014-11-16T09:55:52-07:00
by snibgo
Again, there are many ways of doing this, eg:
Code: Select all
convert -size 500x500 xc:None ^
-pointsize 20 ^
-fill Red ^
-gravity Center ^
-draw "rotate -90 text 0,-200 '45'" ^
-draw "rotate -60 text 0,-200 '50'" ^
-draw "rotate -30 text 0,-200 '55'" ^
-draw "rotate 0 text 0,-200 '60'" ^
-draw "rotate 30 text 0,-200 '5'" ^
-draw "rotate 60 text 0,-200 '10'" ^
-draw "rotate 90 text 0,-200 '15'" ^
-draw "rotate -60 text 0,200 '20'" ^
-draw "rotate -30 text 0,200 '25'" ^
-draw "rotate 0 text 0,200 '30'" ^
-draw "rotate 30 text 0,200 '35'" ^
-draw "rotate 60 text 0,200 '40'" ^
minutes.png