1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-13 20:24:16 +02:00

cleanup based on uglify feedback

This commit is contained in:
Pomax
2016-01-09 23:31:52 -08:00
parent b3da8f4f74
commit 6dffa0ff0f
16 changed files with 38 additions and 35233 deletions

35212
article.js

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,8 @@
var React = require("react");
var ReactDOM = require("react-dom");
var Article = require("./Article.jsx");
var style = require("../stylesheets/style.less");
require("../stylesheets/style.less");
ReactDOM.render(<Article/>, document.getElementById("article"), function() {
// trigger a #hash navigation

View File

@@ -1,5 +1,4 @@
var React = require("react");
var ReactDOM = require("react-dom");
var chroma = require("chroma-js");
var fix = function(e) {
@@ -49,7 +48,7 @@ var Graphic = React.createClass({
redraw: function() { if (this.props.draw) { this.props.draw(this, this.curve); }},
render: function() {
var href = "data:text/plain," + this.props.code;
//var href = "data:text/plain," + this.props.code;
return (
<figure className={this.props.inline ? "inline": false}>
<canvas ref="canvas"
@@ -416,7 +415,7 @@ var Graphic = React.createClass({
drawCurve: function(curve, offset) {
offset = offset || { x:0, y:0 };
var p = curve.points, i;
var p = curve.points;
if (p.length <= 3 || 5 <= p.length) {
var points = curve.getLUT(100);

View File

@@ -1,5 +1,4 @@
var React = require("react");
var ReactDOM = require("react-dom");
var SectionHeader = React.createClass({
render: function() {

View File

@@ -2,8 +2,6 @@ var React = require("react");
var Graphic = require("../../Graphic.jsx");
var SectionHeader = require("../../SectionHeader.jsx");
var abs = Math.abs;
var ABC = React.createClass({
getDefaultProps: function() {
return {
@@ -88,7 +86,6 @@ var ABC = React.createClass({
api.reset();
api.setColor("black");
var w = api.getPanelWidth();
var h = api.getPanelHeight();
var pad = 20;
var fwh = w - 2*pad;
api.drawAxes(pad, "t",0,1, "u",0,1);

View File

@@ -2,9 +2,6 @@ var React = require("react");
var Graphic = require("../../Graphic.jsx");
var SectionHeader = require("../../SectionHeader.jsx");
var sin = Math.sin;
var tau = Math.PI*2;
var ArclengthApprox = React.createClass({
getDefaultProps: function() {
return {

View File

@@ -1,5 +1,4 @@
var React = require("react");
var Graphic = require("../../Graphic.jsx");
var SectionHeader = require("../../SectionHeader.jsx");
var CatmullRomConversion = React.createClass({

View File

@@ -2,7 +2,7 @@ var React = require("react");
var Graphic = require("../../Graphic.jsx");
var SectionHeader = require("../../SectionHeader.jsx");
var sin = Math.sin, cos = Math.cos, tan = Math.tan, abs = Math.abs;
var sin = Math.sin, cos = Math.cos, tan = Math.tan;
var CirclesCubic = React.createClass({
getDefaultProps: function() {
@@ -100,7 +100,6 @@ var CirclesCubic = React.createClass({
api.drawCircle(guess.points[2], 3);
// real curve
var offset = {x:api.w, y:0};
api.drawSkeleton(curve);
api.setColor("black");
api.drawLine(curve.points[1], curve.points[2]);

View File

@@ -56,7 +56,7 @@ var Control = React.createClass({
var p = api.hover;
if (p && p.x >= pad && p.x <= dim-pad) {
this.drawLerpBox(api, dim, pad, p);
var t = (p.x-pad)/fwh, tf;
var t = (p.x-pad)/fwh;
this.drawLerpPoint(api, (1-t)*(1-t), pad, fwh, p);
this.drawLerpPoint(api, 2*(1-t)*(t), pad, fwh, p);
this.drawLerpPoint(api, (t)*(t), pad, fwh, p);
@@ -94,7 +94,7 @@ var Control = React.createClass({
var p = api.hover;
if (p && p.x >= pad && p.x <= dim-pad) {
this.drawLerpBox(api, dim, pad, p);
var t = (p.x-pad)/fwh, tf;
var t = (p.x-pad)/fwh;
this.drawLerpPoint(api, (1-t)*(1-t)*(1-t), pad, fwh, p);
this.drawLerpPoint(api, 2*(1-t)*(1-t)*(t), pad, fwh, p);
this.drawLerpPoint(api, 3*(1-t)*(t)*(t), pad, fwh, p);

View File

@@ -45,7 +45,6 @@ var CurveIntersections = React.createClass({
if(this.step !== this.prevstep) {
var pairs = this.pairs;
var clen = pairs.length;
this.pairs = [];
this.finals = [];
pairs.forEach(p => {

View File

@@ -1,5 +1,4 @@
var React = require("react");
var Graphic = require("../../Graphic.jsx");
var SectionHeader = require("../../SectionHeader.jsx");
var Derivatives = React.createClass({

View File

@@ -31,8 +31,7 @@ var Extremities = React.createClass({
pts = curve.points,
w = api.getPanelWidth(),
h = api.getPanelHeight(),
offset = { x: w, y: 0 },
extremities;
offset = { x: w, y: 0 };
var x_pts = JSON.parse(JSON.stringify(pts)).map((p,t) => { return {x:w*t/tf, y:p.x}; });
api.setColor("black");

View File

@@ -1,5 +1,4 @@
var React = require("react");
var Graphic = require("../../Graphic.jsx");
var SectionHeader = require("../../SectionHeader.jsx");
var MatrixSplit = React.createClass({

View File

@@ -68,8 +68,8 @@ var Moulding = React.createClass({
curve = api.curve,
hull = curve.hull(t),
A = api.A = hull[5],
B = api.B = curve.get(t),
db = api.db = curve.derivative(t);
B = api.B = curve.get(t);
api.db = curve.derivative(t);
api.C = api.utils.lli4(A, B, curve.points[0], curve.points[3]);
api.ratio = ratio;
}
@@ -82,23 +82,17 @@ var Moulding = React.createClass({
x: evt.offsetX,
y: evt.offsetY
};
// find the current ABC and ratio values:
var A = api.A;
var B = api.B;
var C = api.C;
// now that we know A, B, C and the AB:BC ratio, we can compute the new A' based on the desired B'
var newA = api.newA = {
x: newB.x - (C.x - newB.x) / api.ratio,
y: newB.y - (C.y - newB.y) / api.ratio
api.newA = {
x: newB.x - (api.C.x - newB.x) / api.ratio,
y: newB.y - (api.C.y - newB.y) / api.ratio
};
},
dragQB: function(evt, api) {
if (!api.t) return;
this.drag(evt, api);
var curve = api.curve;
api.update = [api.newA];
},

View File

@@ -45,9 +45,7 @@ var PointCurves = React.createClass({
},
drawQuadratic: function(api, curve) {
var w = api.getPanelWidth(),
h = api.getPanelHeight(),
labels = ["start","t=0.5","end"];
var labels = ["start","t=0.5","end"];
api.reset();
@@ -90,9 +88,7 @@ var PointCurves = React.createClass({
},
drawCubic: function(api, curve) {
var w = api.getPanelWidth(),
h = api.getPanelHeight(),
labels = ["start","t=0.5","end"];
var labels = ["start","t=0.5","end"];
api.reset();

View File

@@ -11,6 +11,8 @@ var webpackLoaders = [
__dirname + '/lib/p-loader'
];
var plugins = [];
// Dev mode: make certain concessions to speed up dev work:
if(process.argv.indexOf("--prod") === -1) {
// use the webpack hot Reload server:
@@ -20,6 +22,9 @@ if(process.argv.indexOf("--prod") === -1) {
webpackLoaders.push(__dirname + '/lib/textarea-loader');
}
// Prod mode: make sure to minify the bundle
else { plugins.push(new webpack.optimize.UglifyJsPlugin()); }
// And the final config that webpack will read in.
module.exports = {
entry: entry,
@@ -38,4 +43,5 @@ module.exports = {
}
]
},
plugins: plugins
};