No subject
Wed Feb 18 12:17:48 PST 2009
over the surface and painting everything. Where ever the mask is opaque
(ironically), the paint goes through to the surface, just like screen
painting. Since the mask and surface are the same size and I've made their
origins the same (haven't I?), it seems I should just get the green square
in the middle of the (already brown) surface. But that doesn't seem to be
what is happening. What am I misunderstanding?
Also, if I set alpha=1 over the entire mask, the result is a 200x200 mostly
GREEN square with a slight gradient fade to BROWN in the upper left corner,
near the origin. Why not just a uniform 200x200 GREEN square? I'm bummed
because the documentation seems quite straightforward and intuitive, but I'm
apparently just missing something.
Thanks in advance,
Dan
--0016364579904100000463376169
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I'm sure this is a dumb question, but apparently, I don't understan=
d some (possibly fundamental) aspect of how cairo does stuff (disclaimer: I=
'm a machine learning person and not a graphics person). Based on=
the documentation, I would think that the following code would produce a 2=
00x200 BROWN square with a smaller 40x40 GREEN square centered in it.  =
;Instead, I get just a 200x200 BROWN square (i.e. the mask lets no green pa=
int through).<div>
<div><br></div><div><p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0=
px Monaco; color: #2e0d6e"><br></p><p style=3D"margin: 0.0px 0.0px 0.0px 0.=
0px; font: 10.0px Monaco; color: #2e0d6e"><span class=3D"Apple-style-span" =
style=3D"color: rgb(0, 0, 0);"></span></p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2=
e0d6e"><span style=3D"color: #000000"> fina=
lsurface =3D </span>cairo_image_surface_create<span style=3D"color: #000000=
">(</span>CAIRO_FORMAT_ARGB32<span style=3D"color: #000000">, </span><span =
style=3D""><span class=3D"Apple-style-span" style=3D"color: rgb(63, 110, 11=
6);">200</span></span><span style=3D"color: #000000">, </span><span style=
=3D""><span class=3D"Apple-style-span" style=3D"color: rgb(63, 110, 116);">=
200</span></span><span style=3D"color: #000000">);</span></p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"> &n=
bsp; finalcr =3D <span style=3D"color: #2e0d6e">cairo_create<=
/span> (finalsurface);</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0=
07400"><span style=3D"color: #000000"><span class=3D"Apple-tab-span" style=
=3D"white-space:pre"> </span></span><span style=3D"color: #2e0d6e">cairo_sc=
ale</span><span style=3D"color: #000000"> (finalcr, </span><span style=3D""=
><span class=3D"Apple-style-span" style=3D"color: rgb(63, 110, 116);">200</=
span></span><span style=3D"color: #000000">, </span><span style=3D""><span =
class=3D"Apple-style-span" style=3D"color: rgb(63, 110, 116);">200</span></=
span><span style=3D"color: #000000">);<span class=3D"Apple-tab-span" style=
=3D"white-space:pre"> </span></span><br>
</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0=
07400"><span class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 0); ">&nb=
sp; color=3Dmake<span style=3D"color: #26474b">co=
lor</span>(BROWN); //retur=
ns a cairo_pattern_t</span><br>
</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span cla=
ss=3D"Apple-tab-span" style=3D"white-space:pre"> </span><span style=3D"colo=
r: #2e0d6e">cairo_set_source</span>(finalcr,color);<br></p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span cla=
ss=3D"Apple-tab-span" style=3D"white-space:pre"> </span><span style=3D"colo=
r: #2e0d6e">cairo_paint</span>(finalcr);</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0=
07400"><span class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 0); "><sp=
an class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>color=3Dmake<=
span style=3D"color: #26474b">color</span>(GREEN);</span><br>
</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0=
07400"><span class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 0); "><sp=
an class=3D"Apple-tab-span" style=3D"white-space:pre"> </span><span style=
=3D"color: #2e0d6e">cairo_set_source</span>(finalcr,color);</span><br>
</p>
<p style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-=
left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116=
, 0); "><span class=3D"Apple-style-span" style=3D"color: rgb(46, 13, 110); =
"><span style=3D"color: rgb(0, 0, 0); "> ma=
sksurface =3D </span>cairo_image_surface_create<span style=3D"color: r=
gb(0, 0, 0); ">(</span>CAIRO_FORMAT_ARGB32<span style=3D"color: rgb(0, 0, 0=
); ">, </span><span style=3D""><span class=3D"Apple-style-span" style=
=3D"color: rgb(63, 110, 116);">200</span></span><span style=3D"color: rgb(0=
, 0, 0); ">, </span><span style=3D""><span class=3D"Apple-style-span" =
style=3D"color: rgb(63, 110, 116);">200</span></span><span style=3D"color: =
rgb(0, 0, 0); ">);</span></span><br>
</p><p style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; mar=
gin-left: 0px; font: normal normal normal 10px/normal Monaco; ">  =
; maskcr =3D <span style=3D"color: rgb(46, 13, 110=
); ">cairo_create</span> (masksurface);</p>
<p style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-=
left: 0px; font: normal normal normal 10px/normal Monaco; "><span style=3D"=
color: rgb(46, 13, 110); "> cairo_scale</sp=
an> (maskcr, <span class=3D"Apple-style-span" style=3D"color: rgb=
(63, 110, 116);">200</span>, <span class=3D"Apple-style-span" style=3D=
"color: rgb(63, 110, 116);">200</span>);</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0=
07400"><span class=3D"Apple-style-span" style=3D"color: rgb(46, 13, 110); "=
> cairo_set_source_rgba<span style=3D"color=
: #000000">(maskcr, </span><span style=3D"color: #1c00cf">0</span><span sty=
le=3D"color: #000000">, </span><span style=3D"color: #1c00cf">0</span><span=
style=3D"color: #000000">, </span><span style=3D"color: #1c00cf">0</span><=
span style=3D"color: #000000">, </span><span style=3D""><span class=3D"Appl=
e-style-span" style=3D"color: rgb(28, 0, 207);">0</span></span><span style=
=3D"color: #000000">);</span></span><br>
</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2=
e0d6e"> cairo_paint<span style=3D"color: #0=
00000">(maskcr); &n=
bsp; //make most of mask transparent</span></p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2=
e0d6e"> cairo_set_source_rgba<span style=3D=
"color: #000000">(maskcr, </span><span style=3D"color: #1c00cf">1</span><sp=
an style=3D"color: #000000">, </span><span style=3D"color: #1c00cf">1</span=
><span style=3D"color: #000000">, </span><span style=3D"color: #1c00cf">1</=
span><span style=3D"color: #000000">, </span><span style=3D"color: #1c00cf"=
>1</span><span style=3D"color: #000000">);</span></p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span sty=
le=3D"color: #2e0d6e"> cairo_rectangle</spa=
n>(maskcr, <span style=3D"color: #1c00cf">.4</span>, <span style=3D"color: =
#1c00cf">.4</span>, <span style=3D"color: #1c00cf">.2</span>, <span style=
=3D"color: #1c00cf">.2</span>);</p>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2=
e0d6e"> cairo_fill<span style=3D"color: #00=
0000">(maskcr); &nb=
sp; //make small square in mask opaque</span></p=
>
<p style=3D"margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #0=
07400"><span class=3D"Apple-style-span" style=3D"color: rgb(0, 0, 0); "><sp=
an class=3D"Apple-tab-span" style=3D"white-space:pre"> </span><span style=
=3D"color: #2e0d6e">cairo_mask_surface</span>(finalcr,masksurface,<span sty=
le=3D"color: #1c00cf">0</span>,<span style=3D"color: #1c00cf">0</span>);</s=
pan><br>
</p><div><br></div><div><br></div><div>From reading the documentation, I im=
agine that we are just laying the mask over the surface and painting everyt=
hing. Where ever the mask is opaque (ironically), the paint goes thro=
ugh to the surface, just like screen painting. Since the mask and sur=
face are the same size and I've made their origins the same (haven'=
t I?), it seems I should just get the green square in the middle of the (al=
ready brown) surface. But that doesn't seem to be what is happeni=
ng. What am I misunderstanding?</div>
<div><br></div><div><div>Also, if I set alpha=3D1 over the entire mask, the=
result is a 200x200 mostly GREEN square with a slight gradient fade to BRO=
WN in the upper left corner, near the origin. Why not just a uniform =
200x200 GREEN square? I'm bummed because the documentation seems =
quite straightforward and intuitive, but I'm apparently just missing so=
mething.</div>
<div><br></div><div><br></div><div>Thanks in advance,</div><div><br></div><=
div>Dan</div><div><br></div></div><p></p></div></div>
--0016364579904100000463376169--
More information about the cairo
mailing list