Skip to content

Instantly share code, notes, and snippets.

@hrj
Created September 9, 2011 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrj/1206559 to your computer and use it in GitHub Desktop.
Save hrj/1206559 to your computer and use it in GitHub Desktop.
Sample SurfacePlotter program
// Quick demo of SurfacePlotter [ http://code.google.com/p/surfaceplotter ]
import scala.swing._
import net.ericaro.surfaceplotter.{ProgressiveSurfaceModel, JSurfacePanel, Mapper}
val model = new ProgressiveSurfaceModel
val surfacePanel = new JSurfacePanel
surfacePanel.setModel(model)
model.setMapper(new Mapper {
def f1(x:Float, y:Float) = {
val r = x*x + y*y
if (r == 0 ) 1f else (Math.sin(r)/r).toFloat
}
def f2(x:Float, y:Float) = {
(Math.sin(x*y)).toFloat
}
})
model.plot.execute
new MainFrame {
contents = new Component {
override lazy val peer = surfacePanel
}
visible = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment