Skip to content

Commit fae44b9

Browse files
Made it better (still pretty ugly)
1 parent a43b08e commit fae44b9

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

.DS_Store

6 KB
Binary file not shown.

algorithm_visualizer/src/pages/GraphPage.css

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,40 +96,38 @@ li > input {
9696
display: block;
9797
}
9898

99-
.settings-menu {
99+
.graphPage .settings-menu {
100100
padding-top: .5rem;
101101
}
102102

103-
.settings-menu label {
103+
.graphPage .settings-menu label {
104104
font-size: .85rem;
105105
}
106106

107-
.sidebar i {
107+
.graphPage .sidebar i {
108108
margin-right: .5rem;
109109
}
110110

111-
.camera-modal {
111+
.graphPage .camera-modal {
112112
background-color: black;
113113
border: 1px solid white
114114
}
115115

116-
.skip-button {
116+
.graphPage .skip-button {
117117
margin-left: 1.25rem;
118118
}
119119

120-
.modal-dialog,
121-
.modal-content {
122-
height: 80%;
123-
}
124-
125-
#tutorial p {
120+
.graphPage #tutorial p {
126121
padding-top: 1.25rem;
127122
margin-right: 1.25rem;
128123
margin-left: 1.25rem;
129124
text-align: center;
130125
}
131126

132-
.modal-header {
127+
.graphPage .modal-header {
133128
text-align: center;
134129
}
135130

131+
.graphPage .modal-body img {
132+
width:100%;
133+
}

algorithm_visualizer/src/pages/GraphPage.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ import "./GraphPage.css";
33
import { dijkstra, aStarManhattan, aStarDiagonal, aStarEuclidean, depthFirstSearch, breadthFirstSearch, getNodesInShortestPathOrder } from "./graph_components/graphAlgorithms";
44
import { recursiveDivision, randomMaze, randomWeightedMaze, prims, dfsMaze, binaryTreeMaze, terrainMap, fileReaderTerrain } from "./graph_components/mazeAlgorithms";
55

6-
import { useState, useEffect, useRef } from "react"
6+
import { useState, useEffect, useRef } from "react";
77

88
import {Node} from './graph_components/Node';
99
import Webcam from "react-webcam";
1010

11+
import tutorialGif1 from './graph_components/tutorial/tutorial_page_1.gif';
12+
import tutorialGif2 from './graph_components/tutorial/tutorial_page_2.gif';
13+
import tutorialGif3 from './graph_components/tutorial/tutorial_page_3.gif';
14+
import tutorialGif4 from './graph_components/tutorial/tutorial_page_4.gif';
15+
1116
let nodeSize = 1.6;
1217
let prevTimeout = 0;
1318
let mouseButton = -1;
@@ -45,7 +50,7 @@ export const GraphPage = () => {
4550
[endRow, endCol] = [grid.length-3, grid[0].length-3];
4651
resetGrid();
4752
})
48-
53+
4954
resizeGrid();
5055
window.addEventListener('resize', resizeGrid);
5156
document.addEventListener("mousedown", handleMouseDown);
@@ -255,7 +260,7 @@ export const GraphPage = () => {
255260
resetGrid();
256261
const walls = mazeFunction(grid);
257262

258-
const delay = 1500 / walls.length;
263+
const delay = 3000 / walls.length;
259264
const wallsPerIteration = delay > 2 ? 1 : Math.ceil(2 / delay);
260265

261266
for (let i = 0; i < walls.length; i += wallsPerIteration) {
@@ -472,6 +477,7 @@ export const GraphPage = () => {
472477
<input type="file" onChange={(e) => {fileReaderTerrain(grid, readImageInput(e)).then(walls => generateMaze(() => walls)).catch((err) => {console.log(err)})}} accept=".jpg, .jpeg, .png"/>
473478
<i className="far fa-image fa-sm"></i>Image Terrain
474479
</li></label>
480+
475481
<li type="button" data-bs-toggle="modal" data-bs-target="#modal" onClick={()=>{setWebcamState(true)}}><i className="fas fa-camera fa-sm"></i>Webcam Terrain</li>
476482
</ul>
477483
</div>
@@ -512,7 +518,7 @@ export const GraphPage = () => {
512518
animationSpeed = parseInt(e.target.value);
513519
}} />
514520
</div>
515-
<li type="button" data-bs-toggle="modal" data-bs-target="#tutorial">Tutorial</li>
521+
<li type="button" data-bs-toggle="modal" data-bs-target="#tutorial" onClick={()=>{setTutorialPage(1)}}>Tutorial</li>
516522
</div>
517523

518524
{/* Graph Algorithm Grid */}
@@ -537,11 +543,10 @@ export const GraphPage = () => {
537543
</div>
538544

539545
{/* Tutorial Popup Window */}
540-
<div className="modal fade" id="tutorial" tabindex="-1" aria-labelledby="modal-label" aria-hidden="true">
541-
<div className="modal-dialog modal-dialog-centered">
546+
<div className="modal show fade" id="tutorial" tabindex="-1" aria-labelledby="myLargeModalLabel" aria-hidden="true">
547+
<div className="modal-dialog modal-dialog-centered modal-lg">
542548
<div className="modal-content camera-modal">
543549
<div className="modal-header">
544-
{/*<button type="button" className="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>*/}
545550
<h5 className="col-12 modal-title text-white" id="modal-label"><b>Tutorial - {
546551
(tutorialPage == 1) ? 'Graph Algorithms'
547552
: (tutorialPage == 2) ? 'Weighted/Unweighted'
@@ -554,6 +559,11 @@ export const GraphPage = () => {
554559
: (tutorialPage == 2) ? <p>All of the algorithms on this application are adapted for a 2D grid, movement through a node has a "cost" of 1. Different weights can be added by utilizing the Wall Weight Slider under the options menu. Weighted algorithms will take into consideration of these different weights on the grid whereas unweighted algorithms will ignore them entirely.</p>
555560
: (tutorialPage == 3) ? <p>You can generate a maze using the algorithms within the maze dropdown. Weighted mazes are referred to as terrains. These can be created via image upload, webcam picture, or created within the application.</p>
556561
: <p>The option menu allows the user to adapt the grid to their liking. This includes features such as setting wall weights, adjusting the grid size, and changing the animation speed.</p>
562+
}{
563+
(tutorialPage == 1) ? <img src={tutorialGif1} alt="loading..." />
564+
: (tutorialPage == 2) ? <img src={tutorialGif2} alt="loading..." />
565+
: (tutorialPage == 3) ? <img src={tutorialGif3} alt="loading..." />
566+
: <img src={tutorialGif4 } alt="loading..." />
557567
}</div>
558568
<div className="modal-footer">
559569
{(tutorialPage == 1) ? <button className="btn btn-outline-light" id="skip-button" data-bs-dismiss="modal">Skip</button> : ''}
1.3 MB
Loading
1.35 MB
Loading
287 KB
Loading
63 KB
Loading

0 commit comments

Comments
 (0)