TikZ: complex mask over image (even odd rule)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












I need to draw masks (with various shapes) over an image. For example, I made a circle mask like this:



documentclass[border=10pt]standalone
usepackagetikz
definecolorbackgroundHTML2C414C
definecolorforegroundHTMLFFFFFF
usetikzlibrarypositioning,fit
begindocument
begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
node (image) includegraphicsexample-image;
fill [red, opacity=0.5,even odd rule]
(image.north west) rectangle (image.south east) % Cover up everything
(0,1) circle [radius=50pt]; % Punch a hole
endtikzpicture
enddocument


mask example



How do I use a more complex shape instead of the circle? Specifically, I need a heart shape. I tried using the one from this answer, but it either causes errors or doesn't appear:



begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
node (image) includegraphicsexample-image;
fill [red, opacity=0.5,even odd rule]
(image.north west) rectangle (image.south east)
(0,1) draw .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle;
(0,1) draw .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
endtikzpicture


Error: ! Use of @next doesn't match its definition.










share|improve this question



























    up vote
    4
    down vote

    favorite












    I need to draw masks (with various shapes) over an image. For example, I made a circle mask like this:



    documentclass[border=10pt]standalone
    usepackagetikz
    definecolorbackgroundHTML2C414C
    definecolorforegroundHTMLFFFFFF
    usetikzlibrarypositioning,fit
    begindocument
    begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
    node (image) includegraphicsexample-image;
    fill [red, opacity=0.5,even odd rule]
    (image.north west) rectangle (image.south east) % Cover up everything
    (0,1) circle [radius=50pt]; % Punch a hole
    endtikzpicture
    enddocument


    mask example



    How do I use a more complex shape instead of the circle? Specifically, I need a heart shape. I tried using the one from this answer, but it either causes errors or doesn't appear:



    begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
    node (image) includegraphicsexample-image;
    fill [red, opacity=0.5,even odd rule]
    (image.north west) rectangle (image.south east)
    (0,1) draw .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle;
    (0,1) draw .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
    endtikzpicture


    Error: ! Use of @next doesn't match its definition.










    share|improve this question

























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I need to draw masks (with various shapes) over an image. For example, I made a circle mask like this:



      documentclass[border=10pt]standalone
      usepackagetikz
      definecolorbackgroundHTML2C414C
      definecolorforegroundHTMLFFFFFF
      usetikzlibrarypositioning,fit
      begindocument
      begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
      node (image) includegraphicsexample-image;
      fill [red, opacity=0.5,even odd rule]
      (image.north west) rectangle (image.south east) % Cover up everything
      (0,1) circle [radius=50pt]; % Punch a hole
      endtikzpicture
      enddocument


      mask example



      How do I use a more complex shape instead of the circle? Specifically, I need a heart shape. I tried using the one from this answer, but it either causes errors or doesn't appear:



      begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
      node (image) includegraphicsexample-image;
      fill [red, opacity=0.5,even odd rule]
      (image.north west) rectangle (image.south east)
      (0,1) draw .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle;
      (0,1) draw .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
      endtikzpicture


      Error: ! Use of @next doesn't match its definition.










      share|improve this question















      I need to draw masks (with various shapes) over an image. For example, I made a circle mask like this:



      documentclass[border=10pt]standalone
      usepackagetikz
      definecolorbackgroundHTML2C414C
      definecolorforegroundHTMLFFFFFF
      usetikzlibrarypositioning,fit
      begindocument
      begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
      node (image) includegraphicsexample-image;
      fill [red, opacity=0.5,even odd rule]
      (image.north west) rectangle (image.south east) % Cover up everything
      (0,1) circle [radius=50pt]; % Punch a hole
      endtikzpicture
      enddocument


      mask example



      How do I use a more complex shape instead of the circle? Specifically, I need a heart shape. I tried using the one from this answer, but it either causes errors or doesn't appear:



      begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
      node (image) includegraphicsexample-image;
      fill [red, opacity=0.5,even odd rule]
      (image.north west) rectangle (image.south east)
      (0,1) draw .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle;
      (0,1) draw .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
      endtikzpicture


      Error: ! Use of @next doesn't match its definition.







      tikz-pgf diagrams






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 13 hours ago

























      asked 13 hours ago









      kontextify

      1665




      1665




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          Draw the heart with only one path:



          documentclass[border=10pt]standalone
          usepackagetikz
          definecolorbackgroundHTML2C414C
          definecolorforegroundHTMLFFFFFF
          usetikzlibrarypositioning,fit
          begindocument
          begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
          node (image) includegraphicsexample-image;
          fill [red, opacity=0.5,even odd rule]
          (image.north west) rectangle (image.south east)
          (0,1) .. controls (0,1.75) and (-1.5,2.00) .. (-1.5,3) arc (180:0:0.75) arc (180:0:0.75)
          .. controls ( 1.5,2.00) and (0,1.75) .. (0,1) --cycle;
          endtikzpicture
          enddocument


          enter image description here



          And with relative coordinates in hart definition, it's easier to place wherever you want over the image:



          documentclass[border=10pt]standalone
          usepackagetikz
          definecolorbackgroundHTML2C414C
          definecolorforegroundHTMLFFFFFF
          usetikzlibrarypositioning,fit

          newcommandhart.. controls +(0,.75) and +(0,-1.00) .. ++(-1.5,2) arc (180:0:0.75) arc (180:0:0.75)
          .. controls +(0,-1.00) and +(0,.75) .. cycle

          begindocument
          begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
          node (image) includegraphicsexample-image;
          fill [red, opacity=0.5,even odd rule]
          (image.north west) rectangle (image.south east)
          [rotate=90, scale=.5](image.center)hart
          [scale=1.5](image.center)hart
          [rotate=-50]([shift=(1,2)]image.south west)hart;
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer






















          • @kontextify: may be you are interested in updated answer
            – Ignasi
            5 hours ago

















          up vote
          3
          down vote













          Seems, there was two times draw an one ; to much.



          enter image description here



          documentclass[border=10pt, tikz]standalone
          usepackagetikz
          definecolorbackgroundHTML2C414C
          definecolorforegroundHTMLFFFFFF
          usetikzlibrarypositioning,fit

          begindocument

          begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
          node (image) includegraphicsexample-image;
          fill [red, opacity=0.5,even odd rule]
          (image.north west) rectangle (image.south east) % Cover up everything
          (0,1) circle [radius=50pt]; % Punch a hole
          endtikzpicture

          begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
          node (image) includegraphicsexample-image;
          fill [red, opacity=0.5,even odd rule,]
          (image.north west) rectangle (image.south east)
          (0,1) .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle
          (0,1) .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
          endtikzpicture

          enddocument





          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "85"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f454482%2ftikz-complex-mask-over-image-even-odd-rule%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            Draw the heart with only one path:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit
            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            (0,1) .. controls (0,1.75) and (-1.5,2.00) .. (-1.5,3) arc (180:0:0.75) arc (180:0:0.75)
            .. controls ( 1.5,2.00) and (0,1.75) .. (0,1) --cycle;
            endtikzpicture
            enddocument


            enter image description here



            And with relative coordinates in hart definition, it's easier to place wherever you want over the image:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit

            newcommandhart.. controls +(0,.75) and +(0,-1.00) .. ++(-1.5,2) arc (180:0:0.75) arc (180:0:0.75)
            .. controls +(0,-1.00) and +(0,.75) .. cycle

            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            [rotate=90, scale=.5](image.center)hart
            [scale=1.5](image.center)hart
            [rotate=-50]([shift=(1,2)]image.south west)hart;
            endtikzpicture
            enddocument


            enter image description here






            share|improve this answer






















            • @kontextify: may be you are interested in updated answer
              – Ignasi
              5 hours ago














            up vote
            5
            down vote



            accepted










            Draw the heart with only one path:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit
            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            (0,1) .. controls (0,1.75) and (-1.5,2.00) .. (-1.5,3) arc (180:0:0.75) arc (180:0:0.75)
            .. controls ( 1.5,2.00) and (0,1.75) .. (0,1) --cycle;
            endtikzpicture
            enddocument


            enter image description here



            And with relative coordinates in hart definition, it's easier to place wherever you want over the image:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit

            newcommandhart.. controls +(0,.75) and +(0,-1.00) .. ++(-1.5,2) arc (180:0:0.75) arc (180:0:0.75)
            .. controls +(0,-1.00) and +(0,.75) .. cycle

            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            [rotate=90, scale=.5](image.center)hart
            [scale=1.5](image.center)hart
            [rotate=-50]([shift=(1,2)]image.south west)hart;
            endtikzpicture
            enddocument


            enter image description here






            share|improve this answer






















            • @kontextify: may be you are interested in updated answer
              – Ignasi
              5 hours ago












            up vote
            5
            down vote



            accepted







            up vote
            5
            down vote



            accepted






            Draw the heart with only one path:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit
            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            (0,1) .. controls (0,1.75) and (-1.5,2.00) .. (-1.5,3) arc (180:0:0.75) arc (180:0:0.75)
            .. controls ( 1.5,2.00) and (0,1.75) .. (0,1) --cycle;
            endtikzpicture
            enddocument


            enter image description here



            And with relative coordinates in hart definition, it's easier to place wherever you want over the image:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit

            newcommandhart.. controls +(0,.75) and +(0,-1.00) .. ++(-1.5,2) arc (180:0:0.75) arc (180:0:0.75)
            .. controls +(0,-1.00) and +(0,.75) .. cycle

            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            [rotate=90, scale=.5](image.center)hart
            [scale=1.5](image.center)hart
            [rotate=-50]([shift=(1,2)]image.south west)hart;
            endtikzpicture
            enddocument


            enter image description here






            share|improve this answer














            Draw the heart with only one path:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit
            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            (0,1) .. controls (0,1.75) and (-1.5,2.00) .. (-1.5,3) arc (180:0:0.75) arc (180:0:0.75)
            .. controls ( 1.5,2.00) and (0,1.75) .. (0,1) --cycle;
            endtikzpicture
            enddocument


            enter image description here



            And with relative coordinates in hart definition, it's easier to place wherever you want over the image:



            documentclass[border=10pt]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit

            newcommandhart.. controls +(0,.75) and +(0,-1.00) .. ++(-1.5,2) arc (180:0:0.75) arc (180:0:0.75)
            .. controls +(0,-1.00) and +(0,.75) .. cycle

            begindocument
            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east)
            [rotate=90, scale=.5](image.center)hart
            [scale=1.5](image.center)hart
            [rotate=-50]([shift=(1,2)]image.south west)hart;
            endtikzpicture
            enddocument


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 5 hours ago

























            answered 13 hours ago









            Ignasi

            88k4159293




            88k4159293











            • @kontextify: may be you are interested in updated answer
              – Ignasi
              5 hours ago
















            • @kontextify: may be you are interested in updated answer
              – Ignasi
              5 hours ago















            @kontextify: may be you are interested in updated answer
            – Ignasi
            5 hours ago




            @kontextify: may be you are interested in updated answer
            – Ignasi
            5 hours ago










            up vote
            3
            down vote













            Seems, there was two times draw an one ; to much.



            enter image description here



            documentclass[border=10pt, tikz]standalone
            usepackagetikz
            definecolorbackgroundHTML2C414C
            definecolorforegroundHTMLFFFFFF
            usetikzlibrarypositioning,fit

            begindocument

            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule]
            (image.north west) rectangle (image.south east) % Cover up everything
            (0,1) circle [radius=50pt]; % Punch a hole
            endtikzpicture

            begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
            node (image) includegraphicsexample-image;
            fill [red, opacity=0.5,even odd rule,]
            (image.north west) rectangle (image.south east)
            (0,1) .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle
            (0,1) .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
            endtikzpicture

            enddocument





            share|improve this answer
























              up vote
              3
              down vote













              Seems, there was two times draw an one ; to much.



              enter image description here



              documentclass[border=10pt, tikz]standalone
              usepackagetikz
              definecolorbackgroundHTML2C414C
              definecolorforegroundHTMLFFFFFF
              usetikzlibrarypositioning,fit

              begindocument

              begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
              node (image) includegraphicsexample-image;
              fill [red, opacity=0.5,even odd rule]
              (image.north west) rectangle (image.south east) % Cover up everything
              (0,1) circle [radius=50pt]; % Punch a hole
              endtikzpicture

              begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
              node (image) includegraphicsexample-image;
              fill [red, opacity=0.5,even odd rule,]
              (image.north west) rectangle (image.south east)
              (0,1) .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle
              (0,1) .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
              endtikzpicture

              enddocument





              share|improve this answer






















                up vote
                3
                down vote










                up vote
                3
                down vote









                Seems, there was two times draw an one ; to much.



                enter image description here



                documentclass[border=10pt, tikz]standalone
                usepackagetikz
                definecolorbackgroundHTML2C414C
                definecolorforegroundHTMLFFFFFF
                usetikzlibrarypositioning,fit

                begindocument

                begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
                node (image) includegraphicsexample-image;
                fill [red, opacity=0.5,even odd rule]
                (image.north west) rectangle (image.south east) % Cover up everything
                (0,1) circle [radius=50pt]; % Punch a hole
                endtikzpicture

                begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
                node (image) includegraphicsexample-image;
                fill [red, opacity=0.5,even odd rule,]
                (image.north west) rectangle (image.south east)
                (0,1) .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle
                (0,1) .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
                endtikzpicture

                enddocument





                share|improve this answer












                Seems, there was two times draw an one ; to much.



                enter image description here



                documentclass[border=10pt, tikz]standalone
                usepackagetikz
                definecolorbackgroundHTML2C414C
                definecolorforegroundHTMLFFFFFF
                usetikzlibrarypositioning,fit

                begindocument

                begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
                node (image) includegraphicsexample-image;
                fill [red, opacity=0.5,even odd rule]
                (image.north west) rectangle (image.south east) % Cover up everything
                (0,1) circle [radius=50pt]; % Punch a hole
                endtikzpicture

                begintikzpicture[inner sep=0pt, outer sep=0pt, draw=foreground, fill=foreground]
                node (image) includegraphicsexample-image;
                fill [red, opacity=0.5,even odd rule,]
                (image.north west) rectangle (image.south east)
                (0,1) .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2) arc (180:0:0.75) -- cycle
                (0,1) .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2) arc (0:180:0.75) -- cycle;
                endtikzpicture

                enddocument






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 13 hours ago









                cis

                442412




                442412



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f454482%2ftikz-complex-mask-over-image-even-odd-rule%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)