diff options
-rw-r--r-- | assets/canvas-runtime.js | 1336 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 2 | ||||
-rwxr-xr-x | js/lib/drawing/world.js | 6 | ||||
-rwxr-xr-x | js/lib/geom/brush-stroke.js | 2 | ||||
-rwxr-xr-x | js/lib/geom/circle.js | 1433 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 852 | ||||
-rwxr-xr-x | js/lib/geom/line.js | 914 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 1409 | ||||
-rwxr-xr-x | js/lib/geom/sub-path.js | 2 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 3 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 2 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 2 |
12 files changed, 3072 insertions, 2891 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index 104c22cc..17f8cda8 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -305,16 +305,19 @@ NinjaCvsRt.GLRuntime = function ( canvas, jObj, assetPath ) | |||
305 | { | 305 | { |
306 | case 1: | 306 | case 1: |
307 | obj = new NinjaCvsRt.RuntimeRectangle(); | 307 | obj = new NinjaCvsRt.RuntimeRectangle(); |
308 | obj._materials = []; | ||
308 | obj.importJSON( jObj ); | 309 | obj.importJSON( jObj ); |
309 | break; | 310 | break; |
310 | 311 | ||
311 | case 2: // circle | 312 | case 2: // circle |
312 | obj = new NinjaCvsRt.RuntimeOval(); | 313 | obj = new NinjaCvsRt.RuntimeOval(); |
314 | obj._materials = []; | ||
313 | obj.importJSON( jObj ); | 315 | obj.importJSON( jObj ); |
314 | break; | 316 | break; |
315 | 317 | ||
316 | case 3: // line | 318 | case 3: // line |
317 | obj = new NinjaCvsRt.RuntimeLine(); | 319 | obj = new NinjaCvsRt.RuntimeLine(); |
320 | obj._materials = []; | ||
318 | obj.importJSON( jObj ); | 321 | obj.importJSON( jObj ); |
319 | break; | 322 | break; |
320 | 323 | ||
@@ -481,204 +484,205 @@ NinjaCvsRt.RuntimeGeomObj = function () | |||
481 | 484 | ||
482 | // array of materials | 485 | // array of materials |
483 | this._materials = []; | 486 | this._materials = []; |
487 | }; | ||
484 | 488 | ||
485 | /////////////////////////////////////////////////////////////////////// | 489 | //NinjaCvsRt.RuntimeGeomObj.prototype = Object.create(Object.prototype, {}); |
486 | // Property accessors | 490 | /////////////////////////////////////////////////////////////////////// |
487 | /////////////////////////////////////////////////////////////////////// | 491 | // Property accessors |
488 | 492 | /////////////////////////////////////////////////////////////////////// | |
489 | this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; }; | ||
490 | |||
491 | this.setWorld = function(w) { this._world = w; }; | ||
492 | this.getWorld = function() { return this._world; }; | ||
493 | 493 | ||
494 | /////////////////////////////////////////////////////////////////////// | 494 | NinjaCvsRt.RuntimeGeomObj.prototype.geomType = function() { return this.GEOM_TYPE_UNDEFINED; }; |
495 | // Methods | ||
496 | /////////////////////////////////////////////////////////////////////// | ||
497 | this.addChild = function( child ) | ||
498 | { | ||
499 | if (!this._children) this._children = []; | ||
500 | this._children.push( child ); | ||
501 | }; | ||
502 | 495 | ||
503 | this.importJSON = function() | 496 | NinjaCvsRt.RuntimeGeomObj.prototype.setWorld = function(w) { this._world = w; }; |
504 | { | 497 | NinjaCvsRt.RuntimeGeomObj.prototype.getWorld = function() { return this._world; }; |
505 | }; | ||
506 | 498 | ||
507 | this.importMaterials = function(jObj) | ||
508 | { | ||
509 | if (!jObj || !jObj.materials) return; | ||
510 | 499 | ||
511 | var nMaterials = jObj.nMaterials; | 500 | /////////////////////////////////////////////////////////////////////// |
512 | var matArray = jObj.materials; | 501 | // Methods |
513 | for (var i=0; i<nMaterials; i++) | 502 | /////////////////////////////////////////////////////////////////////// |
514 | { | 503 | NinjaCvsRt.RuntimeGeomObj.prototype.addChild = function( child ) |
515 | var mat; | 504 | { |
516 | var matObj = matArray[i].material; | 505 | if (!this._children) this._children = []; |
517 | var matNodeName = matArray[i].materialNodeName; | 506 | this._children.push( child ); |
518 | var shaderName = matObj.material; | 507 | }; |
519 | switch (shaderName) | ||
520 | { | ||
521 | case "flat": mat = new NinjaCvsRt.RuntimeFlatMaterial(); break; | ||
522 | case "radialGradient": mat = new NinjaCvsRt.RuntimeRadialGradientMaterial(); break; | ||
523 | case "linearGradient": mat = new NinjaCvsRt.RuntimeLinearGradientMaterial(); break; | ||
524 | case "bumpMetal": mat = new NinjaCvsRt.RuntimeBumpMetalMaterial(); break; | ||
525 | case "uber": mat = new NinjaCvsRt.RuntimeUberMaterial(); break; | ||
526 | case "plasma": mat = new NinjaCvsRt.RuntimePlasmaMaterial(); break; | ||
527 | |||
528 | case "deform": | ||
529 | case "water": | ||
530 | case "paris": | ||
531 | case "raiders": | ||
532 | case "tunnel": | ||
533 | case "reliefTunnel": | ||
534 | case "squareTunnel": | ||
535 | case "twist": | ||
536 | case "fly": | ||
537 | case "julia": | ||
538 | case "mandel": | ||
539 | case "star": | ||
540 | case "zinvert": | ||
541 | case "keleidoscope": | ||
542 | case "radialBlur": | ||
543 | case "pulse": mat = new NinjaCvsRt.RuntimePulseMaterial(); break; | ||
544 | |||
545 | default: | ||
546 | console.log( "material type: " + shaderName + " is not supported" ); | ||
547 | break; | ||
548 | } | ||
549 | 508 | ||
550 | if (mat) | 509 | NinjaCvsRt.RuntimeGeomObj.prototype.importJSON = function() |
551 | { | 510 | { |
552 | mat.importJSON( matObj ); | 511 | }; |
553 | mat._materialNodeName = matNodeName; | ||
554 | this._materials.push( mat ); | ||
555 | } | ||
556 | } | ||
557 | }; | ||
558 | 512 | ||
559 | //////////////////////////////////////////////////////////////////// | 513 | NinjaCvsRt.RuntimeGeomObj.prototype.importMaterials = function(jObj) |
560 | // vector function | 514 | { |
515 | if (!jObj || !jObj.materials) return; | ||
561 | 516 | ||
562 | this.vecAdd = function( dimen, a, b ) | 517 | var nMaterials = jObj.nMaterials; |
563 | { | 518 | var matArray = jObj.materials; |
564 | var rtnVec; | 519 | for (var i=0; i<nMaterials; i++) |
565 | if ((a.length < dimen) || (b.length < dimen)) | 520 | { |
521 | var mat; | ||
522 | var matObj = matArray[i].material; | ||
523 | var matNodeName = matArray[i].materialNodeName; | ||
524 | var shaderName = matObj.material; | ||
525 | switch (shaderName) | ||
566 | { | 526 | { |
567 | throw new Error( "dimension error in vecAdd" ); | 527 | case "flat": mat = new NinjaCvsRt.RuntimeFlatMaterial(); break; |
528 | case "radialGradient": mat = new NinjaCvsRt.RuntimeRadialGradientMaterial(); break; | ||
529 | case "linearGradient": mat = new NinjaCvsRt.RuntimeLinearGradientMaterial(); break; | ||
530 | case "bumpMetal": mat = new NinjaCvsRt.RuntimeBumpMetalMaterial(); break; | ||
531 | case "uber": mat = new NinjaCvsRt.RuntimeUberMaterial(); break; | ||
532 | case "plasma": mat = new NinjaCvsRt.RuntimePlasmaMaterial(); break; | ||
533 | |||
534 | case "deform": | ||
535 | case "water": | ||
536 | case "paris": | ||
537 | case "raiders": | ||
538 | case "tunnel": | ||
539 | case "reliefTunnel": | ||
540 | case "squareTunnel": | ||
541 | case "twist": | ||
542 | case "fly": | ||
543 | case "julia": | ||
544 | case "mandel": | ||
545 | case "star": | ||
546 | case "zinvert": | ||
547 | case "keleidoscope": | ||
548 | case "radialBlur": | ||
549 | case "pulse": mat = new NinjaCvsRt.RuntimePulseMaterial(); break; | ||
550 | |||
551 | default: | ||
552 | console.log( "material type: " + shaderName + " is not supported" ); | ||
553 | break; | ||
568 | } | 554 | } |
569 | 555 | ||
570 | rtnVec = []; | 556 | if (mat) |
571 | for (var i=0; i<dimen; i++) | 557 | { |
572 | rtnVec[i] = a[i] + b[i]; | 558 | mat.importJSON( matObj ); |
559 | mat._materialNodeName = matNodeName; | ||
560 | this._materials.push( mat ); | ||
561 | } | ||
562 | } | ||
563 | }; | ||
573 | 564 | ||
574 | return rtnVec; | 565 | //////////////////////////////////////////////////////////////////// |
575 | }; | 566 | // vector function |
567 | NinjaCvsRt.RuntimeGeomObj.prototype.vecAdd = function( dimen, a, b ) | ||
568 | { | ||
569 | var rtnVec; | ||
570 | if ((a.length < dimen) || (b.length < dimen)) | ||
571 | { | ||
572 | throw new Error( "dimension error in vecAdd" ); | ||
573 | } | ||
576 | 574 | ||
575 | rtnVec = []; | ||
576 | for (var i=0; i<dimen; i++) | ||
577 | rtnVec[i] = a[i] + b[i]; | ||
577 | 578 | ||
578 | this.vecSubtract = function( dimen, a, b ) | 579 | return rtnVec; |
579 | { | 580 | }; |
580 | var rtnVec; | ||
581 | if ((a.length < dimen) || (b.length < dimen)) | ||
582 | { | ||
583 | throw new Error( "dimension error in vecSubtract" ); | ||
584 | } | ||
585 | 581 | ||
586 | rtnVec = []; | ||
587 | for (var i=0; i<dimen; i++) | ||
588 | rtnVec[i] = a[i] - b[i]; | ||
589 | 582 | ||
590 | return rtnVec; | 583 | NinjaCvsRt.RuntimeGeomObj.prototype.vecSubtract = function( dimen, a, b ) |
591 | }; | 584 | { |
585 | var rtnVec; | ||