Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns Group-K-352)
- ;;The 2d vec-img , Dimensions of the vec-img (8x8 etc) - 1 (As index 0) , Starting X coord, Starting Y coord, What to replace old with , What old is.
- (defn flood-fill [vec-img , dimensions , x , y , old , new]
- (cond
- (= old new)
- vec-img
- ;;If the vectors dont contain the old color
- (not (contains? vec-img old))
- vec-img
- ;;If the target isnt of the old color
- (not (= (get-in vec-img [x y]) old))
- vec-img
- (and (and (<= x dimensions) (<= y dimensions)) (and (>= x 0) (>= y 0)))
- (flood-fill
- (flood-fill
- (flood-fill
- (flood-fill
- (flood-fill
- (flood-fill
- (flood-fill
- (flood-fill
- (flood-fill
- (assoc-in vec-img [x y] new) , dimensions , x, y , old , new)
- , dimensions , (+ x 1), y , old , new)
- , dimensions , (+ x 1), (+ y 1) , old , new)
- , dimensions , (+ x 1), (- y 1) , old , new)
- , dimensions , x, (- y 1) , old , new)
- , dimensions , x, (+ y 1) , old , new)
- , dimensions , (- x 1), (+ y 1) , old , new)
- , dimensions , (- x 1), (- y 1) , old , new)
- , dimensions , (- x 1), y, old , new)
- :else
- vec-img
- ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement