Skip to content

Instantly share code, notes, and snippets.

@am4dr
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save am4dr/af8e57d6a460958efe5d to your computer and use it in GitHub Desktop.

Select an option

Save am4dr/af8e57d6a460958efe5d to your computer and use it in GitHub Desktop.
GroovyConsole上でProceccing
@Grab(group='org.processing', module='core', version='2.2.1')
import processing.core.*
class MySketch extends PApplet {
final float r = 200
final int FPS = 60
final float sec = 1
final float radpf = 2*PI / sec / FPS
void setup() {
frameRate(FPS)
background(30)
strokeWeight(2)
fill(255, 30)
}
void draw() {
float rad = frameCount * radpf
int size = 200 * noise(frameCount*0.1)
ellipse(width/2+r*sin(rad) as float, height/2+r*cos(rad) as float, size, size)
}
}
import javax.swing.JFrame
def launch(PApplet app, String title, int width, int height) {
app.init()
new JFrame(title).with {
size = [width, height]
add(app)
visible = true
defaultCloseOperation = DISPOSE_ON_CLOSE
}
}
// 内部のexit()によりGroovyConsoleも落ちる
//PApplet.main('MySketch')
//PApplet.main(['--present', 'MySketch'] as String[])
launch(new MySketch(), 'MySketch', 600, 600)
// GroovyのScriptとして実行する場合
@Grab(group='org.processing', module='core', version='2.2.1')
import processing.core.*
class MySketch extends PApplet {
final float r = 200
final int FPS = 60
final float sec = 1
final float radpf = 2*PI / sec / FPS
void setup() {
size(600, 600)
frameRate(FPS)
background(30)
strokeWeight(2)
fill(255, 30)
}
void draw() {
float rad = frameCount * radpf
int size = 200 * noise(frameCount*0.1)
ellipse(width/2+r*sin(rad) as float, height/2+r*cos(rad) as float, size, size)
}
}
PApplet.main('MySketch')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment