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
3
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
    3
    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
      3
      down vote

      favorite









      up vote
      3
      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 2 hours ago

























      asked 2 hours ago









      kontextify

      1525




      1525




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote













          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






          share|improve this answer



























            up vote
            0
            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
              4
              down vote













              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






              share|improve this answer
























                up vote
                4
                down vote













                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






                share|improve this answer






















                  up vote
                  4
                  down vote










                  up vote
                  4
                  down vote









                  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






                  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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Ignasi

                  87.9k4158293




                  87.9k4158293




















                      up vote
                      0
                      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
                        0
                        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
                          0
                          down vote










                          up vote
                          0
                          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 1 hour ago









                          cis

                          410412




                          410412



























                               

                              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













































































                              Comments

                              Popular posts from this blog

                              White Anglo-Saxon Protestant

                              BuddyTV

                              Conflict (narrative)