Flat, round, designer-friendly pseudo-3D engine for canvas & SVG
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

๐Ÿ›  add type property to all primitives

+37 -4
+9 -3
js/anchor.js
··· 214 214 }; 215 215 216 216 Anchor.prototype.toJSON = function () { 217 - var result = {}; 218 - var optionKeys = this.constructor.optionKeys; 217 + var type = this.type; 218 + var ignoreChildren = this.ignoreChildren || false; 219 + var result = { type: type }; 220 + var optionKeys = [...this.constructor.optionKeys]; 219 221 220 - [...optionKeys, 'children'].forEach(function (key) { 222 + if (!ignoreChildren) { 223 + optionKeys = [...optionKeys, 'children']; 224 + } 225 + 226 + optionKeys.forEach(function ( key ) { 221 227 if (['addTo', 'dragRotate', 'element', 'resize'].includes(key)) return; 222 228 var value = this[key]; 223 229 var defaults = this.constructor.defaults;
+4 -1
js/box.js
··· 18 18 // ----- BoxRect ----- // 19 19 20 20 var BoxRect = Rect.subclass(); 21 + 21 22 // prevent double-creation in parent.copyGraph() 22 23 // only create in Box.create() 23 - BoxRect.prototype.copyGraph = function() {}; 24 + BoxRect.prototype.copyGraph = function () { }; 24 25 25 26 // ----- Box ----- // 26 27 ··· 40 41 delete boxDefaults.path; 41 42 42 43 var Box = Anchor.subclass( boxDefaults ); 44 + Box.prototype.type = 'Box'; 45 + Box.prototype.ignoreChildren = true; 43 46 44 47 var TAU = utils.TAU; 45 48
+2
js/cone.js
··· 20 20 length: 1, 21 21 fill: true, 22 22 }); 23 + 24 + Cone.prototype.type = 'Cone'; 23 25 24 26 var TAU = utils.TAU; 25 27
+5
js/cylinder.js
··· 25 25 color: '#333', 26 26 updateSort: true, 27 27 }); 28 + 29 + CylinderGroup.prototype.type = 'CylinderGroup'; 28 30 29 31 CylinderGroup.prototype.create = function() { 30 32 Group.prototype.create.apply( this, arguments ); ··· 96 98 frontFace: undefined, 97 99 fill: true, 98 100 }); 101 + 102 + Cylinder.prototype.type = 'Cylinder'; 103 + 99 104 100 105 var TAU = utils.TAU; 101 106
+2
js/ellipse.js
··· 22 22 quarters: 4, 23 23 closed: false, 24 24 }); 25 + 26 + Ellipse.prototype.type = 'Ellipse'; 25 27 26 28 Ellipse.prototype.setPath = function() { 27 29 var width = this.width != undefined ? this.width : this.diameter;
+3
js/group.js
··· 18 18 updateSort: false, 19 19 visible: true, 20 20 }); 21 + 22 + Group.prototype.type = 'Group'; 23 + 21 24 22 25 // ----- update ----- // 23 26
+2
js/hemisphere.js
··· 17 17 var Hemisphere = Ellipse.subclass({ 18 18 fill: true, 19 19 }); 20 + 21 + Hemisphere.prototype.type = 'Hemisphere'; 20 22 21 23 var TAU = utils.TAU; 22 24
+2
js/illustration.js
··· 30 30 onDragEnd: noop, 31 31 onResize: noop, 32 32 }); 33 + 34 + Illustration.prototype.type = 'Illustration'; 33 35 34 36 utils.extend( Illustration.prototype, Dragger.prototype ); 35 37
+2
js/polygon.js
··· 18 18 sides: 3, 19 19 radius: 0.5, 20 20 }); 21 + 22 + Polygon.prototype.type = 'Polygon'; 21 23 22 24 var TAU = utils.TAU; 23 25
+2
js/rect.js
··· 18 18 width: 1, 19 19 height: 1, 20 20 }); 21 + 22 + Rect.prototype.type = 'Rect'; 21 23 22 24 Rect.prototype.setPath = function() { 23 25 var x = this.width / 2;
+2
js/rounded-rect.js
··· 20 20 cornerRadius: 0.25, 21 21 closed: false, 22 22 }); 23 + 24 + RoundedRect.prototype.type = 'RoundedRect'; 23 25 24 26 RoundedRect.prototype.setPath = function() { 25 27 /* eslint
+2
js/shape.js
··· 26 26 backface: true, 27 27 }); 28 28 29 + Shape.prototype.type = 'Shape'; 30 + 29 31 Shape.prototype.create = function( options ) { 30 32 Anchor.prototype.create.call( this, options ); 31 33 this.updatePath();