-
Notifications
You must be signed in to change notification settings - Fork 0
/
Desenho.java
58 lines (37 loc) · 1.04 KB
/
Desenho.java
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
package edu.curso;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class Desenho extends Application{
@Override
public void start(Stage stg) throws Exception {
Group grp = new Group();
Scene scn = new Scene(grp, 640, 480);
Canvas canvas = new Canvas(640, 480);
grp.getChildren().add(canvas);
stg.setScene(scn);
GraphicsContext ctx = canvas.getGraphicsContext2D();
ctx.setStroke(Color.RED);
ctx.beginPath();
ctx.moveTo(320, 240);
ctx.lineTo(640, 0);
ctx.rect(50, 50, 200, 100);
ctx.stroke();
ctx.setStroke(Color.BLUE);
ctx.beginPath();
for (double altura = 0; altura < 100; altura += 10) {
double y = 100 - (altura / 2);
ctx.strokeOval(50, y, 200, altura);
}
ctx.stroke();
stg.setTitle("Desenho");
stg.show();
}
public static void main(String[] args) {
Application.launch(Desenho.class, args);
}
}