@@ -3,11 +3,16 @@ import "./GraphPage.css";
33import { dijkstra , aStarManhattan , aStarDiagonal , aStarEuclidean , depthFirstSearch , breadthFirstSearch , getNodesInShortestPathOrder } from "./graph_components/graphAlgorithms" ;
44import { 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
88import { Node } from './graph_components/Node' ;
99import 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+
1116let nodeSize = 1.6 ;
1217let prevTimeout = 0 ;
1318let 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 > : '' }
0 commit comments