mirror of
https://github.com/aNNiMON/Own-Programming-Language-Tutorial.git
synced 2024-09-20 00:34:20 +03:00
Модуль canvasfx
This commit is contained in:
parent
3348a513df
commit
46d9f48c32
@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
<libraryjar path="${javac.classpath}" />
|
<libraryjar path="${javac.classpath}" />
|
||||||
<libraryjar file="${java.home}/lib/rt.jar" />
|
<libraryjar file="${java.home}/lib/rt.jar" />
|
||||||
|
<libraryjar file="${java.home}/lib/ext/jfxrt.jar" />
|
||||||
</proguard>
|
</proguard>
|
||||||
|
|
||||||
<move file="${store.dir}/temp_final.jar" tofile="${obfuscated.jar}"/>
|
<move file="${store.dir}/temp_final.jar" tofile="${obfuscated.jar}"/>
|
||||||
|
24
examples/canvas/fx_basic_shapes.own
Normal file
24
examples/canvas/fx_basic_shapes.own
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
use "canvasfx"
|
||||||
|
|
||||||
|
// https://docs.oracle.com/javafx/2/canvas/jfxpub-canvas.htm
|
||||||
|
|
||||||
|
window("JavaFX Basic shapes", 300, 250)
|
||||||
|
|
||||||
|
setFill(Color.GREEN)
|
||||||
|
setStroke(Color.BLUE)
|
||||||
|
setLineWidth(5)
|
||||||
|
strokeLine(40, 10, 10, 40)
|
||||||
|
fillOval(10, 60, 30, 30)
|
||||||
|
strokeOval(60, 60, 30, 30)
|
||||||
|
fillRoundRect(110, 60, 30, 30, 10, 10)
|
||||||
|
strokeRoundRect(160, 60, 30, 30, 10, 10)
|
||||||
|
fillArc(10, 110, 30, 30, 45, 240, ArcType.OPEN)
|
||||||
|
fillArc(60, 110, 30, 30, 45, 240, ArcType.CHORD)
|
||||||
|
fillArc(110, 110, 30, 30, 45, 240, ArcType.ROUND)
|
||||||
|
strokeArc(10, 160, 30, 30, 45, 240, ArcType.OPEN)
|
||||||
|
strokeArc(60, 160, 30, 30, 45, 240, ArcType.CHORD)
|
||||||
|
strokeArc(110, 160, 30, 30, 45, 240, ArcType.ROUND)
|
||||||
|
fillPolygon([10, 40, 10, 40], [210, 210, 240, 240], 4)
|
||||||
|
strokePolygon([60, 90, 60, 90], [210, 210, 240, 240], 4)
|
||||||
|
strokePolyline([110, 140, 110, 140], [210, 210, 240, 240], 4)
|
||||||
|
repaint()
|
18
examples/canvas/fx_event_handlers.own
Normal file
18
examples/canvas/fx_event_handlers.own
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use "canvasfx"
|
||||||
|
use "std"
|
||||||
|
|
||||||
|
w = 800 h = 600
|
||||||
|
window("JavaFX Event handler example", w, h)
|
||||||
|
|
||||||
|
addEventHandler(Events.MOUSE_MOVED, ::onMouseMoved)
|
||||||
|
addEventHandler(Events.MOUSE_DRAGGED, ::onMouseMoved)
|
||||||
|
addEventHandler(Events.KEY_PRESSED, def(e) {
|
||||||
|
if (e.code == KeyCode.C) clearRect(0, 0, w, h)
|
||||||
|
})
|
||||||
|
|
||||||
|
def onMouseMoved(e) {
|
||||||
|
setFill(Color.rgb(rand(255), rand(255), rand(255), rand()))
|
||||||
|
m = 1 + e.isPrimaryButtonDown + e.isSecondaryButtonDown
|
||||||
|
radius = m * rand(30, 50)
|
||||||
|
fillOval(e.x - radius/2, e.y - radius/2, radius, radius)
|
||||||
|
}
|
17
examples/canvas/fx_global_alpha.own
Normal file
17
examples/canvas/fx_global_alpha.own
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use "canvasfx"
|
||||||
|
|
||||||
|
steps = 20
|
||||||
|
size = 25
|
||||||
|
w = steps * (size * 1.25)
|
||||||
|
h = size * 1.5
|
||||||
|
|
||||||
|
step = 1.0 / steps
|
||||||
|
|
||||||
|
window("JavaFX Global Alpha example", w, h)
|
||||||
|
|
||||||
|
setFill(Color.RED)
|
||||||
|
y = size * 0.25
|
||||||
|
for a = 0, a <= 1.0, a += step {
|
||||||
|
setGlobalAlpha(a)
|
||||||
|
fillRect(a * w, y, size, size)
|
||||||
|
}
|
24
examples/canvas/fx_rotation.own
Normal file
24
examples/canvas/fx_rotation.own
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
use "canvasfx"
|
||||||
|
use "std"
|
||||||
|
|
||||||
|
// http://www.developer.com/java/data/using-graphics-in-javafx.html
|
||||||
|
|
||||||
|
width = 800 height = 600
|
||||||
|
window("JavaFX Rotation example", width, height)
|
||||||
|
|
||||||
|
translate(width / 2, height / 2)
|
||||||
|
|
||||||
|
def randomColor() = Color.rgb(rand(255), rand(255), rand(255), 0.9)
|
||||||
|
|
||||||
|
for i = 0, i < 60, i++ {
|
||||||
|
rotate(6.0)
|
||||||
|
setFill(randomColor())
|
||||||
|
fillOval(10, 60, 30, 30)
|
||||||
|
setStroke(randomColor())
|
||||||
|
strokeOval(60, 60, 30, 30)
|
||||||
|
setFill(randomColor())
|
||||||
|
fillRoundRect(110, 60, 30, 30, 10, 10)
|
||||||
|
setFill(randomColor())
|
||||||
|
fillPolygon([105, 117, 159, 123, 133, 105, 77, 87, 51, 93],
|
||||||
|
[150, 186, 186, 204, 246, 222, 246, 204, 186, 186], 10)
|
||||||
|
}
|
1315
src/com/annimon/ownlang/lib/modules/canvasfx.java
Normal file
1315
src/com/annimon/ownlang/lib/modules/canvasfx.java
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user