Alpha value?
Alpha [in graphical use] is a measure of opaqueness.
Yes, it's fairly important to understand, if not so important to actually use.
Yes, it's fairly important to understand, if not so important to actually use.
Bear in mind that while the alpha value has historically meant 'opacity,' it's frequently abused into meaning other things - like reflectivity or brightness. At the end of the day it's just a number, and if you feed it to the parts of the system that deal with reflectivity or brightness instead of the parts of the system that deal with opacity, nothing will go "Hey, what? That's an alpha value dude, get it away from me."
Here is some java applet I did a while ago that uses it, so you can see it in action if you want to compile it etc.
import javax.swing.*;import java.awt.*;public class BallApplet extends JApplet{ BallThread b[] = new BallThread[20]; Color array[] = new Color[20]; public BouncingBallApplet(){ for(int x=0; x < b.length; ++x){ array[x] = new Color((int)(Math.random()*250),(int)(Math.random()*255),(int)(Math.random()*255),(int)(Math.random()*255)); b[x] = new BallThread((int)(Math.random()*800),(int)(Math.random()*60)); b[x].start(); } this.setSize(800,600); } public void paint(Graphics g){ g.setColor(array[(int)(Math.random()*array.length)]); g.fillOval(b[(int)(Math.random()*20)].xLoc,b[(int)(Math.random()*20)].yLoc,40,40); this.repaint(40); } public static void main(String args[]){ new BallApplet(); } public class BallThread extends Thread{ private int xLoc; private int yLoc; public BallThread(int x, int y){ xLoc = x; yLoc = y; } public void run(){ for(;;){ xLoc = (int)(Math.random()*800); yLoc = (int)(Math.random()*600); try{ this.sleep((long)(Math.random()*200)); }catch(InterruptedException e){ System.out.println(e.toString()); } } } }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement