📄 colorblend1.java
字号:
// ColorBlend1.java
import java.awt.*;
import java.awt.image.*;
import java.applet.Applet;
public class ColorBlend1 extends Applet
{
Image im;
public void init ()
{
int width = getSize ().width;
int height = getSize ().height;
int [] pixels = new int [width * height];
int index = 0;
for (int y = 0; y < height; y++)
{
int numerator = y * 255;
int b = numerator / height;
int r = 255 - numerator / height;
for (int x = 0; x < width; x++)
{
int g = x * 255 / width;
pixels [index++] = (255 << 24) | (r << 16) | (g << 8)
| b;
}
}
im = createImage (new MemoryImageSource (width, height, pixels,
0, width));
}
public void paint (Graphics g)
{
g.drawImage (im, 0, 0, this);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -