Page 1 of 1

How to draw with tranparent color / how draw erasures?

Posted: 2018-09-20T01:15:07-07:00
by waldalla
I want create a blue doughnut on transparent background. So far I have a circle on trans[arenty background with a white middle:

Code: Select all

convert -size 1001x1001 xc:white -alpha transparent transparent.png
convert transparent.png -fill "#2244aa" -stroke "#2244aa" -draw "circle 500,500 1,500" circle.png
convert circle.png -fill "white" -stroke "white" -draw "circle 500,500 400,500" circle.png
convert circle.png -resize 19x19 circle.png
How can I make the middle transparent instead of white? I tried -alpha transparent, but this gives me a completely white result:

Code: Select all

convert circle.png -draw "circle 500,500 400,500"  -alpha transparent circle.png
I'm looking for some way to "draw" with transparency as the color.

Thanks for all pointers in advance!

Re: How to draw with tranparent color / how draw erasures?

Posted: 2018-09-20T03:29:14-07:00
by snibgo
I would draw a grayscale image, then copy-opacity that to form the alpha channel:

Code: Select all

convert -size 1001x1001 xc:#2244aa ^
  ( +clone -fill Black -colorize 100 ^
    -fill White -draw "circle 500,500,1,500" ^
    -fill Black -draw "circle 500,500,400,500" ^
  ) ^
  -alpha off ^
  -compose CopyOpacity -composite ^
  out.png
(Windows BAT syntax. Adjust for bash.)

Re: How to draw with tranparent color / how draw erasures?

Posted: 2018-09-24T16:33:41-07:00
by waldalla
Thanks snibgo. Will try it out.

From the script I understand that you create the doughnut in b/w and then use the black parts as a "stamp" to put on a empty (=transparent) background. Very clever!

Re: How to draw with tranparent color / how draw erasures?

Posted: 2018-09-24T17:50:18-07:00
by anthony
A Number of ways... Here are two...

Using Masks with Images
http://www.imagemagick.org/Usage/masking/#masks

Composing using Duff-Porter methods, Specifically with Dst-Out
http://www.imagemagick.org/Usage/compose/#dstout

But essentially you want to manipulate the images alpha channel, either directly as in the first, or using alpha composition, as in the second.

Anthony