diff --git a/Pathfinder/Pathfinder/JavaScript/Astar.js b/Pathfinder/Pathfinder/JavaScript/Astar.js new file mode 100644 index 0000000..e1cecdc --- /dev/null +++ b/Pathfinder/Pathfinder/JavaScript/Astar.js @@ -0,0 +1,162 @@ +//A* Implementation :) + +var check = false; + +//Algorithm Starts here +async function Astar() { + + //Creating a priority_queue for storing the unvisited cells + pqueue = new priority_queue(); + check = false; + + //Re-initialising the property of each cell to its default value + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + + grid[i][j].g = Infinity; + grid[i][j].f = Infinity; + + grid[i][j].visited = false; + grid[i][j].camefrom = null; + grid[i][j].neighbours = []; + grid[i][j].showyou(color(255)); + } + } + + strt.g = 0; + strt.f = dist(str.i, str.j, end.i, end.j); //Math.abs(strt.i - end.i) + Math.abs(strt.j - end.j); + + //Inserting the source cell + pqueue.enqueue(strt.i, strt.j); + + //For keeping the Visited Cell + var closedset = []; + + //Adding reachable neighbours of every cell.Why?.because the user may have added a new wall before running algo. + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + grid[i][j].addneighbours(grid); + } + } + + //While all the cells have been traversed or the END has been found + while (!pqueue.isEmpty()) { + + //if the user clicks Cancel Search,abort=true + if (abort) { + abort = false; + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) + grid[i][j].showyou(color(255)); + } + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); + break; + } + + var current = pqueue.front().element; + + //Hurrah!! We reached our destination + if (current === end) { + check = true; + + var path = []; + var temp = current; + path.push(current); + + //Extract the minimum cost path + while (temp.camefrom) { + path.push(temp.camefrom); + temp = temp.camefrom; + } + + //if enough battery is available + if (battery - (0.5 * (path.length - 1)) >= 0) { + noFill(); + stroke(255, 245, 102); + strokeWeight(w / 5); + beginShape(); + for (var i = 0; i < path.length; i++) { + vertex(path[i].i * w + w / 2, path[i].j * h + h / 2); + } + endShape(); + var c = path.length; + c--; + battery -= 0.5 * c; + success(c); + display_battery(); + } else { + battery_low(); + } + break; + } else { + pqueue.dequeue(); + + closedset.push(current); + + var neigh = current.neighbours; + + //Traversing all neighbours + for (var i = 0; i < neigh.length; i++) { + + var neighbor = neigh[i]; + //If that neighbour is not visited + if (!neighbor.visited) { + + neighbor.visited = true; + //new g value of neighbor + var tempG = current.g + 1; + + //if new g value is samller than previos g value,update it + if (tempG < neighbor.g) { + neighbor.g = tempG; + neighbor.camefrom = current; + } + + //Heuristic Value.Used Euclidean here + var temph = dist(neighbor.i, neighbor.j, end.i, end.j); //Math.abs(neighbor.i - end.i) + Math.abs(neighbor.j - end.j); + //new cost + var newcost = neighbor.g + temph; + //if new cost is smaller than previos cell's cost + + if (newcost < neighbor.f) { + neighbor.h = temph; + neighbor.f = newcost; + pqueue.enqueue(neighbor.i, neighbor.j); + } + } + } + } + + //If path has not been found keep colouring the grid + if (!check) { + for (var i = 0; i < pqueue.items.length; i++) { + pqueue.items[i].element.showyou(color(177, 250, 82)); + } + + for (var i = 0; i < closedset.length; i++) { + closedset[i].showyou(color(74, 247, 244)); + } + + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); + await sleep(15); + } + } + + //Path not found + if (!check && pqueue.isEmpty()) { + fail(); + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); + } + + //Enabling of Clear and Start button after Search completes. + document.getElementById("clr").disabled = false; + document.getElementById("strt").disabled = false; + + //Disabling of Cancel Search button after Search completes + document.getElementById("can").disabled = true; + first_time = 3; +} +//end of the A* implementation \ No newline at end of file diff --git a/Pathfinder/Pathfinder/JavaScript/Dijkstra.js b/Pathfinder/Pathfinder/JavaScript/Dijkstra.js new file mode 100644 index 0000000..ce4894f --- /dev/null +++ b/Pathfinder/Pathfinder/JavaScript/Dijkstra.js @@ -0,0 +1,151 @@ +//Dijkstra ALgorithm Implementation :) + +//function for producing delay in execution +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +//Algorithm Starts here +async function Dijkstra() { + + //hold cells that are yet to be visited + var que = new Queue(); + + var ok = false; + + //Every time algorithm runs,the cells are loaded with default values + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + + grid[i][j].showyou(color(255)); + grid[i][j].camefrom = null; + grid[i][j].visited = false; + grid[i][j].neighbours = []; + } + } + + //Adding reachable neighbours of every cell.Why?.because the user may have added a new wall before running algo. + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + grid[i][j].addneighbours(grid); + } + } + + //Inserting the source cell in the queue + que.enqueue(new QItem(strt.i, strt.j, 0)); + + //Array for keeping the visited cell + var closedSet = []; + + var check = false; + + //While all the cells have been traversed or the END has been found + while (!que.isEmpty()) { + + //if the user clicks Cancel Search,abort=true + if (abort) { + abort = false; + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) + grid[i][j].showyou(color(255)); + } + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); + break; + } + + var p = que.front(); + que.dequeue(); + closedSet.push(p); + + //Hurrah!! We reached our destination + if (grid[p.row][p.col] === end) { + + check = true; + var x = grid[p.row][p.col]; + + var path = []; + var temp = x; + path.push(x); + + //Extracting the minimum cost path + while (true) { + + path.push(temp.camefrom); + temp = temp.camefrom; + if (temp == strt || x == null) { + path.push(temp); + break; + } + } + + //if enough battery is available,then traverse + if (battery - (0.5 * (path.length - 2)) >= 0) { + + noFill(); + stroke(255, 245, 102); + strokeWeight(w / 7); + beginShape(); + + for (var i = 0; i < path.length; i++) { + vertex(path[i].i * w + w / 2, path[i].j * h + h / 2); + } + success(path.length - 2); + endShape(); + battery -= 0.5 * (path.length - 2); + display_battery(); + } else { + battery_low(); + } + break; + + } else { + + var neigh = grid[p.row][p.col].neighbours; + + //traversing through current cell's neighbours + for (var i = 0; i < neigh.length; i++) { + + var neighbor = neigh[i]; + + //if not visited,visit it + if (!neighbor.visited) { + que.enqueue(new QItem(neighbor.i, neighbor.j, p.dist + 1)); + neighbor.visited = true; + neighbor.camefrom = grid[p.row][p.col]; + } + } + } + + //If path has not been found keep colouring the grid + if (!check) { + + for (var i = 0; i < que.items.length; i++) + grid[que.items[i].row][que.items[i].col].showyou(color(177, 250, 82)); + + for (var i = 0; i < closedSet.length; i++) + grid[cSet[i].row][cSet[i].col].showyou(color(74, 247, 244)); + + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); + await sleep(5); + } + } + + //If no path is found + if (!check && que.isEmpty()) { + fail(); + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); + } + + //Enabling of Clear and Start button after Search completes. + document.getElementById("clr").disabled = false; + document.getElementById("strt").disabled = false; + + //Disabling of Cancel Search button after Search completes + document.getElementById("can").disabled = true; + first_time = 3; + + //end of Dijkstra Implementation :) +} \ No newline at end of file diff --git a/Pathfinder/Pathfinder/JavaScript/Grid.js b/Pathfinder/Pathfinder/JavaScript/Grid.js new file mode 100644 index 0000000..e957bba --- /dev/null +++ b/Pathfinder/Pathfinder/JavaScript/Grid.js @@ -0,0 +1,249 @@ +//Grid Implementation + +var row = 21; +var col = 45; + +var grid = new Array(col); +var h, w; + +class Cell { + + //Defining property of each Cell + constructor(i, j) { + this.i = i; + this.j = j; + + this.f = Infinity; + this.h = Infinity; + this.g = Infinity; + + this.wall = false; + this.visited = false; + this.end = false; + this.neighbours = []; + this.camefrom = null; + } + + //For displaying + showyou(col) { + fill(col); + + if (this.wall) + fill(100, 100, 100); + if (this.end) + fill(255, 0, 0); + + strokeWeight(0.1); + stroke(100, 100, 100); + rect(this.i * w, this.j * h, w, h, 5); + } + + //Adding neighbours of current Cell + addneighbours(grid) { + var i = this.i; + var j = this.j; + + if (i < col - 1 && grid[i + 1][j].wall == false) { + this.neighbours.push(grid[i + 1][j]); + } + if (i > 0 && grid[i - 1][j].wall == false) { + this.neighbours.push(grid[i - 1][j]); + } + if (j < row - 1 && grid[i][j + 1].wall == false) { + this.neighbours.push(grid[i][j + 1]); + } + if (j > 0 && grid[i][j - 1].wall == false) { + this.neighbours.push(grid[i][j - 1]); + } + + //If diagonals in path is allowed,add them as neighbours also + var diag = $("#diagonal-panel option:selected") + if (diag.text() == "Allowed") { + + if (i < col - 1 && j < row - 1 && grid[i + 1][j + 1].wall == false && !(grid[i + 1][j].wall == true && grid[i][j + 1].wall == true)) { + this.neighbours.push(grid[i + 1][j + 1]); + } + if (i > 0 && j > 0 && grid[i - 1][j - 1].wall == false && !(grid[i - 1][j].wall == true && grid[i][j - 1].wall == true)) { + this.neighbours.push(grid[i - 1][j - 1]); + } + if (i > 0 && j < row - 1 && grid[i - 1][j + 1].wall == false && !(grid[i - 1][j].wall == true && grid[i][j + 1].wall == true)) { + this.neighbours.push(grid[i - 1][j + 1]); + } + if (j > 0 && i < col - 1 && grid[i + 1][j - 1].wall == false && !(grid[i + 1][j].wall == true && grid[i][j - 1].wall == true)) { + this.neighbours.push(grid[i + 1][j - 1]); + } + } + } +} + +//This is the root of this complete Project!!. +function setup() { + + //Grid Canvas + createCanvas(1335, 585); + + var canvas = document.getElementById("defaultCanvas0"); + + var ctx = canvas.getContext('2d'); + ctx.shadowColor = "grey"; + + h = height / row; + w = width / col; + + for (var i = 0; i < col; i++) grid[i] = new Array(row); + + //Assigning default property to each cell + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + + grid[i][j] = new Cell(i, j); + grid[i][j].showyou(color(255)); + } + } + + //Default start and End + strt = grid[18][10]; + end = grid[25][10]; + + strt.wall = false; + end.wall = false; + + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); +} + +//This function repeats again and again.Provided by p5.js ,Javascript Library for creative coding!! +async function draw() { + + //If Single Destination is Selected Keep the dropdown disable + var xd = document.getElementsByName("algo"); + + if (xd[0].checked) { + + document.getElementById("algorithm-panel").disabled = false; + document.getElementById("Range").style.display = "block"; + //If transferring from Multiple destinations to Single Destination Option,Clear the Grid + if (only) { + + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + grid[i][j].end = false; + grid[i][j].showyou(color(255)); + + } + } + + strt.showyou(color(0, 255, 0)); + end.showyou(color(255, 0, 0)); + only = false; + } + } else { + only = true; + document.getElementById("Range").style.display = "none"; + document.getElementById("algorithm-panel").disabled = true; + } + + var algo = document.getElementsByName("algo"); + + if (algo[1].checked && remin) { + remin = false; + remind(); + + } +} +//Notification to user in the form of pop-up + +//Path Found +function success(c) { + swal({ + title: "Congratulations!!", + text: "Found Path with length " + c, + icon: "success", + button: "OK", + }); +} + +//No path found +function fail() { + swal({ + title: "Sorry", + text: "No Path Found!", + icon: "error", + button: "no!", + }); +} + +//Instrunctions +function instruction() { + swal({ + title: "Please Read!!", + text: "1.Click within the white grid and drag your mouse to draw obstacles.\n\n2.Drag the green node to set the start position.\n\n3.Drag the red node to set the end position.\n\n4.Selecting Single Destination( see Right Panel ) will find the shortest path between one source and one destination\n\n5.Select Algorithm from dropdown,if Single Destination option is selected\n\n6.Selecting Multiple Destinations( see Right Panel )will find the shortest path visiting every destination and returning to the source.\n\n7.Click Start Search in the right panel to start the animation.\n\n8.Click on the 'Mars Rover Range' Button (top left) to know the farthest distance Mars Rover can travel with current battery", + button: "Let's Go", + }); + +} + +function remember() { + swal({ + title: "Remember", + text: "Each traversal will cost some Battery Power.Recharge it before it runs out of power", + button: "OK", + }); +} + +//Reminder when Multiple Destinations is selected +function remind() { + swal({ + title: "Please Read!!", + text: "In Multiple Destinations Case: \n\n First Click on white Cell will convert it to a Wall\n\nSecond click on same cell will convert it into Destination\n\nThird Click will make it white Cell again", + button: "Let's Go", + }); +} + +//Notification of Low Battery +function battery_low() { + swal({ + title: "Sorry!!", + text: "Battery is too Low.Recharge the battery first!!", + icon: "error", + button: "OK", + }); +} + +//Recharge battery +function recharge() { + if (battery == 100) { + swal("Battery Already Full!!"); + } else { + battery = 100; + display_battery(); + } +} + +//Animate the current level of battery +function display_battery() { + var ii = 0; + if (ii == 0) { + ii = 1; + var elem = document.getElementById("myBar"); + var width = 0; + var id = setInterval(frame, 10); + + if (battery <= 25) + elem.style.background = 'red'; + else + elem.style.background = '#ADFF2F'; + + function frame() { + elem.style.width = width + "%"; + width++; + + if (width > battery) { + clearInterval(id); + ii = 0; + } + + + } + } +} \ No newline at end of file diff --git a/Pathfinder/Pathfinder/JavaScript/Queue.js b/Pathfinder/Pathfinder/JavaScript/Queue.js new file mode 100644 index 0000000..700947b --- /dev/null +++ b/Pathfinder/Pathfinder/JavaScript/Queue.js @@ -0,0 +1,96 @@ +//Queue and Priority Queue Implementation :) + +//Property of each Queue element +class QItem { + constructor(x, y, w) { + this.row = x; + this.col = y; + this.dist = w; + } +} + +//Implementation of Queue +class Queue { + + //Array Is Used to Implement Queue + constructor() { + this.items = []; + } + + //Push In the Array!! + enqueue(element) { + this.items.push(element); + } + + //Dequeue element + dequeue() { + if (this.isEmpty()) return "Underflow"; + return this.items.shift(); + } + + //Front Element + front() { + if (this.isEmpty()) return "No elements in Queue"; + return this.items[0]; + } + + //IsEmpty function + isEmpty() { + return this.items.length == 0; + } +} + +//Property of each priority_queue element +class queue_element { + constructor(i, j) { + + this.element = grid[i][j]; + this.priority = grid[i][j].f; + } +} + +//Implementation of Priority Queue +class priority_queue { + + constructor() { + this.items = []; + } + + //Insert in queue + enqueue(i, j) { + + var ele = new queue_element(i, j); + var contain = false; + + for (var i = 0; i < this.items.length; i++) { + if (this.items[i].priority > ele.priority) { + this.items.splice(i, 0, ele); + contain = true; + break; + } + } + if (!contain) { + this.items.push(ele); + } + } + + //Remove + dequeue() { + + this.items.splice(0, 1); + } + + //Front Element + front() { + return this.items[0]; + } + + isEmpty() { + return this.items.length == 0; + } +} + +//IMP: +//The functions here have been declared in that manner other than +// isEmpty=function(){...} +//because this syntax was causing error in Microsoft Edge. \ No newline at end of file diff --git a/Pathfinder/Pathfinder/JavaScript/mEvent.js b/Pathfinder/Pathfinder/JavaScript/mEvent.js new file mode 100644 index 0000000..4357c73 --- /dev/null +++ b/Pathfinder/Pathfinder/JavaScript/mEvent.js @@ -0,0 +1,216 @@ +//Mouse-related Operations + +$(document).on("mousedown", function(event) { + //Not the First Click After The Algorihtm + if (first_time != 3) { + + //If clear grid button is enabled,means no pathfinding search is currently in progress. + //Then you can only edit the grid + if (!document.getElementById("clr").disabled) { + + if (first_time == 1) { + + //Cells to Deafault Value + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + grid[i][j].showyou(color(255)); + } + } + + strt.showyou(color(0, 255, 0)) + end.showyou(color(255, 0, 0)); + + first_time = 0; + } + //Finding Cell Coordinates! + //X- coordinate + var xc = Math.floor(mouseX / w); + //Y- coordinate + var yc = Math.floor(mouseY / h); + + //For checking if user has choosed Multi-Dest or Single-Dest + var yz = document.getElementsByName("algo"); + + //Check if the cell is a valid one and that cell is a destination currently.This click will change it to normal one + if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc].end == true) { + + grid[xc][yc].end = false; + grid[xc][yc].showyou(color(255)); + + $(document).on("mousemove", function(event) { + + //Current Cordinates of cell on which the mouse is! + var xc = Math.floor(mouseX / w); + var yc = Math.floor(mouseY / h); + + if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc] != strt && grid[xc][yc] != end) { + grid[xc][yc].end = false; + grid[xc][yc].showyou(color(255)); + } + + }); + $(document).on("mouseup", function(ev) { + //Stop the mousemove and mouseup + //Ready for Another MouseClick and MouseMove + $(this).unbind("mouseup mousemove"); + }); + + } + //Check if the cell is a valid one and that cell is a wall currently.This click will change it to a destination + //if multiple destinations option is selected + else if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc].wall == true && yz[1].checked) { + + grid[xc][yc].wall = false; + grid[xc][yc].end = true; + grid[xc][yc].showyou(color(255)); + + $(document).on("mousemove", function(event) { + + //Current Cordinates of cell on which the mouse is! + var xc = Math.floor(mouseX / w); + var yc = Math.floor(mouseY / h); + + if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc].wall == true) { + grid[xc][yc].wall = false; + grid[xc][yc].end = true; + grid[xc][yc].showyou(color(255)); + + } + + }); + + $(document).on("mouseup", function(ev) { + //Stop the mousemove and mouseup + //Ready for Another MouseClick and MouseMove + $(this).unbind("mouseup mousemove"); + }); + } + //Check if the cell is a valid one and that cell is a normal one currently.This click will change it to a wall + else if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc].wall == false) { + + //Check if the current cell is not Souce and Destination + if (grid[xc][yc] != strt && grid[xc][yc] != end) { + + //If only pressed then also make the Cell a obstacle + grid[xc][yc].visited = true; + grid[xc][yc].wall = true; + + //Color the Cell + grid[xc][yc].showyou(color(100, 100, 100)); + + /** + * If the mouse is pressed and moved + * make every cell a obstacles excluding Sources and Destination + */ + $(document).on("mousemove", function(ev) { + + var xc = Math.floor(mouseX / w); + var yc = Math.floor(mouseY / h); + + if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc] != strt && grid[xc][yc] != end) { + + grid[xc][yc].visited = true; + grid[xc][yc].wall = true; + grid[xc][yc].showyou(color(100, 100, 100)); + } + }); + + $(document).on("mouseup", function(ev) { + //Stop the mousemove and mouseup + //Ready for Another MouseClick and MouseMove + $(this).unbind("mouseup mousemove"); + }); + + } + //Checks if selected node is a start cell.Move it according to cursor + else if (grid[xc][yc] == strt) { + //The Current Cell is Source or Dstination + //Move the Source or Destination Position + $(document).on("mousemove", function(ev) { + document.getElementById('cursor1').style.display = 'block'; + var cursor = document.getElementById('cursor1'); + var xc = Math.floor(mouseX / w); + var yc = Math.floor(mouseY / h); + cursor.style.left = xc * w + w + "px"; + cursor.style.top = yc * h + 4.3 * h + "px"; + + }); + + $(document).on("mouseup", function(ev) { + + var xf = Math.floor(mouseX / w); + var yf = Math.floor(mouseY / h); + document.getElementById('cursor1').style.display = 'none'; + + if (xf >= 0 && yf >= 0 && xf < col && yf < row && grid[xf][yf].wall != true && grid[xf][yf] != end) { + grid[xc][yc].wall = false; + grid[xc][yc].visited = false; + grid[xc][yc].showyou(color(255)); + + strt = grid[xf][yf]; + strt.showyou(color(0, 255, 0)); + grid[xf][yf].showyou(color(0, 255, 0)); + } + + $(this).unbind("mouseup mousemove"); + }); + + } + //Checks if selected node is the end node.Move it + else if (grid[xc][yc] == end) { + $(document).on("mousemove", function(ev) { + + document.getElementById('cursor2').style.display = 'block'; + var cursor = document.getElementById('cursor2'); + var xc = Math.floor(mouseX / w); + var yc = Math.floor(mouseY / h); + cursor.style.left = xc * w + w + "px"; + cursor.style.top = yc * h + 4 * h + "px"; + + }); + + $(document).on("mouseup", function(ev) { + + var xf = Math.floor(mouseX / w); + var yf = Math.floor(mouseY / h); + document.getElementById('cursor2').style.display = 'none'; + + if (xf >= 0 && yf >= 0 && xf < col && yf < row && grid[xf][yf].wall != true && grid[xf][yf] != strt) { + grid[xc][yc].wall = false; + grid[xc][yc].visited = false; + grid[xc][yc].showyou(color(255)); + + end = grid[xf][yf]; + end.showyou(color(255, 0, 0)); + } + $(this).unbind("mouseup mousemove"); + }); + } + } + //Checks if the current cell is wall or not .Make it normal one if Single destinations is ON + else if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc].wall == true) { + + //If the Cell is a Obstacle then it can't be Souce or Destination + grid[xc][yc].visited = false; + grid[xc][yc].wall = false; + grid[xc][yc].showyou(color(255)); + $(document).on("mousemove", function(event) { + + //Current Cordinates of cell on which the mouse is! + var xc = Math.floor(mouseX / w); + var yc = Math.floor(mouseY / h); + if (xc >= 0 && yc >= 0 && xc < col && yc < row && grid[xc][yc] != strt && grid[xc][yc] != end) { + grid[xc][yc].visited = false; + grid[xc][yc].wall = false; + grid[xc][yc].showyou(color(255)); + } + + }); + $(document).on("mouseup", function(event) { + $(this).unbind("mouseup mousemove"); + }); + } + } + } else + first_time = 1; +}); \ No newline at end of file diff --git a/Pathfinder/Pathfinder/JavaScript/main.js b/Pathfinder/Pathfinder/JavaScript/main.js new file mode 100644 index 0000000..7aadc82 --- /dev/null +++ b/Pathfinder/Pathfinder/JavaScript/main.js @@ -0,0 +1,73 @@ +//Running algorithm on user-input + +$(document).ready(function() { + + //if start search button is click + $('#strt').click(function() { + var elem = document.getElementById("butt"); + elem.value = "Mars Rover Range"; + + document.getElementById("clr").disabled = true; + document.getElementById("strt").disabled = true; + document.getElementById("can").disabled = false; + + //Checking if Single Dest or Multiple Dest. is selected + var x = document.getElementsByName("algo"); + + //If Single dest. is selected + if (x[0].checked) { + + //getting input from drop-down + var value = $("#algorithm-panel option:selected"); + + switch (value.text()) { + case "Dijkstra": //Dijkstra Algo is Selected + Dijkstra(); + break; + + case "A*": //A* algo is selected + Astar(); + break; + + case "Range": + Rem(); + break; + default: //If no algo is selected + swal({ + text: "Please Select a Algorithm to Start !!", + icon: "info", + button: "OK", + }); + document.getElementById("clr").disabled = false; + document.getElementById("strt").disabled = false; + document.getElementById("can").disabled = true; + break; + + } + } + //If Multiple Destinations is selected + else if (x[1].checked) { + reminder = true; + calc_dis(); + } + }); + + //On clicking Clear Button + $('#clr').click(function() { + + for (var i = 0; i < col; i++) { + for (var j = 0; j < row; j++) { + grid[i][j].wall = false; + grid[i][j].end = false; + grid[i][j].showyou(color(255)); + } + } + strt.showyou(color(0, 255, 0)) + end.showyou(color(255, 0, 0)); + }); + + //On clicking Cancel Search button + $('#can').click(function() { + abort = true; + }); +}); \ No newline at end of file diff --git a/Pathfinder/Pathfinder/JavaScript/p5.js b/Pathfinder/Pathfinder/JavaScript/p5.js new file mode 100644 index 0000000..e79ba8b --- /dev/null +++ b/Pathfinder/Pathfinder/JavaScript/p5.js @@ -0,0 +1,106332 @@ +/*! p5.js v1.0.0 February 29, 2020 */ +(function(f) { + if (typeof exports === 'object' && typeof module !== 'undefined') { + module.exports = f(); + } else if (typeof define === 'function' && define.amd) { + define([], f); + } else { + var g; + if (typeof window !== 'undefined') { + g = window; + } else if (typeof global !== 'undefined') { + g = global; + } else if (typeof self !== 'undefined') { + g = self; + } else { + g = this; + } + g.p5 = f(); + } +})(function() { + var define, module, exports; + return (function() { + function r(e, n, t) { + function o(i, f) { + if (!n[i]) { + if (!e[i]) { + var c = 'function' == typeof require && require; + if (!f && c) return c(i, !0); + if (u) return u(i, !0); + var a = new Error("Cannot find module '" + i + "'"); + throw ((a.code = 'MODULE_NOT_FOUND'), a); + } + var p = (n[i] = { exports: {} }); + e[i][0].call( + p.exports, + function(r) { + var n = e[i][1][r]; + return o(n || r); + }, + p, + p.exports, + r, + e, + n, + t + ); + } + return n[i].exports; + } + for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++) + o(t[i]); + return o; + } + return r; + })()( + { + 1: [ + function(_dereq_, module, exports) { + module.exports = { + project: { + name: 'p5', + description: + '[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)', + version: '1.0.0', + url: 'https://github.com/processing/p5.js#readme' + }, + files: { + 'src/color/color_conversion.js': { + name: 'src/color/color_conversion.js', + modules: { + 'Color Conversion': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/color/creating_reading.js': { + name: 'src/color/creating_reading.js', + modules: { + 'Creating & Reading': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/color/p5.Color.js': { + name: 'src/color/p5.Color.js', + modules: {}, + classes: { + 'p5.Color': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/color/setting.js': { + name: 'src/color/setting.js', + modules: { + Setting: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/shape/2d_primitives.js': { + name: 'src/core/shape/2d_primitives.js', + modules: { + '2D Primitives': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/shape/attributes.js': { + name: 'src/core/shape/attributes.js', + modules: { + Attributes: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/shape/curves.js': { + name: 'src/core/shape/curves.js', + modules: { + Curves: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/shape/vertex.js': { + name: 'src/core/shape/vertex.js', + modules: { + Vertex: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/constants.js': { + name: 'src/core/constants.js', + modules: { + Constants: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/environment.js': { + name: 'src/core/environment.js', + modules: { + Environment: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/error_helpers.js': { + name: 'src/core/error_helpers.js', + modules: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/helpers.js': { + name: 'src/core/helpers.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/core/init.js': { + name: 'src/core/init.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/core/internationalization.js': { + name: 'src/core/internationalization.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/core/legacy.js': { + name: 'src/core/legacy.js', + modules: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/main.js': { + name: 'src/core/main.js', + modules: { + Structure: 1 + }, + classes: { + p5: 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/p5.Element.js': { + name: 'src/core/p5.Element.js', + modules: { + DOM: 1 + }, + classes: { + 'p5.Element': 1 + }, + fors: { + 'p5.Element': 1 + }, + namespaces: {} + }, + 'src/core/p5.Graphics.js': { + name: 'src/core/p5.Graphics.js', + modules: { + Rendering: 1 + }, + classes: { + 'p5.Graphics': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/p5.Renderer.js': { + name: 'src/core/p5.Renderer.js', + modules: {}, + classes: { + 'p5.Renderer': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/p5.Renderer2D.js': { + name: 'src/core/p5.Renderer2D.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/core/reference.js': { + name: 'src/core/reference.js', + modules: { + Foundation: 1 + }, + classes: {}, + fors: { + p5: 1, + JSON: 1, + console: 1 + }, + namespaces: {} + }, + 'src/core/rendering.js': { + name: 'src/core/rendering.js', + modules: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/shim.js': { + name: 'src/core/shim.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/core/structure.js': { + name: 'src/core/structure.js', + modules: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/core/transform.js': { + name: 'src/core/transform.js', + modules: { + Transform: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/data/local_storage.js': { + name: 'src/data/local_storage.js', + modules: { + LocalStorage: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/data/p5.TypedDict.js': { + name: 'src/data/p5.TypedDict.js', + modules: { + Dictionary: 1 + }, + classes: { + 'p5.TypedDict': 1, + 'p5.StringDict': 1, + 'p5.NumberDict': 1 + }, + fors: { + 'p5.TypedDict': 1, + p5: 1 + }, + namespaces: {} + }, + 'src/dom/dom.js': { + name: 'src/dom/dom.js', + modules: {}, + classes: { + 'p5.MediaElement': 1, + 'p5.File': 1 + }, + fors: { + p5: 1, + 'p5.Element': 1 + }, + namespaces: {} + }, + 'src/events/acceleration.js': { + name: 'src/events/acceleration.js', + modules: { + Acceleration: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/events/keyboard.js': { + name: 'src/events/keyboard.js', + modules: { + Keyboard: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/events/mouse.js': { + name: 'src/events/mouse.js', + modules: { + Mouse: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/events/touch.js': { + name: 'src/events/touch.js', + modules: { + Touch: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/image/filters.js': { + name: 'src/image/filters.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/image/image.js': { + name: 'src/image/image.js', + modules: { + Image: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/image/loading_displaying.js': { + name: 'src/image/loading_displaying.js', + modules: { + 'Loading & Displaying': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/image/p5.Image.js': { + name: 'src/image/p5.Image.js', + modules: {}, + classes: { + 'p5.Image': 1 + }, + fors: {}, + namespaces: {} + }, + 'src/image/pixels.js': { + name: 'src/image/pixels.js', + modules: { + Pixels: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/io/files.js': { + name: 'src/io/files.js', + modules: { + Input: 1, + Output: 1 + }, + classes: { + 'p5.PrintWriter': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/io/p5.Table.js': { + name: 'src/io/p5.Table.js', + modules: { + Table: 1 + }, + classes: { + 'p5.Table': 1 + }, + fors: {}, + namespaces: {} + }, + 'src/io/p5.TableRow.js': { + name: 'src/io/p5.TableRow.js', + modules: {}, + classes: { + 'p5.TableRow': 1 + }, + fors: {}, + namespaces: {} + }, + 'src/io/p5.XML.js': { + name: 'src/io/p5.XML.js', + modules: {}, + classes: { + 'p5.XML': 1 + }, + fors: {}, + namespaces: {} + }, + 'src/math/calculation.js': { + name: 'src/math/calculation.js', + modules: { + Calculation: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/math/math.js': { + name: 'src/math/math.js', + modules: { + Vector: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/math/noise.js': { + name: 'src/math/noise.js', + modules: { + Noise: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/math/p5.Vector.js': { + name: 'src/math/p5.Vector.js', + modules: {}, + classes: { + 'p5.Vector': 1 + }, + fors: {}, + namespaces: {} + }, + 'src/math/random.js': { + name: 'src/math/random.js', + modules: { + Random: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/math/trigonometry.js': { + name: 'src/math/trigonometry.js', + modules: { + Trigonometry: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/typography/attributes.js': { + name: 'src/typography/attributes.js', + modules: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/typography/loading_displaying.js': { + name: 'src/typography/loading_displaying.js', + modules: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/typography/p5.Font.js': { + name: 'src/typography/p5.Font.js', + modules: {}, + classes: { + 'p5.Font': 1 + }, + fors: {}, + namespaces: {} + }, + 'src/utilities/array_functions.js': { + name: 'src/utilities/array_functions.js', + modules: { + 'Array Functions': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/utilities/conversion.js': { + name: 'src/utilities/conversion.js', + modules: { + Conversion: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/utilities/string_functions.js': { + name: 'src/utilities/string_functions.js', + modules: { + 'String Functions': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/utilities/time_date.js': { + name: 'src/utilities/time_date.js', + modules: { + 'Time & Date': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/3d_primitives.js': { + name: 'src/webgl/3d_primitives.js', + modules: { + '3D Primitives': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/interaction.js': { + name: 'src/webgl/interaction.js', + modules: { + Interaction: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/light.js': { + name: 'src/webgl/light.js', + modules: { + Lights: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/loading.js': { + name: 'src/webgl/loading.js', + modules: { + '3D Models': 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/material.js': { + name: 'src/webgl/material.js', + modules: { + Material: 1 + }, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/p5.Camera.js': { + name: 'src/webgl/p5.Camera.js', + modules: { + Camera: 1 + }, + classes: { + 'p5.Camera': 1 + }, + fors: { + p5: 1, + 'p5.Camera': 1 + }, + namespaces: {} + }, + 'src/webgl/p5.Geometry.js': { + name: 'src/webgl/p5.Geometry.js', + modules: {}, + classes: { + 'p5.Geometry': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/p5.Matrix.js': { + name: 'src/webgl/p5.Matrix.js', + modules: {}, + classes: { + 'p5.Matrix': 1 + }, + fors: {}, + namespaces: {} + }, + 'src/webgl/p5.RenderBuffer.js': { + name: 'src/webgl/p5.RenderBuffer.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/webgl/p5.RendererGL.Immediate.js': { + name: 'src/webgl/p5.RendererGL.Immediate.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/webgl/p5.RendererGL.Retained.js': { + name: 'src/webgl/p5.RendererGL.Retained.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + }, + 'src/webgl/p5.RendererGL.js': { + name: 'src/webgl/p5.RendererGL.js', + modules: {}, + classes: { + 'p5.RendererGL': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/p5.Shader.js': { + name: 'src/webgl/p5.Shader.js', + modules: {}, + classes: { + 'p5.Shader': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/p5.Texture.js': { + name: 'src/webgl/p5.Texture.js', + modules: {}, + classes: { + 'p5.Texture': 1 + }, + fors: { + p5: 1 + }, + namespaces: {} + }, + 'src/webgl/text.js': { + name: 'src/webgl/text.js', + modules: {}, + classes: { + ImageInfos: 1, + FontInfo: 1, + Cubic: 1 + }, + fors: {}, + namespaces: {} + }, + 'lib/addons/p5.sound.js': { + name: 'lib/addons/p5.sound.js', + modules: { + 'p5.sound': 1 + }, + classes: { + 'p5.Effect': 1, + 'p5.Filter': 1, + 'p5.LowPass': 1, + 'p5.HighPass': 1, + 'p5.BandPass': 1, + 'p5.Oscillator': 1, + 'p5.SinOsc': 1, + 'p5.TriOsc': 1, + 'p5.SawOsc': 1, + 'p5.SqrOsc': 1, + 'p5.MonoSynth': 1, + 'p5.AudioVoice': 1, + 'p5.PolySynth': 1, + 'p5.SoundFile': 1, + 'p5.Amplitude': 1, + 'p5.FFT': 1, + 'p5.Signal': 1, + 'p5.Envelope': 1, + 'p5.Pulse': 1, + 'p5.Noise': 1, + 'p5.AudioIn': 1, + 'p5.EQ': 1, + 'p5.Panner3D': 1, + 'p5.Delay': 1, + 'p5.Reverb': 1, + 'p5.Convolver': 1, + 'p5.Phrase': 1, + 'p5.Part': 1, + 'p5.Score': 1, + 'p5.SoundLoop': 1, + 'p5.Compressor': 1, + 'p5.SoundRecorder': 1, + 'p5.PeakDetect': 1, + 'p5.Gain': 1, + 'p5.Distortion': 1 + }, + fors: { + 'p5.sound': 1, + 'p5.Effect': 1, + p5: 1, + 'p5.Oscillator': 1, + 'p5.MonoSynth': 1, + 'p5.AudioVoice': 1, + 'p5.PolySynth': 1, + 'p5.SoundFile': 1, + 'p5.Amplitude': 1, + 'p5.FFT': 1, + 'p5.Signal': 1, + 'p5.Envelope': 1, + 'p5.AudioIn': 1, + 'p5.EQ': 1, + 'p5.Panner3D': 1, + 'p5.Delay': 1, + 'p5.Reverb': 1, + 'p5.Convolver': 1, + 'p5.Part': 1, + 'p5.Score': 1, + 'p5.SoundLoop': 1, + 'p5.Compressor': 1, + 'p5.SoundRecorder': 1, + 'p5.Gain': 1, + 'p5.Distortion': 1 + }, + namespaces: {} + }, + 'lib/addons/p5.sound.min.js': { + name: 'lib/addons/p5.sound.min.js', + modules: {}, + classes: {}, + fors: {}, + namespaces: {} + } + }, + modules: { + Color: { + name: 'Color', + submodules: { + 'Color Conversion': 1, + 'Creating & Reading': 1, + Setting: 1 + }, + elements: {}, + classes: { + 'p5.Color': 1 + }, + fors: { + p5: 1 + }, + namespaces: {}, + file: 'src/color/p5.Color.js', + line: 14 + }, + 'Color Conversion': { + name: 'Color Conversion', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Color', + namespace: '', + file: 'src/color/color_conversion.js', + line: 1, + requires: ['core'] + }, + 'Creating & Reading': { + name: 'Creating & Reading', + submodules: {}, + elements: {}, + classes: { + 'p5.Color': 1 + }, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Color', + namespace: '', + file: 'src/color/p5.Color.js', + line: 14, + requires: ['core', 'constants'], + description: + '

