ミリ秒は1/1000秒です。Processingは、プログラムが実行されたミリ秒数を追跡します。この数値を剰余(%)演算子で変更することにより、時間の中でさまざまなパターンが作成されます。ProcessingウェブサイトのMillisecondsの例からの移植。
millis time pattern
Input Time
View Source Code
/*
* @name Milliseconds
* @arialabel Background broken down in bars of various shades of grey. The fill of some of the bars randomly changes every millisecond to other shades of grey.
* @description A millisecond is 1/1000 of a second. Processing keeps track of the number of milliseconds a
* program has run. By modifying this number with the modulo(%) operator, different patterns in time are created.
* <br><br><small><em>This example is ported from the <a href="https://processing.org/examples/milliseconds.html">Milliseconds example</a>
* on the Processing website</em></small>
*/
let scale;
function setup() {
// createCanvas(720, 400);
createCanvas(windowWidth, windowHeight);
noStroke();
scale = width/20;
}
function draw() {
let i;
for ( i = 0; i < scale; i++) {
colorMode(RGB, (i+1) * scale * 10);
fill(millis()%((i+1) * scale * 10));
rect(i*scale, 0, scale, height);
}
}License
Source code is available on GitHub p5.js website legacy.
All examples are licensed under CC BY-NC-SA 4.0.