Autoscaling working

This commit is contained in:
Luis Fernando Molina committed 2020-02-13 16:29:35 +01:00
1 parent f670bb2ffc
commit da3e8184de
3 files changed
+30 -1

No files matched your search

+28 -1
View File
@@ -15,6 +15,9 @@ function newCoordinateSystem () {
maxWidth: undefined,
scale: undefined,
eventHandler: undefined,
autosScale: true,
physics: physics,
reportValue: reportValue,
zoomX: zoomX,
zoomY: zoomY,
recalculateScale: recalculateScale,
@@ -44,6 +47,9 @@ function newCoordinateSystem () {
thisObject.eventHandler = newEventHandler()
thisObject.eventHandler.name = 'Coordinate System'
let newMax = -VERY_LARGE_NUMBER
let newMin = VERY_LARGE_NUMBER
return thisObject
function finalize () {
@@ -65,6 +71,28 @@ function newCoordinateSystem () {
recalculateScale()
}
function physics () {
if (thisObject.autosScale === true) {
if (thisObject.max.y !== newMax || thisObject.min.y !== newMin) {
thisObject.min.y = newMin
thisObject.max.y = newMax
thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x)
thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y)
}
newMax = -VERY_LARGE_NUMBER
newMin = VERY_LARGE_NUMBER
}
}
function reportValue (value) {
if (thisObject.autosScale === true) {
if (value > newMax) { newMax = value }
if (value < newMin) { newMin = value }
}
}
function zoomX (factor, mousePosition, container) {
let mouseAtCointainer = unTransformThisPoint(mousePosition, container)
let leftDistance = mouseAtCointainer.x
@@ -96,7 +124,6 @@ function newCoordinateSystem () {
}
function recalculateScale (event) {
/* Defines the initial Zoom level at center position. */
thisObject.scale.x = thisObject.maxWidth / (thisObject.max.x - thisObject.min.x)
thisObject.scale.y = thisObject.maxHeight / (thisObject.max.y - thisObject.min.y)
+1
View File
@@ -365,6 +365,7 @@ function newTimeMachine () {
function physics () {
thisObject.edgeEditor.physics()
timeMachineCoordinateSystem.physics()
saveFrame(thisObject.payload, thisObject.container.frame)
if (thisObject.container.frame.isInViewPort()) {
+1
View File
@@ -163,6 +163,7 @@ function newRateScale () {
}
function readObjectState () {
return
try {
let code = JSON.parse(thisObject.payload.node.code)