{% else-1 %}
Позволяет рисовать такие штуки:
http://i.imgur.com/UHl9nyB.gif
http://i.imgur.com/q3mysMs.png
Язык программирования Scala

                        
import scala.swing.Swing._
import scala.swing._
import scala.swing.event._
import java.awt.{Color, Graphics2D, geom}

object PaintApp {
def main(args: Array[String]) = PaintAppSwing.main(args)

object PaintAppSwing extends SimpleSwingApplication with Runnable {
val SIZE = 500

val path = new geom.GeneralPath
val at = new geom.AffineTransform
at.rotate(Math.toRadians(10), SIZE / 2d, SIZE / 2d)
var rotate = true
var sleep = 40

lazy val ui = new Panel {
background = Color.WHITE
preferredSize = (SIZE, SIZE)

focusable = true
listenTo(mouse.clicks, mouse.moves, mouse.wheel, keys)
reactions += {
case e: MousePressed => path.moveTo(e.point.x, e.point.y)
case e: MouseDragged => path.lineTo(e.point.x, e.point.y)
case e: MouseWheelMoved =>
sleep += e.rotation
if (sleep < 1) sleep = 1
else if (sleep > 300) sleep = 300
case KeyTyped(_,'r',_,_) => rotate = !rotate
case KeyTyped(_,'c',_,_) => path.reset
}

override def paintComponent(g: Graphics2D) = {
super.paintComponent(g)
g.drawString(s"Wheel - Change speed [$sleep], C - Clear, R - Rotate [$rotate]", 10, size.height-10)
g.setColor(Color.BLACK)
g.draw(path)
}
}

def top = new MainFrame {
title = "Rotate Paint"
contents = ui
}

def run() {
while (true) {
if (rotate) path.transform(at)
ui.repaint
Thread.sleep(sleep)
}
}
new Thread(this).start
}
}
0 32 0
Без комментариев...