Coloring a square grid by clicking

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











up vote
4
down vote

favorite












I want to make an interface where a user can fill in a square grid by clicking. Some processing will then be done with these pixels to produce a new picture. How can I make this clickable interface? I thought about linking each little square to a set of mouse positions, but this seems unnecessarily complicated.



Grid










share|improve this question







New contributor




gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    4
    down vote

    favorite












    I want to make an interface where a user can fill in a square grid by clicking. Some processing will then be done with these pixels to produce a new picture. How can I make this clickable interface? I thought about linking each little square to a set of mouse positions, but this seems unnecessarily complicated.



    Grid










    share|improve this question







    New contributor




    gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I want to make an interface where a user can fill in a square grid by clicking. Some processing will then be done with these pixels to produce a new picture. How can I make this clickable interface? I thought about linking each little square to a set of mouse positions, but this seems unnecessarily complicated.



      Grid










      share|improve this question







      New contributor




      gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I want to make an interface where a user can fill in a square grid by clicking. Some processing will then be done with these pixels to produce a new picture. How can I make this clickable interface? I thought about linking each little square to a set of mouse positions, but this seems unnecessarily complicated.



      Grid







      dynamic mouseposition






      share|improve this question







      New contributor




      gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 hour ago









      gilianzz

      1233




      1233




      New contributor




      gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      gilianzz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          just select n for a nxn grid



          n = 5;
          Grid[Partition[
          Table[DynamicModule[col = White,
          EventHandler[
          Dynamic[Graphics[EdgeForm[Thick], col, Rectangle,
          ImageSize ->
          Tiny]], "MouseClicked" :> (col =
          col /. Black -> White, White -> Black)]], n^2], n]]


          here is the result



          enter image description here






          share|improve this answer










          New contributor




          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















          • Is there a way to get the information out of the picture e.g. 0,0,0,1,1,1,0,1,0 for a 3x3 grid?
            – gilianzz
            9 mins ago










          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "387"
          ;
          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: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          gilianzz is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185240%2fcoloring-a-square-grid-by-clicking%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          5
          down vote



          accepted










          just select n for a nxn grid



          n = 5;
          Grid[Partition[
          Table[DynamicModule[col = White,
          EventHandler[
          Dynamic[Graphics[EdgeForm[Thick], col, Rectangle,
          ImageSize ->
          Tiny]], "MouseClicked" :> (col =
          col /. Black -> White, White -> Black)]], n^2], n]]


          here is the result



          enter image description here






          share|improve this answer










          New contributor




          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















          • Is there a way to get the information out of the picture e.g. 0,0,0,1,1,1,0,1,0 for a 3x3 grid?
            – gilianzz
            9 mins ago














          up vote
          5
          down vote



          accepted










          just select n for a nxn grid



          n = 5;
          Grid[Partition[
          Table[DynamicModule[col = White,
          EventHandler[
          Dynamic[Graphics[EdgeForm[Thick], col, Rectangle,
          ImageSize ->
          Tiny]], "MouseClicked" :> (col =
          col /. Black -> White, White -> Black)]], n^2], n]]


          here is the result



          enter image description here






          share|improve this answer










          New contributor




          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.

















          • Is there a way to get the information out of the picture e.g. 0,0,0,1,1,1,0,1,0 for a 3x3 grid?
            – gilianzz
            9 mins ago












          up vote
          5
          down vote



          accepted







          up vote
          5
          down vote



          accepted






          just select n for a nxn grid



          n = 5;
          Grid[Partition[
          Table[DynamicModule[col = White,
          EventHandler[
          Dynamic[Graphics[EdgeForm[Thick], col, Rectangle,
          ImageSize ->
          Tiny]], "MouseClicked" :> (col =
          col /. Black -> White, White -> Black)]], n^2], n]]


          here is the result



          enter image description here






          share|improve this answer










          New contributor




          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          just select n for a nxn grid



          n = 5;
          Grid[Partition[
          Table[DynamicModule[col = White,
          EventHandler[
          Dynamic[Graphics[EdgeForm[Thick], col, Rectangle,
          ImageSize ->
          Tiny]], "MouseClicked" :> (col =
          col /. Black -> White, White -> Black)]], n^2], n]]


          here is the result



          enter image description here







          share|improve this answer










          New contributor




          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer








          edited 5 mins ago





















          New contributor




          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered 45 mins ago









          shrap

          664




          664




          New contributor




          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          shrap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.











          • Is there a way to get the information out of the picture e.g. 0,0,0,1,1,1,0,1,0 for a 3x3 grid?
            – gilianzz
            9 mins ago
















          • Is there a way to get the information out of the picture e.g. 0,0,0,1,1,1,0,1,0 for a 3x3 grid?
            – gilianzz
            9 mins ago















          Is there a way to get the information out of the picture e.g. 0,0,0,1,1,1,0,1,0 for a 3x3 grid?
          – gilianzz
          9 mins ago




          Is there a way to get the information out of the picture e.g. 0,0,0,1,1,1,0,1,0 for a 3x3 grid?
          – gilianzz
          9 mins ago










          gilianzz is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          gilianzz is a new contributor. Be nice, and check out our Code of Conduct.












          gilianzz is a new contributor. Be nice, and check out our Code of Conduct.











          gilianzz is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f185240%2fcoloring-a-square-grid-by-clicking%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          Installing NextGIS Connect into QGIS 3?

          One-line joke