This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MJS (..) | |
import Graphics.WebGL (..) | |
main = webgl (400, 400) scene | |
type Point = {point : V3} | |
toPoint vector = { point = vector } | |
triangle : V3 -> V3 -> V3 -> Triangle Point | |
triangle p1 p2 p3 = (toPoint p1, toPoint p2, toPoint p3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------ | |
-- GLOBAL VARIABLES TO PLAY WITH | |
------------------------------------------------ | |
-- number of iterations of the Julia Set | |
maxIterations : Int | |
maxIterations = 100 | |
-- The constant c used in the julia function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------ | |
-- 2D Point Type | |
type Point = { | |
x : Float, | |
y : Float | |
} | |
-- Convert Point to a tuple of floats | |
toTuple : Point -> (Float, Float) | |
toTuple point = (point.x, point.y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import List (..) | |
import Graphics.Collage (..) | |
import Graphics.Element (..) | |
import Color (..) | |
------------------------------------------ | |
-- 2D Point Type | |
type alias Point = { | |
x : Float, | |
y : Float |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.WebGL as GL | |
import Math.Vector3 as GL | |
import Math.Matrix4 as GL | |
type Point = { | |
x : Float, | |
y : Float, | |
z : Float | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.WebGL (..) | |
import Math.Vector3 (..) | |
import Math.Matrix4 (..) | |
type Attribute = {position : Vec3} | |
type Uniform = { rotationMatrix : Mat4} | |
type Varying = {} | |
mapMesh : (a -> b) -> [Triangle a] -> [Triangle b] | |
mapMesh = map << mapTriangle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quickCheck : Generator a -> Int -> (a -> Bool) -> String | |
quickCheck randomGenerator numberOfCases testingCondition = | |
let listGenerator = list numberOfCases <| randomGenerator | |
testInputs = fst <| generate listGenerator (initialSeed 1) | |
getOutput input = (input, testingCondition input) | |
testOutputs = map getOutput testInputs | |
failingOutputs = filter (\x -> (snd x) == False) testOutputs | |
successString = "Ok, passed " ++ (toString numberOfCases) ++ " tests." | |
failingString fail = "The following input has failed the test: " ++ (toString fail) | |
in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interleave : List a -> List a -> List a | |
interleave list1 list2 = | |
case list1 of | |
[] -> list2 | |
x :: xs -> | |
case list2 of | |
[] -> list1 | |
y :: ys -> y :: x :: interleave xs ys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.Collage (move, filled, circle, Form, collage) | |
import Graphics.Element (Element) | |
import List (map, map2, (::), head, tail) | |
import Color (rgb) | |
--- GLOBALS YOU CAN MESS WITH | |
pointSize = 3 -- THE SIZE OF THE POINTS | |
pointColor = rgb 255 100 0 -- THE COLOR OF THE POINTS | |
iterations = 5 -- NUMBER OF ITERATIONS OF CATMULL-CLARK SUBDIVISION |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mapAll : (a -> a -> a) -> List a -> List (List a) | |
mapAll f list = | |
let innerMapAll f tempList = | |
case tempList of | |
[] -> [] | |
x :: xs -> map (f x) list :: innerMapAll f xs | |
in innerMapAll f list |
OlderNewer