Random Mondrian Art
Devon Kenzie, Myla White
What is the problem?
We are looking to explore the feasibility of using Haskell to create personal and creative art work. Based off of Dr. Ben Stephenson's Mondrian Art project, will use Haskell to implement a recursive algorithm that will output Mondrian style art. Colours, box sizes, and box shapes are randomly generated to create the artwork, but will fit a theme as depicted by the user. The user will personalize the artwork through their own character traits.
What is the something extra?
Cohesive colour palettes will be outputted as SVG tags, either based off user input or generated randomly. The colour palettes are created parallel to the user's personality, so that the art work is original for every individual who uses the program. The program is extended with different strategies for creating shapes and sizes to reflect the user's artistic creativity, so that the user can create, interact with, and view their own artwork.
What did we learn from doing this?
Overall, this was a very interesting project as it allowed both of us to be very creative in what we wanted the final result to look like, and therefore allowed us to extensively play with the program itself and learn about it's nuances through a hands-on approach. We both got experience in integrating Haskell and HTML, using user input to influence the output, and learning how to have an output that is both random and cohesive.
We noticed that, as the language for this project, Haskell was considerably easier to debug than other projects of similar lengths we had written in other languages. For the most part, we were able to keep our program clear and concise, so that we could focus more on how we wanted to influence the final result, rather than any minor details for each little line of code. It was very easy to modify both the original skeleton template we started with, and our own program as it got more complex, to accommodate for any extra features we wanted to add throughout. As well, we didn't have to worry about spending hours debugging after each addition was made.
From our experience, Haskell did a good job of handling all of the random elements of our program, like randomList and randomColor, despite not using monads.
-- -- Generates and returns a list of 20000 random doubles between 0 and 1, -- for use in generating random colours if 'Random' was chosen. -- randomList :: Int -> [Double] randomList seed = take 20000 (rl_helper (mkStdGen seed)) -- -- Helper for randomList by generating one random Double between 0 and 1. -- rl_helper :: StdGen -> [Double] rl_helper g = fst vg : rl_helper (snd vg) where vg = randomR (0.0, 1.0 :: Double) g
Here, we were concisely able to generate a sufficient-sized random list of numbers to be used in the generation of random colours.
Haskell was also quite suitable for allowing us to interact with the user.
-- Decides on image type -- 1 = gradient (fewer colours, more consistency with colour spread) -- 2 = random (more colours, completely random colour spread) putStrLn("\nPlease type a number from 1 to 2:\nWould you prefer a gradient or random colours?\n1. Gradient\n2. Random") answer <- getLine sanitation answer [isDigit, (`elem` ['1','2'])]
We found it to be really straightforward to acquire user input that we could then develop our program around. Ensuring that the input wouldn't end up being buggy or causing unnecessary grief to our program was also a relatively simple task.
We still needed to use HTML to output the image, as using Haskell to do this would have involved a dependency on a graphics library which could be relatively complicated. Python or Java could be used to implement this project using any graphics library or HTML.