Last active
November 4, 2019 03:25
-
-
Save hanslovsky/394842fa78c72696087034770b00a1a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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