From de4811c6e5417270ad9b1a056574b49bc7fa023e Mon Sep 17 00:00:00 2001 From: Brev Patterson Date: Sun, 21 Sep 2014 02:33:40 -0700 Subject: [PATCH 1/4] Publish svg.shapes.js@0.0.1 to npm --- MIT-LICENSE | 21 +++++++++++++++++++++ package.json | 30 ++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 MIT-LICENSE create mode 100755 package.json diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100755 index 0000000..92730ed --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2012-2014 Wout Fierens +http://svgjs.com/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/package.json b/package.json new file mode 100755 index 0000000..4965f67 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "svg.shapes.js" +, "description": "A shapes plugin for the svg.js library" +, "url": "https://github.com/wout/svg.shapes.js" +, "homepage": "http://svgjs.com" +, "keywords": ["svg", "shapes", "vector", "graphics", "animation"] +, "author": "Wout Fierens " +, "main": "svg.shapes.js" +, "version": "0.0.1" +, "maintainers": [ + { + "name": "Wout Fierens" + , "email": "wout@woutfierens.com" + , "web": "http://woutfierens.com" + } + ] +, "licenses": [ + { + "type": "MIT" + , "url": "http://www.opensource.org/licenses/mit-license.php" + } + ] +, "repositories": [ + { + "type": "git" + , "url": "https://github.com/wout/svg.shapes.js.git" + } + ] +, "github": "https://github.com/wout/svg.shapes.js" +} From 40bc0b80cf750c338bebe23ec6f7e5b48e35756a Mon Sep 17 00:00:00 2001 From: Brev Patterson Date: Sun, 21 Sep 2014 05:55:45 -0700 Subject: [PATCH 2/4] npm access, for pkg publish @ 0.0.2 --- CHANGELOG.md | 7 +++++++ README.md | 34 ++++++++++++++++++++++++++++++++-- package.json | 24 +++++++++++------------- svg.shapes.js | 44 ++++++++++++++++++++++++++++---------------- svg.shapes.min.js | 4 ++-- 5 files changed, 80 insertions(+), 33 deletions(-) create mode 100755 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100755 index 0000000..5a831c4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# 0.0.2 (09/21/2014) + +- create package.json for npm@0.0.2 + +# 0.0.1 (08/05/2013) + +- init diff --git a/README.md b/README.md index c5fc649..691d7b7 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,39 @@ This is a plugin for the [svg.js](http://svgjs.com) library to draw various shape types based on the built-in polygon method. -Svg.easing.js is licensed under the terms of the MIT License. +Svg.shapes.js is licensed under the terms of the MIT License. ## Usage +### Browser + Include this plugin after including svg.js in your html document. +### Node + +$ `npm install svg.js svg.shapes.js` + +Autoload svg.js: + +```javascript +var svg = require('svg.shapes.js') + +``` + +Or, augment an existing svg.js object: + +```javascript +var svgjs = require('svg.js') + , svg = require('svg.shapes.js')(svgjs) + +``` + + +## Methods + ### Star + Three parameters are required to draw a star, `inner` radius, `outer` radius and `spikes`: ```javascript @@ -36,6 +61,7 @@ Note that this will return an instance of `SVG.PointArray`. ### Ngon + The `ngon()` method only requires two parameters, `radius` and `edges`: ```javascript @@ -61,6 +87,7 @@ Note that this will return an instance of `SVG.PointArray`. ## To-do + - Cog wheel - Wedge - Arc @@ -68,5 +95,8 @@ Note that this will return an instance of `SVG.PointArray`. Head start: http://pastie.org/929979 + ## Dependencies -This module requires svg.js v0.31. \ No newline at end of file + +This module requires svg.js v0.31. + diff --git a/package.json b/package.json index 4965f67..b3f2298 100755 --- a/package.json +++ b/package.json @@ -6,25 +6,23 @@ , "keywords": ["svg", "shapes", "vector", "graphics", "animation"] , "author": "Wout Fierens " , "main": "svg.shapes.js" -, "version": "0.0.1" +, "version": "0.0.2" , "maintainers": [ { - "name": "Wout Fierens" - , "email": "wout@woutfierens.com" - , "web": "http://woutfierens.com" + "name": "Wout Fierens" + , "email": "wout@woutfierens.com" + , "web": "http://woutfierens.com" } ] , "licenses": [ { - "type": "MIT" - , "url": "http://www.opensource.org/licenses/mit-license.php" + "type": "MIT" + , "url": "http://www.opensource.org/licenses/mit-license.php" } ] -, "repositories": [ - { - "type": "git" - , "url": "https://github.com/wout/svg.shapes.js.git" - } - ] -, "github": "https://github.com/wout/svg.shapes.js" +, "repository": { + "type": "git" + , "url": "https://github.com/wout/svg.shapes.js.git" + } +, "github": "https://github.com/wout/svg.shapes.js" } diff --git a/svg.shapes.js b/svg.shapes.js index 51f07f2..3aef54f 100644 --- a/svg.shapes.js +++ b/svg.shapes.js @@ -1,6 +1,20 @@ -// svg.shapes.js 0.11 - Copyright (c) 2013 Wout Fierens - Licensed under the MIT license - -;(function() { +// svg.shapes.js 0.0.2 - Copyright (c) 2013-2014 Wout Fierens - Licensed under the MIT license +;(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(factory(root.SVG)); + } + else if (typeof exports === 'object') { + module.exports = function(svgjs) { + if(! svgjs) svgjs = require('svg.js') + svgjs = factory(svgjs) + return svgjs + } + } + else { + root.SVG = factory(root.SVG) + } +}(this, function(SVG) { + var SVG = this.SVG = SVG var defaults = { spikes: 7 @@ -9,7 +23,7 @@ , edges: 7 , radius: 100 } - + // Add builders to polygon SVG.extend(SVG.Polyline, SVG.Polygon, { // Dynamic star shape @@ -18,7 +32,7 @@ /* merge user input */ this.settings = merge(this.settings, settings) - + return this.plot(SVG.shapes.star(this.settings).move(box.x, box.y)) } // Dynamic ngon shape @@ -30,7 +44,6 @@ return this.plot(SVG.shapes.ngon(this.settings).move(box.x, box.y)) } - }) // Make shapes animatable @@ -53,10 +66,8 @@ return this.plot(SVG.shapes.ngon(this.target.settings).move(box.x, box.y)) } - }) - // Shape generator SVG.shapes = { // Star generator @@ -64,8 +75,8 @@ var i, a, x, y , points = [] , spikes = typeof settings.spikes == 'number' ? settings.spikes : defaults.spikes - , inner = typeof settings.inner == 'number' ? settings.inner : defaults.inner - , outer = typeof settings.outer == 'number' ? settings.outer : defaults.outer + , inner = typeof settings.inner == 'number' ? settings.inner : defaults.inner + , outer = typeof settings.outer == 'number' ? settings.outer : defaults.outer , degrees = 360 / spikes for (i = 0; i < spikes; i++) { @@ -88,18 +99,18 @@ , ngon: function(settings) { var i, a, x, y , points = [] - , edges = typeof settings.edges == 'number' ? settings.edges : defaults.edges + , edges = typeof settings.edges == 'number' ? settings.edges : defaults.edges , radius = typeof settings.radius == 'number' ? settings.radius : defaults.radius , degrees = 360 / edges - + for (i = 0; i < edges; i++) { a = i * degrees - 90 x = radius + radius * Math.cos(a * Math.PI / 180) y = radius + radius * Math.sin(a * Math.PI / 180) - + points.push([x, y]) } - + return new SVG.PointArray(points) } } @@ -123,5 +134,6 @@ return settings } - -}).call(this) \ No newline at end of file + + return SVG +})) diff --git a/svg.shapes.min.js b/svg.shapes.min.js index 16637e2..4075024 100644 --- a/svg.shapes.min.js +++ b/svg.shapes.min.js @@ -1,2 +1,2 @@ -// svg.shapes.js 0.11 - Copyright (c) 2013 Wout Fierens - Licensed under the MIT license -;(function(){function t(t,n){var r,i={};t=t||{};n=n||{};for(r in e)i[r]=typeof n[r]==="number"?n[r]:typeof t[r]==="number"?t[r]:e[r];return i}var e={spikes:7,inner:50,outer:100,edges:7,radius:100};SVG.extend(SVG.Polyline,SVG.Polygon,{star:function(e){var n=this.bbox();this.settings=t(this.settings,e);return this.plot(SVG.shapes.star(this.settings).move(n.x,n.y))},ngon:function(e){var n=this.bbox();this.settings=t(this.settings,e);return this.plot(SVG.shapes.ngon(this.settings).move(n.x,n.y))}});SVG.extend(SVG.FX,{star:function(e){var n=this.bbox();this.target.settings=t(this.target.settings,e);return this.plot(SVG.shapes.star(this.target.settings).move(n.x,n.y))},ngon:function(e){var n=this.bbox();this.target.settings=t(this.target.settings,e);return this.plot(SVG.shapes.ngon(this.target.settings).move(n.x,n.y))}});SVG.shapes={star:function(t){var n,r,i,s,o=[],u=typeof t.spikes=="number"?t.spikes:e.spikes,a=typeof t.inner=="number"?t.inner:e.inner,f=typeof t.outer=="number"?t.outer:e.outer,l=360/u;for(n=0;n Date: Sun, 21 Sep 2014 07:44:09 -0700 Subject: [PATCH 3/4] more --- README.md | 10 +--------- svg.shapes.js | 7 +++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 691d7b7..aa12e97 100644 --- a/README.md +++ b/README.md @@ -15,19 +15,11 @@ Include this plugin after including svg.js in your html document. $ `npm install svg.js svg.shapes.js` -Autoload svg.js: - -```javascript -var svg = require('svg.shapes.js') - -``` - -Or, augment an existing svg.js object: +Augment an existing svg.js object: ```javascript var svgjs = require('svg.js') , svg = require('svg.shapes.js')(svgjs) - ``` diff --git a/svg.shapes.js b/svg.shapes.js index 3aef54f..9e41011 100644 --- a/svg.shapes.js +++ b/svg.shapes.js @@ -5,17 +5,16 @@ } else if (typeof exports === 'object') { module.exports = function(svgjs) { - if(! svgjs) svgjs = require('svg.js') - svgjs = factory(svgjs) - return svgjs + return factory(svgjs) } } else { root.SVG = factory(root.SVG) } + return }(this, function(SVG) { var SVG = this.SVG = SVG - +console.log(1); var defaults = { spikes: 7 , inner: 50 From 47732d1e9fb82c75b9a05d03a17b8a184c296208 Mon Sep 17 00:00:00 2001 From: Brev Patterson Date: Sun, 21 Sep 2014 07:46:47 -0700 Subject: [PATCH 4/4] more --- svg.shapes.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/svg.shapes.js b/svg.shapes.js index 9e41011..1d30b78 100644 --- a/svg.shapes.js +++ b/svg.shapes.js @@ -11,10 +11,9 @@ else { root.SVG = factory(root.SVG) } - return }(this, function(SVG) { var SVG = this.SVG = SVG -console.log(1); + var defaults = { spikes: 7 , inner: 50