-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyCanvas.java
More file actions
62 lines (48 loc) · 1.24 KB
/
MyCanvas.java
File metadata and controls
62 lines (48 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
@SuppressWarnings("serial")
public class MyCanvas extends Canvas{
//画面サイズ
public static final int CANVAS_WIDTH = 300;
public static final int CANVAS_HEIGHT = 300;
//ダブルバッファ用オフスクリーン
private Image offs;
private Graphics2D offg;
int plane;
MyDrawing d;
protected MyPolytope qube ;
public MyCanvas(int plane) {
setPolytope();
this.plane = plane;
}
public void setPolytope() {
qube = main4D.solid;
}
public void setWBuf(){
offs = createImage(CANVAS_WIDTH, CANVAS_HEIGHT);
offg = (Graphics2D)offs.getGraphics();
offg .setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
offg .setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
d = new MyDrawing(offg,qube,this.plane);
}
//imgを転送するだけ
public void paint(Graphics g){
//draw();
d.draw();
g.drawImage(offs,0,0,this);
}
//updateのオーバーライド
public void update(Graphics g){
paint(g);
}
public void reset() {
setPolytope();
d = new MyDrawing(offg,qube,this.plane);
repaint();
}
}