HISE Logo Forum
    • Categories
    • Register
    • Login

    Draw panel / fade edges to alpha?

    Scheduled Pinned Locked Moved General Questions
    7 Posts 4 Posters 504 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.
    • Dan KorneffD
      Dan Korneff
      last edited by

      How would you draw a circle on a panel and fade the edges to alpha?

      nzMb8.png

      Dan Korneff - Producer / Mixer / Audio Nerd

      ustkU clevername27C 2 Replies Last reply Reply Quote 1
      • ustkU
        ustk @Dan Korneff
        last edited by

        @Dan-Korneff
        Not at my computer but

        • begin a layer
        • fill an ellipse
        • add a gaussian blur
        • end the layer

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

        Dan KorneffD 1 Reply Last reply Reply Quote 1
        • clevername27C
          clevername27 @Dan Korneff
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • Dan KorneffD
            Dan Korneff @ustk
            last edited by

            @ustk I'm seeing a faint outline of the panel when I use blur on top of a gradient filled panel
            Here's what my code looks like.

            	g.beginLayer(true);
            	g.setColour(Colours.black);
            	g.fillEllipse([30,30,this.getWidth()-60,this.getHeight()-60]);
            	g.gaussianBlur(30);
            	g.endLayer();
            

            And the image looks like this:

            Screenshot 2023-03-22 161022.jpg

            It might be hard to see, but there is a slight square outline at the bounds of the panel containing the circle.
            this does not happen if the background panel is painted in a solid color.

            Dan Korneff - Producer / Mixer / Audio Nerd

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

              @Dan-Korneff yeah I can see it
              Have you tried a lesser blur amount ?
              Or a box blur ?
              Might also be a good idea to paint it directly on the lower background panel if the design allows this

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

              Dan KorneffD 1 Reply Last reply Reply Quote 0
              • Dan KorneffD
                Dan Korneff @ustk
                last edited by

                @ustk said in Draw panel / fade edges to alpha?:

                paint it directly on the lower background panel if the design allows this

                This does look better, but only because the darkness has now been pushed to the outmost boundaries of the panel. I'm going to try box blur next.

                Dan Korneff - Producer / Mixer / Audio Nerd

                Christoph HartC 1 Reply Last reply Reply Quote 0
                • Christoph HartC
                  Christoph Hart @Dan Korneff
                  last edited by

                  I find myself using layers less and less because of subtle glitches like this - after all it has to rasterize the graphics context to an image and we're back in pixel land.

                  A non layer approach would use g.drawDropShadowFromPath() with a circle path:

                  const var Panel1 = Content.getComponent("Panel1");
                  
                  // that's a poor circle, but the blur will save us...
                  var circlePath = Content.createPath();
                  circlePath.startNewSubPath(0.5, 0);
                  circlePath.quadraticTo(1.0, 0.0, 1.0, 0.5);
                  circlePath.quadraticTo(1.0, 1.0, 0.5, 1.0);
                  circlePath.quadraticTo(0.0, 1.0, 0.0, 0.5);
                  circlePath.quadraticTo(0.0, 0.0, 0.5, 0.0);
                  
                  Panel1.set("width", Panel1.get("height"));
                  
                  Panel1.setPaintRoutine(function(g)
                  {
                  	g.drawDropShadowFromPath(circlePath, this.getLocalBounds(50), Colours.black, 50, [0, 0]);
                  });
                  
                  1 Reply Last reply Reply Quote 4
                  • First post
                    Last post

                  52

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  102.1k

                  Posts