Модуль canvasfx

This commit is contained in:
Victor 2016-02-21 17:32:58 +02:00
parent 3348a513df
commit 46d9f48c32
6 changed files with 1399 additions and 1 deletions

View File

@ -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}"/>

View 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()

View 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)
}

View 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)
}

View 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)
}

File diff suppressed because it is too large Load Diff