Advertisement

[java] color gradients

Started by August 18, 2000 03:10 PM
0 comments, last by nap410 24 years, 4 months ago
Hi, i''m new to java. I know that java 1.2 has a builtin method in graphics2d to create a gradient given two colors, but I was wondering how it could be done in 1.0, thanks.
Hi;

Unfortunately, their is no built method for gradient filling in the Java 1.0 graphics classes (none that I've come across anyway), so you will have to do it manually. Say you want to go from black to blue.

        //assuming the applet width is at least 255for(int i = 0; i < 256; i++) {   g.setColor(new Color(0,0,i));   g.drawLine(i,0,i,getSize().height);}        


From this code you could apply different colors and such. Of course this is not the only way to do it,but it's all i've ever needed.

Hope this helped (a little ).

=============================
silly programmer vb is for kids.
============================
www.thejpsystem.com

Edited by - loserkid on August 18, 2000 6:13:33 PM
==============================================I feel like a kid in some kind of store... ============================================== www.thejpsystem.com

This topic is closed to new replies.

Advertisement