Skip to content

Commit 46d9f48

Browse files
committed
Модуль canvasfx
1 parent 3348a51 commit 46d9f48

File tree

6 files changed

+1399
-1
lines changed

6 files changed

+1399
-1
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<libraryjar path="${javac.classpath}" />
5656
<libraryjar file="${java.home}/lib/rt.jar" />
57-
57+
<libraryjar file="${java.home}/lib/ext/jfxrt.jar" />
5858
</proguard>
5959

6060
<move file="${store.dir}/temp_final.jar" tofile="${obfuscated.jar}"/>

examples/canvas/fx_basic_shapes.own

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use "canvasfx"
2+
3+
// https://docs.oracle.com/javafx/2/canvas/jfxpub-canvas.htm
4+
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)
24+
repaint()

examples/canvas/fx_event_handlers.own

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use "canvasfx"
2+
use "std"
3+
4+
w = 800 h = 600
5+
window("JavaFX Event handler example", w, h)
6+
7+
addEventHandler(Events.MOUSE_MOVED, ::onMouseMoved)
8+
addEventHandler(Events.MOUSE_DRAGGED, ::onMouseMoved)
9+
addEventHandler(Events.KEY_PRESSED, def(e) {
10+
if (e.code == KeyCode.C) clearRect(0, 0, w, h)
11+
})
12+
13+
def onMouseMoved(e) {
14+
setFill(Color.rgb(rand(255), rand(255), rand(255), rand()))
15+
m = 1 + e.isPrimaryButtonDown + e.isSecondaryButtonDown
16+
radius = m * rand(30, 50)
17+
fillOval(e.x - radius/2, e.y - radius/2, radius, radius)
18+
}

examples/canvas/fx_global_alpha.own

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use "canvasfx"
2+
3+
steps = 20
4+
size = 25
5+
w = steps * (size * 1.25)
6+
h = size * 1.5
7+
8+
step = 1.0 / steps
9+
10+
window("JavaFX Global Alpha example", w, h)
11+
12+
setFill(Color.RED)
13+
y = size * 0.25
14+
for a = 0, a <= 1.0, a += step {
15+
setGlobalAlpha(a)
16+
fillRect(a * w, y, size, size)
17+
}

examples/canvas/fx_rotation.own

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use "canvasfx"
2+
use "std"
3+
4+
// http://www.developer.com/java/data/using-graphics-in-javafx.html
5+
6+
width = 800 height = 600
7+
window("JavaFX Rotation example", width, height)
8+
9+
translate(width / 2, height / 2)
10+
11+
def randomColor() = Color.rgb(rand(255), rand(255), rand(255), 0.9)
12+
13+
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],
23+
[150, 186, 186, 204, 246, 222, 246, 204, 186, 186], 10)
24+
}

0 commit comments

Comments
 (0)