Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

[java] color gradients


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 nap410   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 August 2000 - 09:10 AM

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.

Sponsor:

#2 loserkid   Members   -  Reputation: 122

Like
Likes
Like

Posted 18 August 2000 - 11:12 AM

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 255

for(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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS