Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/extensions/jwVector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ class Extension {
{
opcode: 'round',
text: '[ROUNDING] of [VECTOR]',
hideFromPalette: true,
arguments: {
ROUNDING: {
menu: 'roundingFunctions',
Expand All @@ -295,6 +296,17 @@ class Extension {
},
...Vector.Block
},
{
opcode: 'roundNew',
text: '[ROUNDING] of [VECTOR]',
arguments: {
ROUNDING: {
menu: 'roundingFunctionsAcceptReporters',
},
VECTOR: Vector.Argument
},
...Vector.Block
},
"---",
{
opcode: 'getPos',
Expand Down Expand Up @@ -355,6 +367,23 @@ class Extension {
}
]
},
roundingFunctionsAcceptReporters: { // needs to be separate to not break old projects
acceptReporters: true,
items: [
{
text: 'round',
value: 'round'
},
{
text: 'ceil',
value: 'ceil'
},
{
text: 'floor',
value: 'floor'
}
]
},
}
};
}
Expand Down Expand Up @@ -461,9 +490,15 @@ class Extension {
return new VectorType(Math.floor(v.x), Math.floor(v.y))
case 'ceil':
return new VectorType(Math.ceil(v.x), Math.ceil(v.y))
case 'round':
return new VectorType(Math.round(v.x), Math.round(v.y))
}

return new VectorType(Math.round(v.x), Math.round(v.y))
return v
}

roundNew(args) {
return this.round(args)
}

getPos({}, util) {
Expand Down