diff options
49 files changed, 2355 insertions, 1293 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index af860b95..fe5f839c 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -378,6 +378,16 @@ NinjaCvsRt.GLRuntime = Object.create(Object.prototype, { | |||
378 | obj.importJSON( jObj ); | 378 | obj.importJSON( jObj ); |
379 | break; | 379 | break; |
380 | 380 | ||
381 | case 5: //subpath (created by pen tool) | ||
382 | obj = Object.create(NinjaCvsRt.RuntimeSubPath, {_materials: { value:[], writable:true}}); | ||
383 | obj.importJSON (jObj ); | ||
384 | break; | ||
385 | |||
386 | case 6: //brushstroke (created by brush tool) | ||
387 | obj = Object.create(NinjaCvsRt.RuntimeBrushStroke, {_materials: { value:[], writable:true}}); | ||
388 | obj.importJSON (jObj ); | ||
389 | break; | ||
390 | |||
381 | default: | 391 | default: |
382 | throw new Error( "Attempting to load unrecognized object type: " + type ); | 392 | throw new Error( "Attempting to load unrecognized object type: " + type ); |
383 | break; | 393 | break; |
@@ -520,6 +530,7 @@ NinjaCvsRt.RuntimeGeomObj = Object.create(Object.prototype, { | |||
520 | GEOM_TYPE_LINE: { value: 3, writable: false }, | 530 | GEOM_TYPE_LINE: { value: 3, writable: false }, |
521 | GEOM_TYPE_PATH: { value: 4, writable: false }, | 531 | GEOM_TYPE_PATH: { value: 4, writable: false }, |
522 | GEOM_TYPE_CUBIC_BEZIER: { value: 5, writable: false }, | 532 | GEOM_TYPE_CUBIC_BEZIER: { value: 5, writable: false }, |
533 | GEOM_TYPE_BRUSH_STROKE: { value: 6, writable: false }, | ||
523 | GEOM_TYPE_UNDEFINED: { value: -1, writable: false }, | 534 | GEOM_TYPE_UNDEFINED: { value: -1, writable: false }, |
524 | 535 | ||
525 | /////////////////////////////////////////////////////////////////////// | 536 | /////////////////////////////////////////////////////////////////////// |
@@ -1804,3 +1815,485 @@ NinjaCvsRt.RuntimePlasmaMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | |||
1804 | }); | 1815 | }); |
1805 | 1816 | ||
1806 | 1817 | ||
1818 | |||
1819 | // ************************************************************************** | ||
1820 | // Runtime for the pen tool path | ||
1821 | // ************************************************************************** | ||
1822 | NinjaCvsRt.AnchorPoint = Object.create(Object.prototype, { | ||
1823 | ///////////////////////////////////////// | ||
1824 | // Instance variables | ||
1825 | ///////////////////////////////////////// | ||
1826 | _x: {value: 0.0, writable: true}, | ||
1827 | _y: {value: 0.0, writable: true}, | ||
1828 | _z: {value: 0.0, writable: true}, | ||
1829 | |||
1830 | _prevX: {value: 0.0, writable: true}, | ||
1831 | _prevY: {value: 0.0, writable: true}, | ||
1832 | _prevZ: {value: 0.0, writable: true}, | ||
1833 | |||
1834 | _nextX: {value: 0.0, writable: true}, | ||
1835 | _nextY: {value: 0.0, writable: true}, | ||
1836 | _nextZ: {value: 0.0, writable: true}, | ||
1837 | |||
1838 | // *********** setters ************ | ||
1839 | setPos: { | ||
1840 | value: function(x,y,z){ | ||
1841 | this._x = x; | ||
1842 | this._y = y; | ||
1843 | this._z = z; | ||
1844 | } | ||
1845 | }, | ||
1846 | |||
1847 | setPrevPos: { | ||
1848 | value: function (x, y, z) { | ||
1849 | this._prevX = x; | ||
1850 | this._prevY = y; | ||
1851 | this._prevZ = z; | ||
1852 | } | ||
1853 | }, | ||
1854 | |||
1855 | setNextPos: { | ||
1856 | value: function (x, y, z) { | ||
1857 | this._nextX = x; | ||
1858 | this._nextY = y; | ||
1859 | this._nextZ = z; | ||
1860 | } | ||
1861 | }, | ||
1862 | |||
1863 | // *************** getters ****************** | ||
1864 | // (add as needed) | ||
1865 | getPosX: { | ||
1866 | value: function () { | ||
1867 | return this._x; | ||
1868 | } | ||
1869 | }, | ||
1870 | |||
1871 | getPosY: { | ||
1872 | value: function () { | ||
1873 | return this._y; | ||
1874 | } | ||
1875 | }, | ||
1876 | |||
1877 | getPosZ: { | ||
1878 | value: function () { | ||
1879 | return this._z; | ||
1880 | } | ||
1881 | }, | ||
1882 | |||
1883 | getPrevX: { | ||
1884 | value: function () { | ||
1885 | return this._prevX; | ||
1886 | } | ||
1887 | }, | ||
1888 | |||
1889 | getPrevY: { | ||
1890 | value: function () { | ||
1891 | return this._prevY; | ||
1892 | } | ||
1893 | }, | ||
1894 | |||
1895 | getPrevZ: { | ||
1896 | value: function () { | ||
1897 | return this._prevZ; | ||
1898 | } | ||
1899 | }, | ||
1900 | |||
1901 | getNextX: { | ||
1902 | value: function () { | ||
1903 | return this._nextX; | ||
1904 | } | ||
1905 | }, | ||
1906 | |||
1907 | getNextY: { | ||
1908 | value: function () { | ||
1909 | return this._nextY; | ||
1910 | } | ||
1911 | }, | ||
1912 | |||
1913 | getNextZ: { | ||
1914 | value: function () { | ||
1915 | return this._nextZ; | ||
1916 | } | ||
1917 | } | ||
1918 | }); | ||
1919 | |||
1920 | NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, { | ||
1921 | // array of anchor points | ||
1922 | _Anchors: { value: null, writable: true }, | ||
1923 | |||
1924 | //path properties | ||
1925 | _isClosed: {value: false, writable: true}, | ||
1926 | _strokeWidth: {value: 0, writable: true}, | ||
1927 | _strokeColor: {value: null, writable: true}, | ||
1928 | _fillColor: {value: null, writable: true}, | ||
1929 | |||
1930 | geomType: { | ||
1931 | value: function () { | ||
1932 | return this.GEOM_TYPE_CUBIC_BEZIER; | ||
1933 | } | ||
1934 | }, | ||
1935 | |||
1936 | importJSON: { | ||
1937 | value: function(jo) { | ||
1938 | if (this.geomType()!== jo.geomType){ | ||
1939 | return; | ||
1940 | } | ||
1941 | //the geometry for this object | ||
1942 | this._Anchors = []; | ||
1943 | var i=0; | ||
1944 | for (i=0;i<jo.anchors.length;i++){ | ||
1945 | var newAnchor = Object.create(NinjaCvsRt.AnchorPoint); | ||
1946 | var ipAnchor = jo.anchors[i]; | ||
1947 | newAnchor.setPos(ipAnchor._x, ipAnchor._y, ipAnchor._z); | ||