|
3569 | 3569 | /** |
3570 | 3570 | * computes the minimum size of a node according to its inputs and output slots |
3571 | 3571 | * @method computeSize |
3572 | | - * @param {number} minHeight |
3573 | | - * @return {number} the total size |
| 3572 | + * @param {vec2} minHeight |
| 3573 | + * @return {vec2} the total size |
3574 | 3574 | */ |
3575 | 3575 | LGraphNode.prototype.computeSize = function(out) { |
3576 | 3576 | if (this.constructor.size) { |
@@ -9997,7 +9997,7 @@ LGraphNode.prototype.executeAction = function(action) |
9997 | 9997 | break; |
9998 | 9998 | case "slider": |
9999 | 9999 | var old_value = w.value; |
10000 | | - var nvalue = Math.clamp((x - 15) / (widget_width - 30), 0, 1); |
| 10000 | + var nvalue = clamp((x - 15) / (widget_width - 30), 0, 1); |
10001 | 10001 | if(w.options.read_only) break; |
10002 | 10002 | w.value = w.options.min + (w.options.max - w.options.min) * nvalue; |
10003 | 10003 | if (old_value != w.value) { |
@@ -13378,82 +13378,6 @@ LGraphNode.prototype.executeAction = function(action) |
13378 | 13378 | }; |
13379 | 13379 |
|
13380 | 13380 | //API ************************************************* |
13381 | | - //like rect but rounded corners |
13382 | | - if (typeof(window) != "undefined" && window.CanvasRenderingContext2D && !window.CanvasRenderingContext2D.prototype.roundRect) { |
13383 | | - window.CanvasRenderingContext2D.prototype.roundRect = function( |
13384 | | - x, |
13385 | | - y, |
13386 | | - w, |
13387 | | - h, |
13388 | | - radius, |
13389 | | - radius_low |
13390 | | - ) { |
13391 | | - var top_left_radius = 0; |
13392 | | - var top_right_radius = 0; |
13393 | | - var bottom_left_radius = 0; |
13394 | | - var bottom_right_radius = 0; |
13395 | | - |
13396 | | - if ( radius === 0 ) |
13397 | | - { |
13398 | | - this.rect(x,y,w,h); |
13399 | | - return; |
13400 | | - } |
13401 | | - |
13402 | | - if(radius_low === undefined) |
13403 | | - radius_low = radius; |
13404 | | - |
13405 | | - //make it compatible with official one |
13406 | | - if(radius != null && radius.constructor === Array) |
13407 | | - { |
13408 | | - if(radius.length == 1) |
13409 | | - top_left_radius = top_right_radius = bottom_left_radius = bottom_right_radius = radius[0]; |
13410 | | - else if(radius.length == 2) |
13411 | | - { |
13412 | | - top_left_radius = bottom_right_radius = radius[0]; |
13413 | | - top_right_radius = bottom_left_radius = radius[1]; |
13414 | | - } |
13415 | | - else if(radius.length == 4) |
13416 | | - { |
13417 | | - top_left_radius = radius[0]; |
13418 | | - top_right_radius = radius[1]; |
13419 | | - bottom_left_radius = radius[2]; |
13420 | | - bottom_right_radius = radius[3]; |
13421 | | - } |
13422 | | - else |
13423 | | - return; |
13424 | | - } |
13425 | | - else //old using numbers |
13426 | | - { |
13427 | | - top_left_radius = radius || 0; |
13428 | | - top_right_radius = radius || 0; |
13429 | | - bottom_left_radius = radius_low || 0; |
13430 | | - bottom_right_radius = radius_low || 0; |
13431 | | - } |
13432 | | - |
13433 | | - //top right |
13434 | | - this.moveTo(x + top_left_radius, y); |
13435 | | - this.lineTo(x + w - top_right_radius, y); |
13436 | | - this.quadraticCurveTo(x + w, y, x + w, y + top_right_radius); |
13437 | | - |
13438 | | - //bottom right |
13439 | | - this.lineTo(x + w, y + h - bottom_right_radius); |
13440 | | - this.quadraticCurveTo( |
13441 | | - x + w, |
13442 | | - y + h, |
13443 | | - x + w - bottom_right_radius, |
13444 | | - y + h |
13445 | | - ); |
13446 | | - |
13447 | | - //bottom left |
13448 | | - this.lineTo(x + bottom_right_radius, y + h); |
13449 | | - this.quadraticCurveTo(x, y + h, x, y + h - bottom_left_radius); |
13450 | | - |
13451 | | - //top left |
13452 | | - this.lineTo(x, y + bottom_left_radius); |
13453 | | - this.quadraticCurveTo(x, y, x + top_left_radius, y); |
13454 | | - }; |
13455 | | - }//if |
13456 | | - |
13457 | 13381 | function compareObjects(a, b) { |
13458 | 13382 | for (var i in a) { |
13459 | 13383 | if (a[i] != b[i]) { |
@@ -14182,10 +14106,10 @@ LGraphNode.prototype.executeAction = function(action) |
14182 | 14106 | return; |
14183 | 14107 | } |
14184 | 14108 | if( !is_edge_point ) //not edges |
14185 | | - point[0] = Math.clamp(x,0,1); |
| 14109 | + point[0] = clamp(x, 0, 1); |
14186 | 14110 | else |
14187 | 14111 | point[0] = s == 0 ? 0 : 1; |
14188 | | - point[1] = 1.0 - Math.clamp(y,0,1); |
| 14112 | + point[1] = 1.0 - clamp(y, 0, 1); |
14189 | 14113 | points.sort(function(a,b){ return a[0] - b[0]; }); |
14190 | 14114 | this.selected = points.indexOf(point); |
14191 | 14115 | this.must_update = true; |
@@ -14333,10 +14257,11 @@ LGraphNode.prototype.executeAction = function(action) |
14333 | 14257 | return oDOM.removeEventListener(sEvent, fCall, capture); |
14334 | 14258 | } |
14335 | 14259 | } |
14336 | | - |
14337 | | - Math.clamp = function(v, a, b) { |
| 14260 | + |
| 14261 | + function clamp(v, a, b) { |
14338 | 14262 | return a > v ? a : b < v ? b : v; |
14339 | 14263 | }; |
| 14264 | + global.clamp = clamp; |
14340 | 14265 |
|
14341 | 14266 | if (typeof window != "undefined" && !window["requestAnimationFrame"]) { |
14342 | 14267 | window.requestAnimationFrame = |
|
0 commit comments