summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCode WvS <code-wvs@quantentunnel.de>2015-03-21 14:22:09 +0100
committerCode WvS <code-wvs@quantentunnel.de>2015-03-21 14:22:09 +0100
commit107ff47f5914f0a77f1980d6321edbc59c8952ec (patch)
tree98d11c6cf3fee3d77f08a82e27fd6a746953a48f
parentbee393e2fef958fbf43afb20b14a73ef73cbfc41 (diff)
downloadsnap-yow-107ff47f5914f0a77f1980d6321edbc59c8952ec.tar.gz
snap-yow-107ff47f5914f0a77f1980d6321edbc59c8952ec.zip
fix polygon drawing
-rw-r--r--objects.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/objects.js b/objects.js
index ce17065..57a2067 100644
--- a/objects.js
+++ b/objects.js
@@ -3384,9 +3384,11 @@ SpriteMorph.prototype.drawLine = function (start, dest) {
for (var j = 0; j < latlngs.length; j++) {
// If a distance between two points is <= 1 meter,
// call them "the same"
+ // if the same exists, a polygon can be created
+ // TODO: detect and join lines with "same points"
if (latlngs[j].distanceTo(destLatLng) <= 1) {
- var polyLL = window.polylines[this.myPolylineIndex]
- .spliceLatLngs(j, latlngs.length)
+ var polyLL = latlngs
+ .slice(j, latlngs.length)
.concat([destLatLng]);
L.polygon(polyLL,
{color: this.color.toString(), weight: this.size})
@@ -3433,7 +3435,7 @@ SpriteMorph.prototype.moveBy = function (delta, justMe) {
part.moveBy(delta);
});
}
- if (!this.isDown) {
+ if (!this.isDown && start) {
this.myPolylineIndex = window.polylineIndex++;
}
};
@@ -4715,6 +4717,8 @@ StageMorph.prototype.drawOn = function (aCanvas, aRect) {
StageMorph.prototype.clearPenTrails = function () {
window.map.removeLayer(window.penTrails);
+ window.polylines = [];
+ window.polylineIndex = 0;
window.penTrails = L.layerGroup().addTo(window.map);
window.penShapes = L.layerGroup().addTo(window.penTrails);
window.penLines = L.layerGroup().addTo(window.penTrails);