create 12 squares around a circle - clock face ticks background PNG
-
- Posts: 7
- Joined: 2014-11-15T13:03:18-07:00
- Authentication code: 6789
create 12 squares around a circle - clock face ticks background PNG
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: create 12 squares around a circle - clock face ticks background PNG
why not just use that image? do you need to change something?
-
- Posts: 7
- Joined: 2014-11-15T13:03:18-07:00
- Authentication code: 6789
Re: create 12 squares around a circle - clock face ticks background PNG
Yes, I need to be able to create variations of the shape... circles/squares/etc at different sizes and offsets around the circle.fmw42 wrote:why not just use that image? do you need to change something?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: create 12 squares around a circle - clock face ticks background PNG
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.
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.
-
- Posts: 7
- Joined: 2014-11-15T13:03:18-07:00
- Authentication code: 6789
Re: create 12 squares around a circle - clock face ticks background PNG
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
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: create 12 squares around a circle - clock face ticks background PNG
"+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
snibgo's IM pages: im.snibgo.com
-
- Posts: 7
- Joined: 2014-11-15T13:03:18-07:00
- Authentication code: 6789
Re: create 12 squares around a circle - clock face ticks background PNG
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
Last edited by roundsparrow on 2014-11-15T14:56:03-07:00, edited 1 time in total.
Re: create 12 squares around a circle - clock face ticks background PNG
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
-
- Posts: 7
- Joined: 2014-11-15T13:03:18-07:00
- Authentication code: 6789
Re: create 12 squares around a circle - clock face ticks background PNG
yha, that was it, forgot % is var on Windows
The outcome size is a bit complex, but got close to a target of 960x960
Thank you - this worked fine. I remember now the example pages always are 0 based pixel counting, so 909+49 = 960 total.
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
Last edited by roundsparrow on 2014-11-15T15:06:32-07:00, edited 2 times in total.
Re: create 12 squares around a circle - clock face ticks background PNG
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 !
So I would say change -size 80x10 to -size 480x10
We crossed posts !
-
- Posts: 7
- Joined: 2014-11-15T13:03:18-07:00
- Authentication code: 6789
Re: create 12 squares around a circle - clock face ticks background PNG
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.Bonzo wrote:]
We crossed posts !
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: create 12 squares around a circle - clock face ticks background PNG
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
snibgo's IM pages: im.snibgo.com
-
- Posts: 7
- Joined: 2014-11-15T13:03:18-07:00
- Authentication code: 6789
Re: create 12 squares around a circle - clock face ticks background PNG
Thank you for the follow-up.snibgo wrote:Many variations are possible. This may be an easier method
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: create 12 squares around a circle - clock face ticks background PNG
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
snibgo's IM pages: im.snibgo.com