From e4aa505b91b569df7ebfcb698d63ce21e633a6db Mon Sep 17 00:00:00 2001 From: GoToLoop Date: Wed, 2 Dec 2020 09:35:44 -0300 Subject: [PATCH 1/2] PVector is float x, y, z container! http://Processing.GitHub.io/processing-javadocs/core/processing/core/PVector.html The way class PVector is defined in Trinket now makes it 100% useless! I can't convert Processing's Python Mode sketches to Trinket b/c its fields are declared as datatype int: * https://GitHub.com/trinketapp/processing.sk/blob/0.0.12/src/vector.js#L76-L82 * https://GitHub.com/trinketapp/processing.sk/blob/0.0.12/src/vector.js#L97-L102 Dunno whether this repo is active in order to apply the `int_` to `[ int_, float_ ]` urgent fix. --- src/vector.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vector.js b/src/vector.js index d62dd66..9994ca6 100644 --- a/src/vector.js +++ b/src/vector.js @@ -76,9 +76,9 @@ function vectorLimit(self, value) { function vectorClass($gbl, $loc) { $loc.__init__ = makeFunc(vectorInit, "__init__", [ self, - { "x": int_, optional }, - { "y": int_, optional }, - { "z": int_, optional } + { "x": [ int_, float_ ], optional }, + { "y": [ int_, float_ ], optional }, + { "z": [ int_, float_ ], optional } ]); $loc.__getattr__ = new Sk.builtin.func(function (self, key) { @@ -96,9 +96,9 @@ function vectorClass($gbl, $loc) { $loc.set = makeFunc(vectorSet, "set", [ self, - { "x": int_ }, - { "x": int_, optional }, - { "x": int_, optional } + { "x": [ int_, float_ ] }, + { "x": [ int_, float_ ], optional }, + { "x": [ int_, float_ ], optional } ]); $loc.mag = makeFunc(self => self.v.mag(), "mag", [ self ]); @@ -157,4 +157,4 @@ function vectorClass($gbl, $loc) { $loc.__repr__ = makeFunc(self => self.v.toString(), "repr", [ self ]); } -export default mod => buildClass(mod, vectorClass, "PVector", []); \ No newline at end of file +export default mod => buildClass(mod, vectorClass, "PVector", []); From 8ac90edd4b8fa34334a6e6c218bbee10cd08c32e Mon Sep 17 00:00:00 2001 From: GoToLoop Date: Wed, 2 Dec 2020 09:49:05 -0300 Subject: [PATCH 2/2] Fix method set() repeating prop 'x' thrice! --- src/vector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector.js b/src/vector.js index 9994ca6..86ac65b 100644 --- a/src/vector.js +++ b/src/vector.js @@ -97,8 +97,8 @@ function vectorClass($gbl, $loc) { $loc.set = makeFunc(vectorSet, "set", [ self, { "x": [ int_, float_ ] }, - { "x": [ int_, float_ ], optional }, - { "x": [ int_, float_ ], optional } + { "y": [ int_, float_ ], optional }, + { "z": [ int_, float_ ], optional } ]); $loc.mag = makeFunc(self => self.v.mag(), "mag", [ self ]);