“hamon : Ripples of rain” by lis
https://openprocessing.org/sketch/1447292
License CreativeCommons Attribution NonCommercial ShareAlike
https://creativecommons.org/licenses/by-nc-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
Click to drop raindrops. Randomly drop raindrops with the Enter key.
CC Attribution NonCommercial ShareAlike
hamon : Ripples of rain
xxxxxxxxxx
let debug = false;
let auto_drawing = true;
const circles = [];
const draw_timing = 100;
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
frameRate(60);
}
function draw() {
background(0);
stroke('#fff');
noFill();
strokeWeight(1);
random_add_circle();
const del_idx = [];
for ( let i = 0; i < circles.length; i++ ) {
const circle = circles[i];
if ( circle.is_finished ) {
del_idx.unshift(i); // 逆順で追加
}
else {
circle.draw();
}
}
del_idx.forEach(idx => {
circles.splice(idx, 1); // 完了オブジェクトの削除
});
debug_disp();
}
function add_circle(x, y, size) {
circles.push(new Circle(x, y, size));
}
function random_add_circle() {
if ( !auto_drawing ) { return; }
if ( frameCount % draw_timing != 0 ) { return; }
const x = random(0, width);
const y = random(0, height);
add_circle(x, y, 20);
}
function mouseClicked() {
add_circle(mouseX, mouseY, 20);
}
function keyPressed() {
if ( keyCode === ENTER ) {
auto_drawing = !auto_drawing;
}
else if ( key === 'd' ) {
debug = !debug;
}
return false;
}
class Circle {
constructor(x, y, size) {
this.x = x;
this.y = y;
this.size = size;
this.count = 0;
this.max_count = 50 + random(0, 400);
this.weight = random(10, 30) * 0.1;
this.is_finished = false;
}
draw() {
if ( this.is_expired() ) {
this.is_finished = true;
return;
}
if ( frameCount % 1 == 0 ) {
this.size += 1;
this.count++;
}
const alpha = 100 - (this.count / this.max_count * 100)
stroke(255, 255, 255, alpha);
strokeWeight(this.weight);
ellipse(this.x, this.y, this.size);
}
is_expired() {
if ( this.count > this.max_count ) {
return true;
}
return false;
}
}
function debug_disp() {
if ( !debug ) { return; }
let msg = '';
msg += `frame: ${frameCount}\n`;
msg += `noise: ${noise(random(0, 1))}\n`;
msg += `c num: ${circles.length}\n`
for (let i = 0; i < circles.length; i++) {
const c = circles[i];
msg += `c[${i}]: (${c.x}, ${c.y}, ${c.size}) count=${c.count}, max=${c.max_count}\n`;
}
textSize(9);
stroke('#fff');
strokeWeight(1);
text(msg, 5, 15);
}
See More Shortcuts