Re: composites circle

Lawrence D'Oliveiro <[email protected]>
Newsgroups gmane.comp.lib.cairo
Organization Geek Central
Message-ID <[email protected]>
On Sun, 17 Jan 2016 13:25:56 +1300, I wrote:

> So really, draw each circle with an opaque colour clipped outside the
> other circle. Then fill the mixed colour, clipped to the intersection
> of the two circles.

Like this:

    #!/usr/bin/python3

    import sys
    import os
    import qahirah
    from qahirah import \
        CAIRO, \
        Colour

    pix = qahirah.ImageSurface.create \
      (
        format = CAIRO.FORMAT_RGB24,
        dimensions = (187, 143)
      )
    (qahirah.Context.create(pix)
        .set_source_colour(Colour.grey(0))
        .set_operator(CAIRO.OPERATOR_SOURCE)
        .paint()
        .arc
          (
            centre = (63, 81),
            radius = 40,
            angle1 = 0,
            angle2 = qahirah.circle,
            negative = False
          )
        .set_source_colour(Colour.from_rgba((1, 0, 0)))
        .fill()
        .arc
          (
            centre = (123, 81),
            radius = 40,
            angle1 = 0,
            angle2 = qahirah.circle,
            negative = False
          )
        .set_source_colour(Colour.grey((1)))
        .fill()
        .arc
          (
            centre = (63, 81),
            radius = 40,
            angle1 = 0,
            angle2 = qahirah.circle,
            negative = False
          )
        .clip()
        .arc
          (
            centre = (123, 81),
            radius = 40,
            angle1 = 0,
            angle2 = qahirah.circle,
            negative = False
          )
        .set_source_colour(Colour.from_rgba((1, 0.82, 0.82)))
        .fill()
    )

    pix.flush().write_to_png("%s.png" % os.path.basename(sys.argv[0]))
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.