Strange_Fk Posted September 20, 2015 Posted September 20, 2015 If anybody knows the command/method used to alter the transparency of a fillRect() for paint that would be great. I tried looking it up and saw that it might be called alpha to alter this, however I can't figure out how to change alpha. The only command i can see is getAlpha(). If anyone could provide me with an example that would be great. I'm sure I can figure it out from there! Thanks in advance!
fixthissite Posted September 20, 2015 Posted September 20, 2015 (edited) Use a transparent color.Color has multiple constructors. The one that takes 4 int arguments is the one you want. The last argument is the "alpha": Color color = new Color(255, 0, 0, 100); void onPaint(Graphics2D g) { g.setColor(color); g.fillRect(...); } Edited September 20, 2015 by fixthissite 3
Apaec Posted September 20, 2015 Posted September 20, 2015 Use a transparent color. Color has multiple constructors. The one that takes 4 int arguments is the one you want. The last argument is the "alpha": Color color = new Color(255, 0, 0, 100); void onPaint(Graphics2D g) { g.setColor(color); g.fillRect(...); } This^ It is worth noting that, like the RGB values, the alpha constructor is also in the range 0-255 where 255 is solid colour. apa 2
Strange_Fk Posted September 22, 2015 Author Posted September 22, 2015 hell yeah thanks guys much appreciated! 1
Strange_Fk Posted September 22, 2015 Author Posted September 22, 2015 Ahh just realized it was you again FixThisSite! I'll post a screen of proggy tomorrow morning