Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

take out zoom, use Floats

  • Loading branch information...
commit 97e75fbec02ee6014cfabbde726ae525d8e1ea66 1 parent 39d4cad
@n8han authored
Showing with 5 additions and 14 deletions.
  1. +5 −14 core-scala/src/main/scala/spde/core/Enrich.scala
View
19 core-scala/src/main/scala/spde/core/Enrich.scala
@@ -81,27 +81,18 @@ trait FunctionPlotting { self: processing.core.PApplet =>
lazy val inputs = (0 to width) map { px =>
(px, minX + rangeX * px / width)
}
- { f: (Float => Float) => for ( (px, x) <- inputs ) yield (px, f(x)) }
- }
- /** adjust y values to fill the view height */
- def zoom(points: Seq[Tuple2[Int, Float]]) = {
- val (minY, maxY) = ((points.head._2, points.head._2) /: points.tail) {
- case ((max, min), (px, y)) =>
- (if (y > max) y else max, if (y < min) y else min)
- }
- val rangeY = maxY - minY
- for ( (px, y) <- points ) yield (px, ((y - minY) / rangeY * height).toInt)
+ { f: (Float => Float) => for ( (px, x) <- inputs ) yield (px.toFloat, f(x)) }
}
/** Plots each given point */
- def dotplot(points: Seq[(Int, Int)]) {
- for ( (x, y) <- points ) point(x, y)
+ def dotplot(points: Seq[(Float, Float)]) {
+ for ( (x, y) <- points ) point(x, height/2 - y)
}
/** Plots a line between each given point */
- def lineplot(points: Seq[(Int, Int)]) {
+ def lineplot(points: Seq[(Float, Float)]) {
noFill()
beginShape()
- for ( (x, y) <- points ) vertex(x, y)
+ for ( (x, y) <- points ) vertex(x, height/2 - y)
endShape()
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.