AuthorTravis Kirton
Tags math, interaction
This example shows the effect of the map() function.
map()
let result = map(value)
To run this example you need to include the MathComparePaths.swift file in your project.
let example = MathComparePaths(frame: canvas.frame) { var points = [Point]() var modifiedPoints = [Point]() var x = 0.0 repeat { let y = sin(x * 2 * M_PI) * -1//-1 inverts iOS coordinates to look normal let my = map(y, min: -1, max: 1, toMin: -1, toMax: 0) //same as above modifiedPoints.append(Point(x, my)) points.append(Point(x, y)) x += 0.001 } while x < 1 return (points, modifiedPoints) } canvas.add(example)