Skip to content

Commit

Permalink
bumpy but working
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hamblen committed Apr 10, 2010
1 parent 07db921 commit 1c87764
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions TI-81/TI-81.spde
@@ -0,0 +1,26 @@
def plot(minX: Int, maxX: Int) = {
val rangeX = maxX - minX
lazy val inputs = (0 to width) map { px =>
(px, minX + (px.toFloat / width * rangeX).toInt)
}
{ f: (Int => Int) =>
val values = inputs map { case (px, x) => (px, x, f(x)) }
val (headPX, headX, headY) = values.head
val (minY, maxY) = ((headX, headY) /: values.tail) {
case ((max, min), (px, x, y)) =>
(if (y > max) y else max, if (y < min) y else min)
}
val rangeY = maxY - minY
val points = values map { case (px, x, y) =>
(px, ((y - minY).toFloat / rangeY * height).toInt)
}
for ( (x, y) <- points ) point(x, y)
}
}
val centplot = plot(-100, 100)

size(500, 500)

def draw {
centplot { x => x }
}
1 change: 1 addition & 0 deletions project/build/ExamplesProject.scala
Expand Up @@ -10,6 +10,7 @@ class ExamplesProject(info: ProjectInfo) extends ParentProject(info) with poster
lazy val gasket = project("Sierpinski", "Sierpinski_Gasket", new DefaultSpdeProject(_))
lazy val lsystems = project("L-Systems", "L_Systems", new DefaultSpdeProject(_))
lazy val matrix = project("Matrix", "Matrix", new DefaultOpenGLProject(_))
lazy val ti_81 = project("TI-81", "TI-81", new DefaultSpdeProject(_))

/* Video projects use GSVideo, see VIDEO.md for more info. */
lazy val loop = project("Loop", "Loop", new SampleVideoProject(_))
Expand Down

0 comments on commit 1c87764

Please sign in to comment.