⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 canvashs.java

📁 很不错的一个获取html色彩值的Applet
💻 JAVA
字号:
/*	ColorPicker v1.0 by Toh Lik Khoong
	Last revised 01/03/2001
	Please contact me at lktoh@navsurf.com for any comments or suggestions
	The source code is strictly for educational purposes and cannot be modified
	or used without the express permission of the author
	Visit http://navsurf.com for the latest version and other useful applets
*/

import java.awt.*;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;

public class CanvasHS extends Canvas{
	static final int HEIGHT = 255;
	static final int WIDTH = 255;

	private int[] colormap = new int[WIDTH*HEIGHT];
	private Image col = null;

	private Point cur_point = new Point();

	CanvasHS(){
		//super.setBackground(Color.black);
		super.resize(WIDTH, HEIGHT);
		for (int x = 0; x < WIDTH; x++){
			for (int y = 1; y <= HEIGHT; y++){
				colormap[x + (HEIGHT - y)*WIDTH] = Color.HSBtoRGB(((float) x)/HEIGHT, ((float) y)/WIDTH, (float) 0.75);
			}
		}
		col = createImage(new MemoryImageSource(WIDTH, HEIGHT, colormap, 0, WIDTH));
	}

	public Color getColorAt(int x, int y){
		Color couleur = new Color(colormap[x + y*WIDTH]);
		return couleur;
	}

	public void paint(Graphics g){
		g.drawImage(col, 0, 0, this);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -