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

Configure Feed

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

at main 38 lines 794 B view raw
1/** 2 * Shape 3 */ 4 5( function( root, factory ) { 6 // module definition 7 if ( typeof module == 'object' && module.exports ) { 8 // CommonJS 9 module.exports = factory( require('./boilerplate'), require('./shape') ); 10 } else { 11 // browser global 12 var Zdog = root.Zdog; 13 Zdog.Polygon = factory( Zdog, Zdog.Shape ); 14 } 15}( this, function factory( utils, Shape ) { 16 17var Polygon = Shape.subclass({ 18 sides: 3, 19 radius: 0.5, 20}); 21 22Polygon.type = 'Polygon'; 23 24var TAU = utils.TAU; 25 26Polygon.prototype.setPath = function() { 27 this.path = []; 28 for ( var i = 0; i < this.sides; i++ ) { 29 var theta = i / this.sides * TAU - TAU/4; 30 var x = Math.cos( theta ) * this.radius; 31 var y = Math.sin( theta ) * this.radius; 32 this.path.push({ x: x, y: y }); 33 } 34}; 35 36return Polygon; 37 38} ) );