/*****************************/ /* */ /*  お絵描きソフト第二回  */ /* */ /* 1998/ 5/20 宍戸 輝光 */ /* */ /*****************************/ import java.awt.*; class Gedcv2 extends Canvas { // キャンバス用クラス private Image img; private int w,h; private Graphics g_img; Gedcv2(Image im) { // コンストラクタ int i; w=200; // キャンバスの大きさ設定 h=200; resize(200,224); img=im; // 渡されたイメージをキャンバスのイメージに設定 g_img=img.getGraphics(); // キャンバスに描画するGrahics g_img.setColor(Color.white); // キャンバス初期化 g_img.fillRect(0,0,w,h); g_img.setColor(Color.black); g_img.drawRect(0,0,w-1,h-1); g_img.drawRect(15,207,171,11); drawGScale(0); g_img.setColor(new Color(0,0,0)); // 描画色設定 repaint(); } public boolean mouseDown(Event evt,int x,int y) { // マウスイベント int c; if (x>0 && y>0 && x15 && y>207 && x<186 && y<218) { // グレースケール内 c=(x-16)/10; // 何番目か調べる drawGScale(c); // グレースケール再描画 if (c==16) // 描画色を選択された色に設定 g_img.setColor(new Color(255,255,255)); else g_img.setColor(new Color(c*16,c*16,c*16)); repaint(); return true; } return false; } public boolean mouseDrag(Event evt,int x,int y) { int c; if (x>0 && y>0 && x