diff --git a/src/App.js b/src/App.js
index 2739f81..7184bc2 100644
--- a/src/App.js
+++ b/src/App.js
@@ -26,7 +26,7 @@ class App extends Component {
constructor(props) {
super(props);
this.state = {
- numPoints: 2500,
+ numPoints: 1000,
backgroundColor:"#fdfdfd", // doesn't work with white or black -- strange
circleSpacing: 3,
shape: 'triangles',
@@ -193,7 +193,7 @@ class App extends Component {
circleSpacing: this.state.shape !== "circles",
smoothIters: this.state.smoothType === "none",
contrastIters: this.state.smoothType === "none",
- backgroundColor: this.state.shape != "circles" && this.state.fill ? true : false
+ backgroundColor: this.state.shape !== "circles" && this.state.fill ? true : false
}
return (
diff --git a/src/ControlPanel.js b/src/ControlPanel.js
index 8088d36..4f91d44 100644
--- a/src/ControlPanel.js
+++ b/src/ControlPanel.js
@@ -110,7 +110,6 @@ class ControlPanel extends Component {
break;
case 'slider':
-
ele =
{ (control.getDisabled === undefined || (control.getDisabled !== undefined && !control.getDisabled(this.props.disabled[control.id]))) &&
@@ -122,6 +121,18 @@ class ControlPanel extends Component {
}
break;
+ case 'logslider':
+ ele =
+ { (control.getDisabled === undefined || (control.getDisabled !== undefined && !control.getDisabled(this.props.disabled[control.id]))) &&
+
+
+ this.handleSliderChange(control.id, Math.round(Math.pow(10,(val/25+1)))) } onDragStop={ (e) => this.props.update(e, control.id, this.state[control.id]) }
+ defaultValue={ Math.log10(this.props.status[control.id])*25-25 } sliderStyle={ this.state.styles.slider } />
+
}
+
+ break;
case 'checkbox':
ele =
{ (control.getDisabled === undefined || (control.getDisabled !== undefined && !control.getDisabled(this.props.disabled[control.id]))) &&
diff --git a/src/ControlSettings.js b/src/ControlSettings.js
index c9368e8..ec4526b 100644
--- a/src/ControlSettings.js
+++ b/src/ControlSettings.js
@@ -24,11 +24,10 @@ const ControlSettings = [{
}]
}, {
id: 'numPoints',
- type: 'slider',
+ type: 'logslider',
getLabel: (num) => "# of Points: " + num,
min: 10,
- max: 50000,
- step: 100
+ max: 100000
},
{
id: 'fitToScreen',
diff --git a/src/PolygonUtils.js b/src/PolygonUtils.js
index 2218fb8..f95ca4d 100644
--- a/src/PolygonUtils.js
+++ b/src/PolygonUtils.js
@@ -123,38 +123,20 @@ const PolygonUtils = {
let weight = 0;
let counter = 0;
for (let iW =0; iW < width; ++iW) {
- if (iW % 2 === 0) {
- for (let iH=0; iH < height; ++iH) {
- weight = weights[counter];
- ++counter; // note: counter = iW*height+iH; but this is a little faster?
- if (weight > 0.0) {
- site = diagram.find(iW, iH).index; // find which polygon contains this pixels
- if (weightedCentroidData[site][2] === 0.0) {
- weightedCentroidData[site][0] = weight*iW;
- weightedCentroidData[site][1] = weight*iH;
- } else {
- weightedCentroidData[site][0] += weight*iW;
- weightedCentroidData[site][1] += weight*iH;
- }
- weightedCentroidData[site][2] += weight;
+ for (let iH=0; iH < height; ++iH) {
+ weight = weights[counter];
+ ++counter; // note: counter = iW*height+iH; but this is a little faster?
+ if (weight > 0.0) {
+ site = diagram.find(iW, iH).index; // find which polygon contains this pixels
+ if (weightedCentroidData[site][2] === 0.0) {
+ weightedCentroidData[site][0] = weight*iW;
+ weightedCentroidData[site][1] = weight*iH;
+ } else {
+ weightedCentroidData[site][0] += weight*iW;
+ weightedCentroidData[site][1] += weight*iH;
}
- }
- } else {
- for (let iH=height-1; iH >= 0; --iH) {
- weight = weights[counter];
- ++counter; // note: counter = iW*height+iH; but this is a little faster?
- if (weight > 0.0) {
- site = diagram.find(iW, iH).index; // find which polygon contains this pixel
- if (weightedCentroidData[site][2] === 0.0) {
- weightedCentroidData[site][0] = weight*iW;
- weightedCentroidData[site][1] = weight*iH;
- } else {
- weightedCentroidData[site][0] += weight*iW;
- weightedCentroidData[site][1] += weight*iH;
- }
- weightedCentroidData[site][2] += weight;
- }
- }
+ weightedCentroidData[site][2] += weight;
+ }
}
}
@@ -169,7 +151,7 @@ const PolygonUtils = {
let snappedAny = false;
// Sites that edges of Voronoi cells that lie on the perimeter of
// the polygon will be snapped to the perimeter.
- diagram.edges.map(function(edge) {
+ diagram.edges.forEach(function(edge) {
// Perimeter edges don't have a neighboring Voronoi site.
if (typeof edge.right === 'undefined') {
// If the site has already been snapped to the perimeter, skip it.
diff --git a/src/Resampler.js b/src/Resampler.js
index 3f2b980..860f9b7 100644
--- a/src/Resampler.js
+++ b/src/Resampler.js
@@ -113,14 +113,8 @@ class Resampler {
this.weights = [];
if (this.smoothType === 'contrastWeighted') {
for (let iW =0; iW < this.width; ++iW) {
- if (iW % 2 === 0) {
- for (let iH=0; iH < this.height; ++iH) {
- this.weights.push(this.approximateGradient(iW, iH, 1) + 1.0);
- }
- } else {
- for (let iH=this.height-1; iH >= 0; --iH) {
- this.weights.push(this.approximateGradient(iW, iH, 1) + 1.0);
- }
+ for (let iH=0; iH < this.height; ++iH) {
+ this.weights.push(this.approximateGradient(iW, iH, 1) + 1.0);
}
}
// only need to redo the smoothing if we are using weighted smoothing