Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  (ns Group-K-352)
  2.  
  3. ;;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.
  4. (defn flood-fill [vec-img , dimensions , x , y , old , new]
  5.  
  6.   (cond
  7.     (= old new)
  8.     vec-img
  9.  
  10.     ;;If the vectors dont contain the old color
  11.     (not (contains? vec-img old))
  12.     vec-img
  13.  
  14.     ;;If the target isnt of the old color
  15.     (not (= (get-in vec-img [x y]) old))
  16.     vec-img
  17.  
  18.     (and (and (<= x dimensions) (<= y dimensions)) (and (>= x 0) (>= y 0)))
  19.     (flood-fill
  20.       (flood-fill
  21.         (flood-fill
  22.           (flood-fill
  23.             (flood-fill
  24.               (flood-fill
  25.                 (flood-fill
  26.                   (flood-fill
  27.                     (flood-fill
  28.                       (assoc-in vec-img [x y] new) , dimensions , x, y , old , new)
  29.                     , dimensions , (+ x 1), y , old , new)
  30.                   , dimensions , (+ x 1), (+ y 1) , old , new)
  31.                 , dimensions , (+ x 1), (- y 1) , old , new)
  32.               , dimensions , x, (- y 1) , old , new)
  33.             , dimensions , x, (+ y 1) , old , new)
  34.           , dimensions , (- x 1), (+ y 1) , old , new)
  35.         , dimensions , (- x 1), (- y 1) , old , new)
  36.       , dimensions , (- x 1), y, old , new)
  37.  
  38.     :else
  39.     vec-img
  40.     ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement