Code: Select all
magick ^
-gravity center ^
xc:lightblue[200x200] ^
-fill none ^
-stroke white ^
-strokewidth 2 ^
( ^
-background none ^
xc:none[100x100] ^
-fill darkred ^
-stroke none ^
-draw "circle 50,50 50,10" ^
) ^
-define compose:args=50,50 ^
-compose blend ^
-composite ^
-depth 8 ^
img_test1.png
Perfect. The output is a 200x200 blue square with an 80x80 red circle, 50% transparent, composited in the center.
Then I add just a single line to the code, a "-draw" operation. It draws a white stroked empty square on the blue square before creating and overlaying the red circle. This is the code with the added line...
Code: Select all
magick ^
-gravity center ^
xc:lightblue[200x200] ^
-fill none ^
-stroke white ^
-strokewidth 2 ^
-draw "rectangle 20,20 120,120" ^
( ^
-background none ^
xc:none[100x100] ^
-fill darkred ^
-stroke none ^
-draw "circle 50,50 50,10" ^
) ^
-define compose:args=50,50 ^
-compose blend ^
-composite ^
-depth 8 ^
img_test2.png
What seems to be happening here is the background of the red circle, the transparent 100x100 canvas it's drawn on, blends down to make the blue square 50% transparent in that area. I can't think of a reason why that canvas should send its 50% transparency property down to the blue layer in the second command when it doesn't act that way at all in the first command.
I've tried to flatten the image at various points through the command. I've tried setting or un-setting alpha before and/or after each layer of the image. I've tried it with "-background none" (or white or black) before creating the blue canvas. None of my simple tests seem to make a difference in the result.
Is this a bug, or am I misunderstanding something that's causing this odd behavior?