Skip to content

Commit

Permalink
JSON error
Browse files Browse the repository at this point in the history
  • Loading branch information
Squidyman committed Apr 23, 2020
1 parent caf0142 commit 9e6e250
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
9 changes: 5 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<html><head>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="p5.min.js"></script>
<script type="text/javascript" src="js/algorithm.js"></script>

</head>
<body onload="InitThis();">

<div align="center">
<canvas id="myCanvas" width="500" height="500" style="border:2px solid black"></canvas>
<br><br>
Expand All @@ -25,8 +30,4 @@

</div>

<script src="p5.min.js"></script>
<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="js/algorithm.js"></script>

</body></html>
24 changes: 16 additions & 8 deletions js/algorithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ function InitThis() {
ctx = document.getElementById('myCanvas').getContext("2d");

$('#myCanvas').mousedown(function(e) {
lineList.push(JSON.parse(JSON.stringify(line)));
activeLine++;
lineList.push(JSON.parse(JSON.stringify(line)));

mousePressed = true;
Draw(e.pageX - $(this).offset().left, e.pageY - $(this).offset().top, false);
});
Expand Down Expand Up @@ -116,15 +117,21 @@ function scalarProjection(p, a, b) {
return normalPoint;
}

function setup() {

}

$(document).ready(function(){

$('#run').on('click', function(){
// let epsilon = 0;
let epsilon = 0;
// alert("Hello! I am an alert box!!");
// allPoints = [];
// let points = lineList[0].points;
// console.log(lineList);
// for(let i = 0; i < points.length; i++){
// allPoints.push(createVector(points[i][0], points[i][1]));
// }
allPoints = [];
let points = lineList[0].points;
console.log(lineList);
for(let i = 0; i < points.length; i++){
allPoints.push(createVector(points[i][0], points[i][1]));
}

// background(0);

Expand Down Expand Up @@ -166,4 +173,5 @@ $('#run').on('click', function(){
// text('epsilon: ' + nf(epsilon, 2, 2), 20, 25);
// text('n: ' + rdpPoints.length, 20, 50);

})
})

0 comments on commit 9e6e250

Please sign in to comment.