diff options
59 files changed, 2799 insertions, 1742 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index af860b95..4fb0a327 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -378,6 +378,10 @@ 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; | ||
381 | default: | 385 | default: |
382 | throw new Error( "Attempting to load unrecognized object type: " + type ); | 386 | throw new Error( "Attempting to load unrecognized object type: " + type ); |
383 | break; | 387 | break; |
@@ -1804,3 +1808,242 @@ NinjaCvsRt.RuntimePlasmaMaterial = Object.create(NinjaCvsRt.RuntimeMaterial, { | |||
1804 | }); | 1808 | }); |
1805 | 1809 | ||
1806 | 1810 | ||
1811 | |||
1812 | // ************************************************************************** | ||
1813 | // Runtime for the pen tool path | ||
1814 | // ************************************************************************** | ||
1815 | NinjaCvsRt.AnchorPoint = Object.create(Object.prototype, { | ||
1816 | ///////////////////////////////////////// | ||
1817 | // Instance variables | ||
1818 | ///////////////////////////////////////// | ||
1819 | _x: {value: 0.0, writable: true}, | ||
1820 | _y: {value: 0.0, writable: true}, | ||
1821 | _z: {value: 0.0, writable: true}, | ||
1822 | |||
1823 | _prevX: {value: 0.0, writable: true}, | ||
1824 | _prevY: {value: 0.0, writable: true}, | ||
1825 | _prevZ: {value: 0.0, writable: true}, | ||
1826 | |||
1827 | _nextX: {value: 0.0, writable: true}, | ||
1828 | _nextY: {value: 0.0, writable: true}, | ||
1829 | _nextZ: {value: 0.0, writable: true}, | ||
1830 | |||
1831 | // *********** setters ************ | ||
1832 | setPos: { | ||
1833 | value: function(x,y,z){ | ||
1834 | this._x = x; | ||
1835 | this._y = y; | ||
1836 | this._z = z; | ||
1837 | } | ||
1838 | }, | ||
1839 | |||
1840 | setPrevPos: { | ||
1841 | value: function (x, y, z) { | ||
1842 | this._prevX = x; | ||
1843 | this._prevY = y; | ||
1844 | this._prevZ = z; | ||
1845 | } | ||
1846 | }, | ||
1847 | |||
1848 | setNextPos: { | ||
1849 | value: function (x, y, z) { | ||
1850 | this._nextX = x; | ||
1851 | this._nextY = y; | ||
1852 | this._nextZ = z; | ||
1853 | } | ||
1854 | }, | ||
1855 | |||
1856 | // *************** getters ****************** | ||
1857 | // (add as needed) | ||
1858 | getPosX: { | ||
1859 | value: function () { | ||
1860 | return this._x; | ||
1861 | } | ||
1862 | }, | ||
1863 | |||
1864 | getPosY: { | ||
1865 | value: function () { | ||
1866 | return this._y; | ||
1867 | } | ||
1868 | }, | ||
1869 | |||
1870 | getPosZ: { | ||
1871 | value: function () { | ||
1872 | return this._z; | ||
1873 | } | ||
1874 | }, | ||
1875 | |||
1876 | getPrevX: { | ||
1877 | value: function () { | ||
1878 | return this._prevX; | ||
1879 | } | ||
1880 | }, | ||
1881 | |||
1882 | getPrevY: { | ||
1883 | value: function () { | ||
1884 | return this._prevY; | ||
1885 | } | ||
1886 | }, | ||
1887 | |||
1888 | getPrevZ: { | ||
1889 | value: function () { | ||
1890 | return this._prevZ; | ||
1891 | } | ||
1892 | }, | ||
1893 | |||
1894 | getNextX: { | ||
1895 | value: function () { | ||
1896 | return this._nextX; | ||
1897 | } | ||
1898 | }, | ||
1899 | |||
1900 | getNextY: { | ||
1901 | value: function () { | ||
1902 | return this._nextY; | ||
1903 | } | ||
1904 | }, | ||
1905 | |||
1906 | getNextZ: { | ||
1907 | value: function () { | ||
1908 | return this._nextZ; | ||
1909 | } | ||
1910 | } | ||
1911 | }); | ||
1912 | |||
1913 | NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, { | ||
1914 | // array of anchor points | ||
1915 | _Anchors: { value: null, writable: true }, | ||
1916 | |||
1917 | //path properties | ||
1918 | _isClosed: {value: false, writable: true}, | ||
1919 | _strokeWidth: {value: 0, writable: true}, | ||
1920 | _strokeColor: {value: null, writable: true}, | ||
1921 | _fillColor: {value: null, writable: true}, | ||
1922 | |||
1923 | geomType: { | ||
1924 | value: function () { | ||
1925 | return this.GEOM_TYPE_CUBIC_BEZIER; | ||
1926 | } | ||
1927 | }, | ||
1928 | |||
1929 | importJSON: { | ||
1930 | value: function(jo) { | ||
1931 | if (this.geomType()!== jo.geomType){ | ||
1932 | return; | ||
1933 | } | ||
1934 | //the geometry for this object | ||
1935 | this._Anchors = []; | ||
1936 | var i=0; | ||
1937 | for (i=0;i<jo.anchors.length;i++){ | ||
1938 | var newAnchor = Object.create(NinjaCvsRt.AnchorPoint); | ||
1939 | var ipAnchor = jo.anchors[i]; | ||
1940 | newAnchor.setPos(ipAnchor._x, ipAnchor._y, ipAnchor._z); | ||
1941 | newAnchor.setPrevPos(ipAnchor._prevX, ipAnchor._prevY, ipAnchor._prevZ); | ||