Skip to content

Commit a0f1355

Browse files
committed
GraphicsFXValue для canvasfx
1 parent 5e1f520 commit a0f1355

File tree

5 files changed

+247
-400
lines changed

5 files changed

+247
-400
lines changed

examples/canvas/fx_basic_shapes.own

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@ use "canvasfx"
22

33
// https://docs.oracle.com/javafx/2/canvas/jfxpub-canvas.htm
44

5-
window("JavaFX Basic shapes", 300, 250)
6-
7-
setFill(Color.GREEN)
8-
setStroke(Color.BLUE)
9-
setLineWidth(5)
10-
strokeLine(40, 10, 10, 40)
11-
fillOval(10, 60, 30, 30)
12-
strokeOval(60, 60, 30, 30)
13-
fillRoundRect(110, 60, 30, 30, 10, 10)
14-
strokeRoundRect(160, 60, 30, 30, 10, 10)
15-
fillArc(10, 110, 30, 30, 45, 240, ArcType.OPEN)
16-
fillArc(60, 110, 30, 30, 45, 240, ArcType.CHORD)
17-
fillArc(110, 110, 30, 30, 45, 240, ArcType.ROUND)
18-
strokeArc(10, 160, 30, 30, 45, 240, ArcType.OPEN)
19-
strokeArc(60, 160, 30, 30, 45, 240, ArcType.CHORD)
20-
strokeArc(110, 160, 30, 30, 45, 240, ArcType.ROUND)
21-
fillPolygon([10, 40, 10, 40], [210, 210, 240, 240], 4)
22-
strokePolygon([60, 90, 60, 90], [210, 210, 240, 240], 4)
23-
strokePolyline([110, 140, 110, 140], [210, 210, 240, 240], 4)
5+
g = window("JavaFX Basic shapes", 300, 250)
6+
g.setFill(Color.GREEN)
7+
g.setStroke(Color.BLUE)
8+
g.setLineWidth(5)
9+
g.strokeLine(40, 10, 10, 40)
10+
g.fillOval(10, 60, 30, 30)
11+
g.strokeOval(60, 60, 30, 30)
12+
g.fillRoundRect(110, 60, 30, 30, 10, 10)
13+
g.strokeRoundRect(160, 60, 30, 30, 10, 10)
14+
g.fillArc(10, 110, 30, 30, 45, 240, ArcType.OPEN)
15+
g.fillArc(60, 110, 30, 30, 45, 240, ArcType.CHORD)
16+
g.fillArc(110, 110, 30, 30, 45, 240, ArcType.ROUND)
17+
g.strokeArc(10, 160, 30, 30, 45, 240, ArcType.OPEN)
18+
g.strokeArc(60, 160, 30, 30, 45, 240, ArcType.CHORD)
19+
g.strokeArc(110, 160, 30, 30, 45, 240, ArcType.ROUND)
20+
g.fillPolygon([10, 40, 10, 40], [210, 210, 240, 240], 4)
21+
g.strokePolygon([60, 90, 60, 90], [210, 210, 240, 240], 4)
22+
g.strokePolyline([110, 140, 110, 140], [210, 210, 240, 240], 4)
2423
repaint()

examples/canvas/fx_event_handlers.own

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use "canvasfx"
22
use "std"
33

44
w = 800 h = 600
5-
window("JavaFX Event handler example", w, h)
5+
g = window("JavaFX Event handler example", w, h)
66

77
addEventHandler(Events.MOUSE_MOVED, ::onMouseMoved)
88
addEventHandler(Events.MOUSE_DRAGGED, ::onMouseMoved)
@@ -11,8 +11,8 @@ addEventHandler(Events.KEY_PRESSED, def(e) {
1111
})
1212

1313
def onMouseMoved(e) {
14-
setFill(Color.rgb(rand(255), rand(255), rand(255), rand()))
14+
g.setFill(Color.rgb(rand(255), rand(255), rand(255), rand()))
1515
m = 1 + e.isPrimaryButtonDown + e.isSecondaryButtonDown
1616
radius = m * rand(30, 50)
17-
fillOval(e.x - radius/2, e.y - radius/2, radius, radius)
17+
g.fillOval(e.x - radius/2, e.y - radius/2, radius, radius)
1818
}

examples/canvas/fx_global_alpha.own

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ h = size * 1.5
77

88
step = 1.0 / steps
99

10-
window("JavaFX Global Alpha example", w, h)
10+
g = window("JavaFX Global Alpha example", w, h)
1111

12-
setFill(Color.RED)
12+
g.setFill(Color.RED)
1313
y = size * 0.25
1414
for a = 0, a <= 1.0, a += step {
15-
setGlobalAlpha(a)
16-
fillRect(a * w, y, size, size)
15+
g.setGlobalAlpha(a)
16+
g.fillRect(a * w, y, size, size)
1717
}

examples/canvas/fx_rotation.own

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ use "std"
44
// http://www.developer.com/java/data/using-graphics-in-javafx.html
55

66
width = 800 height = 600
7-
window("JavaFX Rotation example", width, height)
7+
g = window("JavaFX Rotation example", width, height)
88

9-
translate(width / 2, height / 2)
9+
g.translate(width / 2, height / 2)
1010

1111
def randomColor() = Color.rgb(rand(255), rand(255), rand(255), 0.9)
1212

1313
for i = 0, i < 60, i++ {
14-
rotate(6.0)
15-
setFill(randomColor())
16-
fillOval(10, 60, 30, 30)
17-
setStroke(randomColor())
18-
strokeOval(60, 60, 30, 30)
19-
setFill(randomColor())
20-
fillRoundRect(110, 60, 30, 30, 10, 10)
21-
setFill(randomColor())
22-
fillPolygon([105, 117, 159, 123, 133, 105, 77, 87, 51, 93],
14+
g.rotate(6.0)
15+
g.setFill(randomColor())
16+
g.fillOval(10, 60, 30, 30)
17+
g.setStroke(randomColor())
18+
g.strokeOval(60, 60, 30, 30)
19+
g.setFill(randomColor())
20+
g.fillRoundRect(110, 60, 30, 30, 10, 10)
21+
g.setFill(randomColor())
22+
g.fillPolygon([105, 117, 159, 123, 133, 105, 77, 87, 51, 93],
2323
[150, 186, 186, 204, 246, 222, 246, 204, 186, 186], 10)
2424
}

0 commit comments

Comments
 (0)