Skip to content

Latest commit

 

History

History
55 lines (33 loc) · 1.37 KB

README.md

File metadata and controls

55 lines (33 loc) · 1.37 KB

pixels

A Clojure library designed to simulate operations on pixmaps. Note that the pixmaps are represented by vectors of vectors, which means in the code the coordinates are reversed to allow use of things like get-in.

Prerequisites

The following are required to run this tool:

Usage

(require '[pixels.core])

Create a new image:

(def image (I 3 4))
=> [["O" "O" "O"] ["O" "O" "O"] ["O" "O" "O"] ["O" "O" "O"]]

Colour a pixel:

(L image 2 2 "X")
=> [["O" "O" "O"] ["O" "X" "O"] ["O" "O" "O"] ["O" "O" "O"]]

Paint a vertical segment:

(V image 3 2 4 "X")
=> [["O" "O" "O"] ["O" "O" "X"] ["O" "O" "X"] ["O" "O" "X"]] 

Paint a horizontal segment:

(H image 1 3 2 "X")
=> [["O" "O" "O"] ["X" "X" "X"] ["O" "O" "O"] ["O" "O" "O"]]

Flood fill a region:

(def question-mark [["X" "X" "X"]
                    ["X" "O" "X"]
                    ["O" "X" "X"]
                    ["O" "X" "O"]])
                    
(F question-mark 2 3 "I")
=> [["I" "I" "I"] ["I" "O" "I"] ["O" "I" "I"] ["O" "I" "O"]]

Running tests

Tests are written using Midje

lein midje

License

Copyright © 2015 Conan Cook