diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..908e754
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,2 @@
+- name: Check Signed Commits in PR
+ uses: 1Password/check-signed-commits-action@v1
diff --git a/src/pages/FloodFill/index.js b/src/pages/FloodFill/index.js
index 1c7e4f4..dba2ca5 100644
--- a/src/pages/FloodFill/index.js
+++ b/src/pages/FloodFill/index.js
@@ -1,109 +1,137 @@
-
-import React, { useState, useEffect } from 'react'
-import './FloodFill.css'
-import { startFloodFill } from './algorithm'
-import Container from '../../components/Container/index'
-import Menu from '../../components/Menu/index'
-import { ReactComponent as GithubLogo } from '../../images/github-logo.svg';
+import React, { useState, useEffect } from "react";
+import "./FloodFill.css";
+import { startFloodFill } from "./algorithm";
+import Container from "../../components/Container/index";
+import Menu from "../../components/Menu/index";
+import { ReactComponent as GithubLogo } from "../../images/github-logo.svg";
const FloodFill = () => {
- const [image, setImage] = useState([[]])
- const [flooding, setFlooding] = useState(false)
- const [fillType, setFillType] = useState("RANDOM")
- const [dimension, setDimension] = useState(20)
- const [connectedNeighbours, setConnectedNeighbours] = useState(4)
+ const [image, setImage] = useState([[]]);
+ const [flooding, setFlooding] = useState(false);
+ const [fillType, setFillType] = useState("RANDOM");
+ const [dimension, setDimension] = useState(20);
+ const [connectedNeighbours, setConnectedNeighbours] = useState(4);
- const onDimensionChange = (size) => {
- let row = [], newImage = []
- for (let index = 0; index < size; index++) {
- row = []
- for (let index = 0; index < size; index++) {
- row[index] = fillType === "RANDOM" ? (Math.round(Math.random()) ? "#000" : "red") : "red"
- }
- newImage[index] = row
- }
- setImage(newImage)
+ const onDimensionChange = (size) => {
+ let row = [],
+ newImage = [];
+ for (let index = 0; index < size; index++) {
+ row = [];
+ for (let index = 0; index < size; index++) {
+ row[index] =
+ fillType === "RANDOM"
+ ? Math.round(Math.random())
+ ? "#000"
+ : "red"
+ : "red";
+ }
+ newImage[index] = row;
}
+ setImage(newImage);
+ };
- useEffect(() => {
- onDimensionChange(dimension)
- }, [dimension, fillType])
+ useEffect(() => {
+ onDimensionChange(dimension);
+ }, [dimension, fillType]);
- const onCellClick = async (a, b) => {
- if (flooding) return
- setFlooding(true)
- const finish = await startFloodFill(JSON.parse(JSON.stringify(image)), image[a][b] === "white" ? "#0cff0c" : "white", image[a][b], [a, b], setImage, Number(connectedNeighbours))
- if (finish) {
- setFlooding(false)
- }
+ const onCellClick = async (a, b) => {
+ if (flooding) return;
+ setFlooding(true);
+ const finish = await startFloodFill(
+ JSON.parse(JSON.stringify(image)),
+ image[a][b] === "white" ? "#0cff0c" : "white",
+ image[a][b],
+ [a, b],
+ setImage,
+ Number(connectedNeighbours)
+ );
+ if (finish) {
+ setFlooding(false);
}
- return (
- <>
- Click on a tile to start. Flooding...
- Flood Fill
-
-
- {image.map((row, a) =>
- {row.map((cellColor, b) => )}
- {
- onCellClick(a, b)
- }}> )}
Click on a tile to start.
+| { + onCellClick(a, b); + }} + > | + ))} +
Flooding...
} +