Each color stores the color mode and level maxes that applied at the\ntime of its construction. These are used to interpret the input arguments\n(at construction and later for that instance of color) and to format the\noutput e.g. when saturation() is requested.

\n

Internally we store an array representing the ideal RGBA values in floating\npoint form, normalized from 0 to 1. From this we calculate the closest\nscreen color (RGBA levels from 0 to 255) and expose this to the renderer.

\n

We also cache normalized, floating point components of the color in various\nrepresentations as they are calculated. This is done to prevent repeating a\nconversion that has already been performed.

\n' + }, + Setting: { + name: 'Setting', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Color', + namespace: '', + file: 'src/color/setting.js', + line: 1, + requires: ['core', 'constants'] + }, + Shape: { + name: 'Shape', + submodules: { + '2D Primitives': 1, + Curves: 1, + Vertex: 1, + '3D Primitives': 1, + '3D Models': 1 + }, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + '2D Primitives': { + name: '2D Primitives', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Shape', + namespace: '', + file: 'src/core/shape/2d_primitives.js', + line: 1, + requires: ['core', 'constants'] + }, + Attributes: { + name: 'Attributes', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Typography', + namespace: '', + file: 'src/core/shape/attributes.js', + line: 1, + requires: ['core', 'constants'] + }, + Curves: { + name: 'Curves', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Shape', + namespace: '', + file: 'src/core/shape/curves.js', + line: 1, + requires: ['core'] + }, + Vertex: { + name: 'Vertex', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Shape', + namespace: '', + file: 'src/core/shape/vertex.js', + line: 1, + requires: ['core', 'constants'] + }, + Constants: { + name: 'Constants', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {}, + module: 'Constants', + file: 'src/core/constants.js', + line: 1 + }, + Environment: { + name: 'Environment', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {}, + module: 'Environment', + file: 'src/core/environment.js', + line: 1, + requires: ['core', 'constants'] + }, + Structure: { + name: 'Structure', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {}, + module: 'IO', + file: 'src/core/main.js', + line: 1, + requires: ['constants'] + }, + DOM: { + name: 'DOM', + submodules: {}, + elements: {}, + classes: { + 'p5.Element': 1, + 'p5.MediaElement': 1, + 'p5.File': 1 + }, + fors: { + 'p5.Element': 1, + p5: 1 + }, + namespaces: {}, + module: 'DOM', + file: 'src/dom/dom.js', + line: 3392, + description: + "

The web is much more than just canvas and the DOM functionality makes it easy to interact\nwith other HTML5 objects, including text, hyperlink, image, input, video,\naudio, and webcam.

\n

There is a set of creation methods, DOM manipulation methods, and\nan extended p5.Element that supports a range of HTML elements. See the\n\nbeyond the canvas tutorial for a full overview of how this addon works.\n\n

See tutorial: beyond the canvas\nfor more info on how to use this library.", + requires: ['p5'] + }, + Rendering: { + name: 'Rendering', + submodules: { + undefined: 1 + }, + elements: {}, + classes: { + 'p5.RendererGL': 1, + 'p5.Graphics': 1, + 'p5.Renderer': 1 + }, + fors: { + p5: 1 + }, + namespaces: {}, + module: 'Rendering', + file: 'src/webgl/p5.RendererGL.js', + line: 600, + description: + '

Thin wrapper around a renderer, to be used for creating a\ngraphics buffer object. Use this class if you need\nto draw into an off-screen graphics buffer. The two parameters define the\nwidth and height in pixels. The fields and methods for this class are\nextensive, but mirror the normal drawing API for p5.

\n' + }, + Foundation: { + name: 'Foundation', + submodules: {}, + elements: {}, + classes: { + JSON: 1, + console: 1 + }, + fors: { + p5: 1, + JSON: 1, + console: 1 + }, + namespaces: {}, + tag: 'module', + file: 'src/core/reference.js', + line: 1 + }, + Transform: { + name: 'Transform', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {}, + module: 'Transform', + file: 'src/core/transform.js', + line: 1, + requires: ['core', 'constants'] + }, + Data: { + name: 'Data', + submodules: { + LocalStorage: 1, + Dictionary: 1, + 'Array Functions': 1, + Conversion: 1, + 'String Functions': 1 + }, + elements: {}, + classes: { + 'p5.TypedDict': 1, + 'p5.StringDict': 1, + 'p5.NumberDict': 1 + }, + fors: { + p5: 1, + 'p5.TypedDict': 1 + }, + namespaces: {}, + file: 'src/data/p5.TypedDict.js', + line: 417 + }, + LocalStorage: { + name: 'LocalStorage', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Data', + namespace: '', + file: 'src/data/local_storage.js', + line: 1, + requires: [ + 'core\n\nThis module defines the p5 methods for working with local storage' + ] + }, + Dictionary: { + name: 'Dictionary', + submodules: {}, + elements: {}, + classes: { + 'p5.TypedDict': 1, + 'p5.StringDict': 1, + 'p5.NumberDict': 1 + }, + fors: { + 'p5.TypedDict': 1, + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Data', + namespace: '', + file: 'src/data/p5.TypedDict.js', + line: 417, + requires: [ + 'core\n\nThis module defines the p5 methods for the p5 Dictionary classes.\nThe classes StringDict and NumberDict are for storing and working\nwith key-value pairs.' + ], + description: + '

Base class for all p5.Dictionary types. Specifically\n typed Dictionary classes inherit from this class.

\n' + }, + Events: { + name: 'Events', + submodules: { + Acceleration: 1, + Keyboard: 1, + Mouse: 1, + Touch: 1 + }, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + namespaces: {} + }, + Acceleration: { + name: 'Acceleration', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Events', + namespace: '', + file: 'src/events/acceleration.js', + line: 1, + requires: ['core'] + }, + Keyboard: { + name: 'Keyboard', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Events', + namespace: '', + file: 'src/events/keyboard.js', + line: 1, + requires: ['core'] + }, + Mouse: { + name: 'Mouse', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Events', + namespace: '', + file: 'src/events/mouse.js', + line: 1, + requires: ['core', 'constants'] + }, + Touch: { + name: 'Touch', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Events', + namespace: '', + file: 'src/events/touch.js', + line: 1, + requires: ['core'] + }, + Image: { + name: 'Image', + submodules: { + Pixels: 1 + }, + elements: {}, + classes: { + 'p5.Image': 1 + }, + fors: { + p5: 1 + }, + namespaces: {}, + module: 'Image', + file: 'src/image/p5.Image.js', + line: 21, + requires: ['core'], + description: + '

Creates a new p5.Image. A p5.Image is a canvas backed representation of an\nimage.\n

\np5 can display .gif, .jpg and .png images. Images may be displayed\nin 2D and 3D space. Before an image is used, it must be loaded with the\nloadImage() function. The p5.Image class contains fields for the width and\nheight of the image, as well as an array called pixels[] that contains the\nvalues for every pixel in the image.\n

\nThe methods described below allow easy access to the image's pixels and\nalpha channel and simplify the process of compositing.\n

\nBefore using the pixels[] array, be sure to use the loadPixels() method on\nthe image to make sure that the pixel data is properly loaded.

\n' + }, + 'Loading & Displaying': { + name: 'Loading & Displaying', + submodules: {}, + elements: {}, + classes: { + 'p5.Font': 1 + }, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Typography', + namespace: '', + file: 'src/typography/p5.Font.js', + line: 13, + requires: ['core'], + description: + '

This module defines the p5.Font class and functions for\ndrawing text to the display canvas.

\n' + }, + Pixels: { + name: 'Pixels', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Image', + namespace: '', + file: 'src/image/pixels.js', + line: 1, + requires: ['core'] + }, + IO: { + name: 'IO', + submodules: { + Structure: 1, + Input: 1, + Output: 1, + Table: 1, + 'Time & Date': 1 + }, + elements: {}, + classes: { + p5: 1, + 'p5.PrintWriter': 1, + 'p5.Table': 1, + 'p5.TableRow': 1, + 'p5.XML': 1 + }, + fors: { + p5: 1 + }, + namespaces: {}, + file: 'src/io/p5.XML.js', + line: 9 + }, + Input: { + name: 'Input', + submodules: {}, + elements: {}, + classes: { + 'p5.XML': 1 + }, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'IO', + namespace: '', + file: 'src/io/p5.XML.js', + line: 9, + requires: ['core'], + description: + '

XML is a representation of an XML object, able to parse XML code. Use\nloadXML() to load external XML files and create XML objects.

\n' + }, + Output: { + name: 'Output', + submodules: {}, + elements: {}, + classes: { + p5: 1, + 'p5.PrintWriter': 1 + }, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'IO', + namespace: '', + file: 'src/io/files.js', + line: 1235, + description: + '

This is the p5 instance constructor.

\n

A p5 instance holds all the properties and methods related to\na p5 sketch. It expects an incoming sketch closure and it can also\ntake an optional node parameter for attaching the generated p5 canvas\nto a node. The sketch closure takes the newly created p5 instance as\nits sole argument and may optionally set preload(), setup(), and/or\ndraw() properties on it for running a sketch.

\n

A p5 sketch can run in "global" or "instance" mode:\n"global" - all properties and methods are attached to the window\n"instance" - all properties and methods are bound to this p5 object

\n' + }, + Table: { + name: 'Table', + submodules: {}, + elements: {}, + classes: { + 'p5.Table': 1, + 'p5.TableRow': 1 + }, + fors: {}, + is_submodule: 1, + namespaces: {}, + module: 'IO', + namespace: '', + file: 'src/io/p5.TableRow.js', + line: 9, + requires: ['core'], + description: + '

Table objects store data with multiple rows and columns, much\nlike in a traditional spreadsheet. Tables can be generated from\nscratch, dynamically, or using data from an existing file.

\n' + }, + Math: { + name: 'Math', + submodules: { + Calculation: 1, + Vector: 1, + Noise: 1, + Random: 1, + Trigonometry: 1 + }, + elements: {}, + classes: { + 'p5.Vector': 1 + }, + fors: { + p5: 1 + }, + namespaces: {}, + file: 'src/math/p5.Vector.js', + line: 10 + }, + Calculation: { + name: 'Calculation', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Math', + namespace: '', + file: 'src/math/calculation.js', + line: 1, + requires: ['core'] + }, + Vector: { + name: 'Vector', + submodules: {}, + elements: {}, + classes: { + 'p5.Vector': 1 + }, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Math', + namespace: '', + file: 'src/math/p5.Vector.js', + line: 10, + requires: ['core'], + description: + '

A class to describe a two or three dimensional vector, specifically\na Euclidean (also known as geometric) vector. A vector is an entity\nthat has both magnitude and direction. The datatype, however, stores\nthe components of the vector (x, y for 2D, and x, y, z for 3D). The magnitude\nand direction can be accessed via the methods mag() and heading().\n

\nIn many of the p5.js examples, you will see p5.Vector used to describe a\nposition, velocity, or acceleration. For example, if you consider a rectangle\nmoving across the screen, at any given instant it has a position (a vector\nthat points from the origin to its location), a velocity (the rate at which\nthe object's position changes per time unit, expressed as a vector), and\nacceleration (the rate at which the object's velocity changes per time\nunit, expressed as a vector).\n

\nSince vectors represent groupings of values, we cannot simply use\ntraditional addition/multiplication/etc. Instead, we'll need to do some\n"vector" math, which is made easy by the methods inside the p5.Vector class.

\n' + }, + Noise: { + name: 'Noise', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Math', + namespace: '', + file: 'src/math/noise.js', + line: 14, + requires: ['core'] + }, + Random: { + name: 'Random', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Math', + namespace: '', + file: 'src/math/random.js', + line: 1, + requires: ['core'] + }, + Trigonometry: { + name: 'Trigonometry', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Math', + namespace: '', + file: 'src/math/trigonometry.js', + line: 1, + requires: ['core', 'constants'] + }, + Typography: { + name: 'Typography', + submodules: { + Attributes: 1, + 'Loading & Displaying': 1 + }, + elements: {}, + classes: { + 'p5.Font': 1 + }, + fors: { + p5: 1 + }, + namespaces: {}, + file: 'src/typography/p5.Font.js', + line: 13 + }, + 'Array Functions': { + name: 'Array Functions', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Data', + namespace: '', + file: 'src/utilities/array_functions.js', + line: 1, + requires: ['core'] + }, + Conversion: { + name: 'Conversion', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Data', + namespace: '', + file: 'src/utilities/conversion.js', + line: 1, + requires: ['core'] + }, + 'String Functions': { + name: 'String Functions', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Data', + namespace: '', + file: 'src/utilities/string_functions.js', + line: 1, + requires: ['core'] + }, + 'Time & Date': { + name: 'Time & Date', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'IO', + namespace: '', + file: 'src/utilities/time_date.js', + line: 1, + requires: ['core'] + }, + '3D Primitives': { + name: '3D Primitives', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Shape', + namespace: '', + file: 'src/webgl/3d_primitives.js', + line: 1, + requires: ['core', 'p5.Geometry'] + }, + 'Lights, Camera': { + name: 'Lights, Camera', + submodules: { + Interaction: 1, + Lights: 1, + Material: 1, + Camera: 1 + }, + elements: {}, + classes: { + 'p5.Camera': 1, + 'p5.Geometry': 1, + 'p5.Matrix': 1, + 'p5.Shader': 1, + 'p5.Texture': 1, + ImageInfos: 1, + FontInfo: 1, + Cubic: 1 + }, + fors: { + p5: 1, + 'p5.Camera': 1 + }, + namespaces: {}, + file: 'src/webgl/text.js', + line: 260 + }, + Interaction: { + name: 'Interaction', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Lights, Camera', + namespace: '', + file: 'src/webgl/interaction.js', + line: 1, + requires: ['core'] + }, + Lights: { + name: 'Lights', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Lights, Camera', + namespace: '', + file: 'src/webgl/light.js', + line: 1, + requires: ['core'] + }, + '3D Models': { + name: '3D Models', + submodules: {}, + elements: {}, + classes: {}, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Shape', + namespace: '', + file: 'src/webgl/loading.js', + line: 1, + requires: ['core', 'p5.Geometry'] + }, + Material: { + name: 'Material', + submodules: {}, + elements: {}, + classes: { + 'p5.Geometry': 1, + 'p5.Shader': 1, + 'p5.Texture': 1 + }, + fors: { + p5: 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Lights, Camera', + namespace: '', + file: 'src/webgl/p5.Texture.js', + line: 12, + requires: ['core'], + description: '

This module defines the p5.Shader class

\n' + }, + Camera: { + name: 'Camera', + submodules: {}, + elements: {}, + classes: { + 'p5.Camera': 1 + }, + fors: { + p5: 1, + 'p5.Camera': 1 + }, + is_submodule: 1, + namespaces: {}, + module: 'Lights, Camera', + namespace: '', + file: 'src/webgl/p5.Camera.js', + line: 320, + requires: ['core'], + description: + '

This class describes a camera for use in p5's\n\nWebGL mode. It contains camera position, orientation, and projection\ninformation necessary for rendering a 3D scene.

\n

New p5.Camera objects can be made through the\ncreateCamera() function and controlled through\nthe methods described below. A camera created in this way will use a default\nposition in the scene and a default perspective projection until these\nproperties are changed through the various methods available. It is possible\nto create multiple cameras, in which case the current camera\ncan be set through the setCamera() method.

\n

Note:\nThe methods below operate in two coordinate systems: the 'world' coordinate\nsystem describe positions in terms of their relationship to the origin along\nthe X, Y and Z axes whereas the camera's 'local' coordinate system\ndescribes positions from the camera's point of view: left-right, up-down,\nand forward-backward. The move() method,\nfor instance, moves the camera along its own axes, whereas the\nsetPosition()\nmethod sets the camera's position in world-space.

\n' + }, + 'p5.sound': { + name: 'p5.sound', + submodules: {}, + elements: {}, + classes: { + 'p5.sound': 1, + 'p5.Effect': 1, + 'p5.Filter': 1, + 'p5.LowPass': 1, + 'p5.HighPass': 1, + 'p5.BandPass': 1, + 'p5.Oscillator': 1, + 'p5.SinOsc': 1, + 'p5.TriOsc': 1, + 'p5.SawOsc': 1, + 'p5.SqrOsc': 1, + 'p5.MonoSynth': 1, + 'p5.AudioVoice': 1, + 'p5.PolySynth': 1, + 'p5.SoundFile': 1, + 'p5.Amplitude': 1, + 'p5.FFT': 1, + 'p5.Signal': 1, + 'p5.Envelope': 1, + 'p5.Pulse': 1, + 'p5.Noise': 1, + 'p5.AudioIn': 1, + 'p5.EQ': 1, + 'p5.Panner3D': 1, + 'p5.Delay': 1, + 'p5.Reverb': 1, + 'p5.Convolver': 1, + 'p5.Phrase': 1, + 'p5.Part': 1, + 'p5.Score': 1, + 'p5.SoundLoop': 1, + 'p5.Compressor': 1, + 'p5.SoundRecorder': 1, + 'p5.PeakDetect': 1, + 'p5.Gain': 1, + 'p5.Distortion': 1 + }, + fors: { + 'p5.sound': 1, + 'p5.Effect': 1, + p5: 1, + 'p5.Oscillator': 1, + 'p5.MonoSynth': 1, + 'p5.AudioVoice': 1, + 'p5.PolySynth': 1, + 'p5.SoundFile': 1, + 'p5.Amplitude': 1, + 'p5.FFT': 1, + 'p5.Signal': 1, + 'p5.Envelope': 1, + 'p5.AudioIn': 1, + 'p5.EQ': 1, + 'p5.Panner3D': 1, + 'p5.Delay': 1, + 'p5.Reverb': 1, + 'p5.Convolver': 1, + 'p5.Part': 1, + 'p5.Score': 1, + 'p5.SoundLoop': 1, + 'p5.Compressor': 1, + 'p5.SoundRecorder': 1, + 'p5.Gain': 1, + 'p5.Distortion': 1 + }, + namespaces: {}, + module: 'p5.sound', + file: 'lib/addons/p5.sound.js', + line: 11703, + description: + '

p5.sound extends p5 with Web Audio functionality including audio input,\nplayback, analysis and synthesis.\n

\n