HISE Logo Forum
    • Categories
    • Register
    • Login

    Does path.contains() work properly? I am having issues with it.

    Scheduled Pinned Locked Moved Scripting
    3 Posts 2 Posters 186 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • VirtualVirginV
      VirtualVirgin
      last edited by VirtualVirgin

      I have a path here and I am trying to detect the mouse events inside the bounds of the path with path.contains():

      UpArrowPanel.setMouseCallback(function(event)
      {
          var inBounds = arrowPath.contains([event.x, event.y]);
          
          // Handle hover state
          if (event.hover)
      		inBounds ? isHovered = true : isHovered = false;
      etc..
      

      But the detection I am getting is clearly off from the actual path:

      Screen Recording 2025-03-19 at 3.33.36 PM.gif

      Here is a snippet of the arrow path with paint routine and mouse callback:

      HiseSnippet 1459.3ocsW0uaaaCDmJMpa1acaEXO.D4ujaxbscSZRVvPa9bMXMoF0oECnnnflhxhnxjBjzw0qnOY6kZuAaGojrk+HNoFXFvIl2we2c7ti2crsRRYZsTg7pd0nTFx6686LRXhONlvEnyOA48C9WPzFlBmQ5nQoDslEh77t2uaI3UYcj6y+7riHIDAkMgDB8VImxdIuO2LgZ6m+G7jjyHgrq38Ks6se94To3XYhb.XO2yuAJkP+HoG6Rhcaq4idAQGi7djOkt89r8hZsaiV6y1Ib6tsZ1fzpw96uKirSCZ28YjVQcoMPd2+zPtQp5XHFlFD5QxvQchkCEYJ3sbMuaBytnIpCn4Lxnii4IgsKbNZDxa81SbU2KyU8y9WvC4ioOwk8SNF3IHJ6z7VaYlTyuBSxqjIsdlI8P+NTEO0Lgi0d9N+yEPDLh.wlxlR1dQq82U7OVB6PXp2m7Q1YJXwXDAMa0XKL7mZGTsJDezF7aROTojCaSDrD7ugKvRBCcjB1n7F1XK71MreA7koWWyLAaLjGZh23FYGy38hM2LeRRhb3wve6BYJZXeabXRBdBgI1LwhrCkjv.Kt4A3G+Xb1J3LBQCbD7Uwz7+hK5gMwrL.kA2l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J+bnuhI8arzI8uql3C8ayMz3Eaiqs.aDhY+eXi4uO5A9mFEAMzmXfq6e1etpOF5VTeVu0dWPft+17jKGzuCTRmx.sKfjGsMkYMada15F10VOPGlHzs3egO4LaZW6kyrYASTeBUI+.M69n8EXeqiBXSB2KTq.OUFViahb2QK6m6COH7CT5zhZNfsVUfOYUAt8pBbmUE3SWUf6tp.261AZeu9gCfYayt1fPWz9TWQMOuSEDHCzksh9O.EyG8cB
      

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @VirtualVirgin
        last edited by

        @VirtualVirgin Because this is your actual arrow, the one that is used for the contains method

        Screenshot 2025-03-19 at 20.55.21.png

        as you can see when drawing it's real original size with:

        g.fillPath(arrowPath, arrowPath.getBounds(1.0));
        

        So when you draw it to another area (or scale), it won't change the fact that the original path boundaries are used.

        So if you want to draw it to another scale, it's in fact the original path that you have to scale, not it's drawing. The scaleToFit function should do what you want

        Can't help pressing F5 in the forum...

        VirtualVirginV 1 Reply Last reply Reply Quote 1
        • VirtualVirginV
          VirtualVirgin @ustk
          last edited by

          @ustk Oh that makes sense! And that method is a lot easier than what I was doing.

          You can listen to my orchestral mockups here:
          https://www.virtualvirgin.net/

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          19

          Online

          1.8k

          Users

          12.0k

          Topics

          104.7k

          Posts