Java 3 Color Gradient

前端 未结 2 930
孤独总比滥情好
孤独总比滥情好 2021-01-12 02:50

I have a JPanel, and I would like to paint a gradient within it. I have the code below, but that only paints a 2 color gradient. I would like to add a 3rd but d

2条回答
  •  一生所求
    2021-01-12 03:50

    Take a look at LinearGradientPaint, it allows you to specify n number of colours and their weights.

    Update 1

    With a "small" change in requirements, it is debatable if either LinearGradientPaint over GradientPant will have any significant effect in performance.

    I highly recommend that you take a look at Harmonic Code. This guy does some really interesting posts, and some on gradients. ;)

    Update 2

    Knew I'd seen something like it before Bilinear color interpolation.

提交回复
热议问题