Skip to content

Commit f570674

Browse files
committed
curve did not obey canvas setting
1 parent cd0b0eb commit f570674

5 files changed

Lines changed: 20 additions & 22 deletions

File tree

ForInstalledPython/glow.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GlowScriptOffline/glowscript_libraries/glow.2.7.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GlowScriptOffline2.7.zip

27 Bytes
Binary file not shown.

lib/glow/primitives.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,10 @@
16421642
return new curve(a) // so curve() is like new curve()
16431643
}
16441644
if (args.canvas !== null) { // it's null if first setting up objects; see subclass function
1645-
if (args.canvas !== undefined) initObject(this, curve, {canvas:args.canvas}) // e.g. called from helix
1645+
if (args.length == 1 && toType(args[0]) == 'object' && args[0].canvas !== undefined) {
1646+
initObject(this, curve, {canvas:args[0].canvas}) // e.g. called from helix
1647+
delete args[0].canvas
1648+
}
16461649
else initObject(this, curve, {})
16471650
this.__points = [] // list of point objects
16481651
this.__radius = 0 // means width of a few pixels
@@ -2013,11 +2016,9 @@
20132016
}
20142017
})
20152018

2016-
function points(args) { // TODO: shrinking a curve's extent doesn't trigger moving the camera inward; dunno why.
2019+
function points(args) {
20172020
if (!(this instanceof points)) {
2018-
var a = []
2019-
for (var i=0; i<arguments.length; i++) a.push(arguments[i])
2020-
return new points(a) // so curve() is like new curve()
2021+
return new points(arguments[0]) // so points() is like new points()
20212022
}
20222023
if (args.canvas !== null) { // it's null if first setting up objects; see subclass function
20232024
initObject(this, points, {})
@@ -2027,21 +2028,18 @@
20272028
this.__pixels = true
20282029
this.__opacity = 1
20292030
this.pickable = true
2030-
if (args.length == 1 && toType(args[0]) == 'object') {
2031-
var obj = args[0]
2032-
if (obj.size_units !== undefined) {
2033-
if (obj.size_units == 'pixels') this.__pixels = true
2034-
else if (obj.size_units == 'world') this.__pixels = false
2035-
else throw new Error('size_units must be "pixels" (the default) or "world".')
2036-
delete obj.size_units
2037-
}
2038-
for (var a in obj) { // include user variables
2039-
if (a === 'pos') continue
2040-
this[a] = obj[a]
2041-
delete obj[a]
2042-
}
2031+
if (args.size_units !== undefined) {
2032+
if (args.size_units == 'pixels') this.__pixels = true
2033+
else if (args.size_units == 'world') this.__pixels = false
2034+
else throw new Error('size_units must be "pixels" (the default) or "world".')
2035+
delete args.size_units
20432036
}
2044-
var temp = this.__setup(args) // returns [pos, specs]; specs irrelevant in constructor
2037+
for (var a in args) { // include user variables
2038+
if (a === 'pos') continue
2039+
this[a] = args[a]
2040+
delete args[a]
2041+
}
2042+
var temp = this.__setup([args]) // returns [pos, specs]; specs irrelevant in constructor
20452043
pos = temp[0]
20462044
if (pos.length > 0) this.__push_and_append(pos, {})
20472045
this.canvas.__points_objects.push(this)

package/glow.2.7.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)