From 2a6993efae6e961660ecd2aa1f999f10aadf94f4 Mon Sep 17 00:00:00 2001 From: Code WvS Date: Sun, 1 Mar 2015 17:48:36 +0100 Subject: draw pen trails; expand to polygons automatically --- snap.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'snap.html') diff --git a/snap.html b/snap.html index 7f609d0..ab02c64 100755 --- a/snap.html +++ b/snap.html @@ -57,7 +57,7 @@ }; // Snap! YOW starts here - var world, map, layer, spriteGroup; + var world, map, layer, spriteGroup, polylines, polylineIndex; function loop() { world.doOneCycle(); @@ -115,6 +115,15 @@ window.spriteGroup = spriteGroup; spriteGroup = L.layerGroup().addTo(map); + // During a pen down, a polyline is updated at polylines[this.myPolylineIndex]. + // On pen up, myPolylineIndex is set to polylineIndex and polylineIndex is incremented + // so polylines contains complete lines created by different sprites. + // These lines might be (partially) transformed into polygons. + window.penTrails = L.layerGroup().addTo(map); + window.polylines = polylines; + polylineIndex = 0; + polylines = []; + // Load the IDE world = new WorldMorph(document.getElementById('world')); world.worldCanvas.focus(); -- cgit v1.3.1