Skip to content

Instantly share code, notes, and snippets.

@hanslovsky
Last active November 4, 2019 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanslovsky/394842fa78c72696087034770b00a1a1 to your computer and use it in GitHub Desktop.
Save hanslovsky/394842fa78c72696087034770b00a1a1 to your computer and use it in GitHub Desktop.
import javafx.application.Platform
import javafx.util.Duration
def sources = paintera.baseView.sourceInfo()
def properties = paintera.properties
def bookmarkConfig = properties.bookmarkConfig
Platform.runLater({ sources.currentSourceIndexProperty().set(1)})
def manager = paintera.baseView.manager()
def duration = Duration.seconds(5.0)
def bookmarks = bookmarkConfig.unmodifiableBookmarks
for (int i = 0; i < 6; ++i) {
Platform.runLater( { manager.setTransform(bookmarks[(i+1) % 2].globalTransformCopy, duration) })
println(bookmarks[(i+1) % 2].globalTransformCopy)
Thread.sleep((long)(1.1*duration.toMillis()))
}
import java.lang.Double
import java.lang.Math
import javafx.animation.KeyFrame
import javafx.animation.KeyValue
import javafx.animation.Timeline
import javafx.application.Platform
import javafx.beans.property.DoubleProperty
import javafx.beans.property.SimpleDoubleProperty
import javafx.beans.value.ChangeListener
import javafx.scene.transform.Affine
import javafx.util.Duration
def baseView = paintera.baseView
def viewer3D = baseView.viewer3D
def initialTransform = new Affine()
viewer3D.getAffine(initialTransform)
def timeline = new Timeline(60.0)
timeline.setCycleCount(5)
timeline.setAutoReverse(false);
def currentState = new Affine();
def rotation = new SimpleDoubleProperty(0.0)
rotation.addListener(
{ DoubleProperty obs, Double oldv, Double newv ->
currentState.setToTransform(initialTransform)
currentState.prependRotation(newv, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
viewer3D.setAffine(currentState)
println("Updating state " + currentState)
println("Rotation is " + newv)
} as ChangeListener)
def duration = new Duration(6000)
def kv = new KeyValue(rotation, 360.0)//Math.PI)
timeline.getKeyFrames().add(new KeyFrame(duration, kv))
timeline.play()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment