├── .gitignore
├── .jshintrc
├── gulpfile.js
├── package.json
├── sandbox.html
├── js
├── vector.js
├── particle.js
└── breathing-halftone.js
├── README.md
└── dist
├── breathing-halftone.pkgd.min.js
└── breathing-halftone.pkgd.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "browser": true,
3 | "devel": true,
4 | "strict": true,
5 | "undef": true,
6 | "unused": true
7 | }
8 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /*jshint node: true, strict: false */
2 |
3 | var gulp = require('gulp');
4 | var concat = require('gulp-concat');
5 | var rename = require('gulp-rename');
6 | var uglify = require('gulp-uglify');
7 |
8 | gulp.task( 'dist', function() {
9 | var jsFiles = [
10 | 'js/vector.js',
11 | 'js/particle.js',
12 | 'js/breathing-halftone.js'
13 | ];
14 |
15 | gulp.src( jsFiles )
16 | .pipe( concat('breathing-halftone.pkgd.js') )
17 | .pipe( gulp.dest('dist') );
18 |
19 | gulp.src( jsFiles )
20 | .pipe( rename('breathing-halftone.pkgd.min.js') )
21 | .pipe( uglify({ preserveComments: 'some' }) )
22 | .pipe( gulp.dest('dist') );
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "breathing-halftone",
3 | "version": "0.1.0",
4 | "description": "Images go whoa with lots of dots",
5 | "main": "js/breathing-halftone.js",
6 | "dependencies": {},
7 | "devDependencies": {
8 | "gulp": "^3.5.5",
9 | "gulp-concat": "^2.1.7",
10 | "gulp-markdown": "^0.1.2",
11 | "gulp-rename": "^1.1.0",
12 | "highlight.js": "^8.0.0",
13 | "through2": "^0.4.1",
14 | "gulp-uglify": "^1.0.1"
15 | },
16 | "scripts": {
17 | "test": "echo \"Error: no test specified\" && exit 1"
18 | },
19 | "repository": {
20 | "type": "git",
21 | "url": "git://github.com/desandro/breathing-halftone.git"
22 | },
23 | "author": "David DeSandro",
24 | "license": "MIT",
25 | "bugs": {
26 | "url": "https://github.com/desandro/breathing-halftone/issues"
27 | },
28 | "homepage": "https://github.com/desandro/breathing-halftone"
29 | }
30 |
--------------------------------------------------------------------------------
/sandbox.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | breathing halftone
7 |
8 |
9 |
10 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/js/vector.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Breathing Halftone
3 | * Images go whoa with lots of floaty dots
4 | * http://breathing-halftone.desandro.com
5 | */
6 |
7 | ( function( window ) {
8 |
9 | 'use strict';
10 |
11 | // ----- vars ----- //
12 |
13 | var Halftone = window.BreathingHalftone = window.BreathingHalftone || {};
14 |
15 | // -------------------------- Vector -------------------------- //
16 |
17 | function Vector( x, y ) {
18 | this.set( x || 0, y || 0 );
19 | }
20 |
21 | Vector.prototype.set = function( x, y ) {
22 | this.x = x;
23 | this.y = y;
24 | };
25 |
26 | Vector.prototype.add = function( v ) {
27 | this.x += v.x;
28 | this.y += v.y;
29 | };
30 |
31 | Vector.prototype.subtract = function( v ) {
32 | this.x -= v.x;
33 | this.y -= v.y;
34 | };
35 |
36 | Vector.prototype.scale = function( s ) {
37 | this.x *= s;
38 | this.y *= s;
39 | };
40 |
41 | Vector.prototype.multiply = function( v ) {
42 | this.x *= v.x;
43 | this.y *= v.y;
44 | };
45 |
46 | // custom getter whaaaaaaat
47 | Object.defineProperty( Vector.prototype, 'magnitude', {
48 | get: function() {
49 | return Math.sqrt( this.x * this.x + this.y * this.y );
50 | }
51 | });
52 |
53 | // ----- class functions ----- //
54 |
55 | Vector.subtract = function( a, b ) {
56 | return new Vector( a.x - b.x, a.y - b.y );
57 | };
58 |
59 | Vector.add = function( a, b ) {
60 | return new Vector( a.x + b.x, a.y + b.y );
61 | };
62 |
63 | Vector.copy = function( v ) {
64 | return new Vector( v.x, v.y );
65 | };
66 |
67 | Halftone.Vector = Vector;
68 |
69 | })( window );
70 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Breathing Halftone
2 |
3 | _Images go whoa with lots of floaty dots_
4 |
5 | Made for [Yaron](http://yaronschoen.com/info)
6 |
7 | ## Install
8 |
9 | [breathing-halftone.pkgd.js](http://breathing-halftone.desandro.com/dist/breathing-halftone.pkgd.js)
10 |
11 | [breathing-halftone.pkgd.min.js](http://breathing-halftone.desandro.com/dist/breathing-halftone.pkgd.min.js)
12 |
13 | ## Usage
14 |
15 | ``` js
16 | // get the image
17 | // jquery
18 | var img = $('#hero img')[0];
19 | // or vanilla JS
20 | var img = document.querySelector('#hero img');
21 |
22 | // init halftone
23 | new BreathingHalftone( img, {
24 | // options...
25 | });
26 | ```
27 |
28 | Browsers that do not support `