//package com.mycompany.app.mygroovymodule import processing.core.*; //--------------------------------------------------------- //--------------------------------------------------------- /** Draw (with the mouse) disappearing dots. This sketch uses the Groovy List and uses an external second class SpriteEllipse. */ class sketch_071119d_groovy extends PApplet { // global variables Integer nCount = -1 List listSprite = [] Integer colorBackground = 255 //--------------------------------------------------------- /* This is called once at start of application */ void setup() { size(400, 400) frameRate(10) smooth() colorBackground = ColorUtil.getRandomColor2(this) } //--------------------------------------------------------- /* This is called every time slice. */ void draw() { background(colorBackground) nCount++ nCount %= 256 if (nCount == 45) { // change background color colorBackground = ColorUtil.getRandomColor2(this) } if ((nCount%3) == 0) { //Float r = random(50, 100) Float r = random((Integer) (height*0.0625), (Integer) (height*0.25)) // 20, 90 //Integer color = (nCount*10)%256 Integer color = ColorUtil.getRandomColor2(this) SpriteEllipse sprite = new SpriteEllipse(mouseX, mouseY, r, color, this) listSprite << sprite } for (e in listSprite) { e.update() } // remove dead sprites List listSprite2 = listSprite.findAll { it.isDead() } //println "listSprite2: ${listSprite2}" //println "listSprite: ${listSprite}" listSprite = listSprite.minus(listSprite2) for (e in listSprite) { e.render() } } //--------------------------------------------------------- /* */ static void main(args) { println "in main" PApplet.main([ "sketch_071119d_groovy" ] as String[]); println "DONE" } }