Skip to content
Permalink
Browse files

Prettierify

  • Loading branch information
kopiro committed Sep 17, 2019
1 parent 5ef4601 commit 0b5a742c38016d6bfaddb4411a834de4d94b9ae1
Showing with 90 additions and 69 deletions.
  1. +60 −59 rollup.config.js
  2. +5 −1 src/curve.js
  3. +19 −5 src/ios9curve.js
  4. +6 −4 src/siriwave.js
@@ -1,71 +1,72 @@
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import {
uglify
} from 'rollup-plugin-uglify';
import { uglify } from 'rollup-plugin-uglify';
import livereload from 'rollup-plugin-livereload';
import serve from 'rollup-plugin-serve';

import pkg from './package.json';

const additional_plugins = [];
const plugins = [];

if (process.env.NODE_ENV !== 'production') {
additional_plugins.push(
serve({
open: true,
contentBase: '.'
})
);
additional_plugins.push(
livereload({
watch: 'dist'
})
);
plugins.push(
serve({
open: true,
contentBase: '.',
}),
);
plugins.push(
livereload({
watch: 'dist',
}),
);
}

export default [{
input: 'src/siriwave.js',
output: {
file: pkg.unpkg,
name: pkg.amdName,
format: 'umd'
},
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**'
}),
].concat(additional_plugins)
},
{
input: 'src/siriwave.js',
output: {
file: pkg.unpkg.replace('.js', '.min.js'),
name: pkg.amdName,
format: 'umd'
},
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**'
}),
uglify()
].concat(additional_plugins)
},
{
input: 'src/siriwave.js',
output: [{
file: pkg.module,
format: 'esm'
}],
plugins: [
babel({
exclude: 'node_modules/**'
}),
]
}
];
export default [
{
input: 'src/siriwave.js',
output: {
file: pkg.unpkg,
name: pkg.amdName,
format: 'umd',
},
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
}),
].concat(plugins),
},
{
input: 'src/siriwave.js',
output: {
file: pkg.unpkg.replace('.js', '.min.js'),
name: pkg.amdName,
format: 'umd',
},
plugins: [
resolve(),
commonjs(),
babel({
exclude: 'node_modules/**',
}),
uglify(),
].concat(plugins),
},
{
input: 'src/siriwave.js',
output: [
{
file: pkg.module,
format: 'esm',
},
],
plugins: [
babel({
exclude: 'node_modules/**',
}),
],
},
];
@@ -40,7 +40,11 @@ export default class Curve {
ctx.lineWidth = this.definition.lineWidth;

// Cycle the graph from -X to +X every PX_DEPTH and draw the line
for (let i = -this.GRAPH_X; i <= this.GRAPH_X; i += this.ctrl.opt.pixelDepth) {
for (
let i = -this.GRAPH_X;
i <= this.GRAPH_X;
i += this.ctrl.opt.pixelDepth
) {
ctx.lineTo(this._xpos(i), this.ctrl.heightMax + this._ypos(i));
}

@@ -57,7 +57,10 @@ export default class iOS9Curve {
}

globalAttFn(x) {
return Math.pow(this.ATT_FACTOR / (this.ATT_FACTOR + Math.pow(x, 2)), this.ATT_FACTOR);
return Math.pow(
this.ATT_FACTOR / (this.ATT_FACTOR + Math.pow(x, 2)),
this.ATT_FACTOR,
);
}

sin(x, phase) {
@@ -82,7 +85,9 @@ export default class iOS9Curve {
const x = i * k - t;

y += Math.abs(
this.amplitudes[ci] * this.sin(this.verses[ci] * x, this.phases[ci]) * this.globalAttFn(x),
this.amplitudes[ci]
* this.sin(this.verses[ci] * x, this.phases[ci])
* this.globalAttFn(x),
);
}

@@ -134,8 +139,13 @@ export default class iOS9Curve {
this.amplitudes[ci] += this.DESPAWN_FACTOR;
}

this.amplitudes[ci] = Math.min(Math.max(this.amplitudes[ci], 0), this.finalAmplitudes[ci]);
this.phases[ci] = (this.phases[ci] + this.ctrl.speed * this.speeds[ci] * this.SPEED_FACTOR) % (2 * Math.PI);
this.amplitudes[ci] = Math.min(
Math.max(this.amplitudes[ci], 0),
this.finalAmplitudes[ci],
);
this.phases[ci] = (this.phases[ci]
+ this.ctrl.speed * this.speeds[ci] * this.SPEED_FACTOR)
% (2 * Math.PI);
}

let maxY = -Infinity;
@@ -145,7 +155,11 @@ export default class iOS9Curve {
for (const sign of [1, -1]) {
ctx.beginPath();

for (let i = -this.GRAPH_X; i <= this.GRAPH_X; i += this.ctrl.opt.pixelDepth) {
for (
let i = -this.GRAPH_X;
i <= this.GRAPH_X;
i += this.ctrl.opt.pixelDepth
) {
const x = this._xpos(i);
const y = this._ypos(i);
ctx.lineTo(x, this.ctrl.heightMax - sign * y);
@@ -35,7 +35,9 @@ export default class SiriWave {
color: '#fff',
cover: false,
width: window.getComputedStyle(this.container).width.replace('px', ''),
height: window.getComputedStyle(this.container).height.replace('px', ''),
height: window
.getComputedStyle(this.container)
.height.replace('px', ''),
autostart: false,
pixelDepth: 0.02,
lerpSpeed: 0.1,
@@ -160,10 +162,10 @@ export default class SiriWave {
hex = hex.replace(shorthandRegex, (m, r, g, b) => r + r + g + g + b + b);
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result
? `${parseInt(result[1], 16).toString()},${parseInt(result[2], 16).toString()},${parseInt(
result[3],
? `${parseInt(result[1], 16).toString()},${parseInt(
result[2],
16,
).toString()}`
).toString()},${parseInt(result[3], 16).toString()}`
: null;
}

0 comments on commit 0b5a742

Please sign in to comment.
You can’t perform that action at this time.