Skip to content

Commit 968cf23

Browse files
authored
Merge pull request #64 from code-dot-org/hbergam/glomming-update
Adding second paint glomming algorithm and createDrawer flag to switch between SquareDrawer and CircleDrawer
2 parents 517878c + d273cdd commit 968cf23

File tree

3 files changed

+496
-9
lines changed

3 files changed

+496
-9
lines changed

src/neighborhood.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Subtype from "./subtype";
22
import NeighborhoodCell from "./neighborhoodCell";
3-
import NeighborhoodDrawer from "./neighborhoodDrawer";
3+
import NeighborhoodSquareDrawer from "./neighborhoodSquareDrawer";
4+
import NeighborhoodCircleDrawer from "./neighborhoodCircleDrawer";
45
import { Direction } from "./tiles";
56

67
module.exports = class Neighborhood extends Subtype {
@@ -75,14 +76,24 @@ module.exports = class Neighborhood extends Subtype {
7576
/**
7677
* @override
7778
**/
78-
createDrawer(svg) {
79-
this.drawer = new NeighborhoodDrawer(
80-
this.maze_.map,
81-
this.skin_,
82-
svg,
83-
this.squareSize,
84-
this
85-
);
79+
createDrawer(svg, drawer = "square") {
80+
if (drawer === "square") {
81+
this.drawer = new NeighborhoodSquareDrawer(
82+
this.maze_.map,
83+
this.skin_,
84+
svg,
85+
this.squareSize,
86+
this
87+
);
88+
} else {
89+
this.drawer = new NeighborhoodCircleDrawer(
90+
this.maze_.map,
91+
this.skin_,
92+
svg,
93+
this.squareSize,
94+
this
95+
);
96+
}
8697
}
8798

8899
/**
File renamed without changes.

0 commit comments

Comments
 (0)