Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish npm 0.0.2 #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 0.0.2 (09/21/2014)

- create package.json for [email protected]

# 0.0.1 (08/05/2013)

- init
21 changes: 21 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -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.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@

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`

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
Expand All @@ -36,6 +53,7 @@ Note that this will return an instance of `SVG.PointArray`.


### Ngon

The `ngon()` method only requires two parameters, `radius` and `edges`:

```javascript
Expand All @@ -61,12 +79,16 @@ Note that this will return an instance of `SVG.PointArray`.


## To-do

- Cog wheel
- Wedge
- Arc
- Cross

Head start: http://pastie.org/929979


## Dependencies
This module requires svg.js v0.31.

This module requires svg.js v0.31.

28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"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 <[email protected]>"
, "main": "svg.shapes.js"
, "version": "0.0.2"
, "maintainers": [
{
"name": "Wout Fierens"
, "email": "[email protected]"
, "web": "http://woutfierens.com"
}
]
, "licenses": [
{
"type": "MIT"
, "url": "http://www.opensource.org/licenses/mit-license.php"
}
]
, "repository": {
"type": "git"
, "url": "https://github.com/wout/svg.shapes.js.git"
}
, "github": "https://github.com/wout/svg.shapes.js"
}
42 changes: 26 additions & 16 deletions svg.shapes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
// 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) {
return factory(svgjs)
}
}
else {
root.SVG = factory(root.SVG)
}
}(this, function(SVG) {
var SVG = this.SVG = SVG

var defaults = {
spikes: 7
Expand All @@ -9,7 +21,7 @@
, edges: 7
, radius: 100
}

// Add builders to polygon
SVG.extend(SVG.Polyline, SVG.Polygon, {
// Dynamic star shape
Expand All @@ -18,7 +30,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
Expand All @@ -30,7 +42,6 @@

return this.plot(SVG.shapes.ngon(this.settings).move(box.x, box.y))
}

})

// Make shapes animatable
Expand All @@ -53,19 +64,17 @@

return this.plot(SVG.shapes.ngon(this.target.settings).move(box.x, box.y))
}

})


// Shape generator
SVG.shapes = {
// Star generator
star: function(settings) {
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++) {
Expand All @@ -88,18 +97,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)
}
}
Expand All @@ -123,5 +132,6 @@

return settings
}

}).call(this)

return SVG
}))
4 changes: 2 additions & 2 deletions svg.shapes.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.