Switch to full style
General Java code examples
Post a reply

Use Alpha values to draw

Tue Nov 11, 2008 5:59 pm

Use Alpha values to draw
Code:
import java.awt.*;
import javax.swing.*;

public class UseAlphaValues extends JFrame {
int width, height;

  UseAlphaValues(String st) {
    this(st, 350, 300);
  }
  UseAlphaValues(String st, int w, int h) {
    setTitle(st);
    setSize(width = w, height = h);
    setBackground(Color.black);
    }
   public void paint(Graphics g) {
    Color color1 = new Color(150, 100, 100, 70);
    Color color2 = new Color(75, 150, 200, 125);
    Color color3 = new Color(120, 150, 200, 200);
    g.setColor(color1);
    g.fillOval(0, 0, width / 2, height / 2);
    g.setColor(color2);
    g.fillOval(width / 4, height / 4, width / 2, height / 2);
    g.setColor(color3);
    g.fillOval(width / 3, height / 3, width / 4, height / 4);
  }
  public static void main(String[] args) {
    new UseAlphaValues("Use Alpha values to draw in layers.")
      .setVisible(true);
  }
}



Attachments
layers.gif
output ,
layers.gif (6.35 KiB) Viewed 4371 times

Post a reply
  Related Posts  to : Use Alpha values to draw
 What is Alpha Reseller Master Reseller Hosting?     -  
 modulus of two values     -  
 EXTRACTING VALUES FROM XML FILE     -  
 Dividing two Integer values     -  
 Using Multiple Values for a Cookie in php     -  
 How can i Get Brightness and Contrast values of img     -  
 Calculate the sum of values in an array     -  
 Get image pixels Values in ITK     -  
 URL Characters and URL Encoding Values     -  
 Return all the values of an array using array_values     -  

Topic Tags

Java Graphics