ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://processing.org/examples/brownian.html |
| Last Crawled | 2026-04-06 05:42:48 (7 hours ago) |
| First Indexed | 2014-10-24 15:42:31 (11 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Brownian motion / Examples / Processing.org |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | Recording random movement as a continuous line.
/**
* Brownian motion.
*
* Recording random movement as a continuous line.
*/
int num = 2000;
int range = 6;
float[] ax = new float[num];
float[] ay = new float[num];
void setup()
{
size(640, 360);
for(int i = 0; i < num; i++) {
ax[i] = width/2;
ay[i] = height/2;
}
frameRate(30);
}
void draw()
{
background(51);
// Shift all elements 1 place to the left
for(int i = 1; i < num; i++) {
ax[i-1] = ax[i];
ay[i-1] = ay[i];
}
// Put a new value at the end of the array
ax[num-1] += random(-range, range);
ay[num-1] += random(-range, range);
// Constrain all points to the screen
ax[num-1] = constrain(ax[num-1], 0, width);
ay[num-1] = constrain(ay[num-1], 0, height);
// Draw a line connecting the points
for(int i=1; i<num; i++) {
float val = float(i)/num * 204.0 + 51;
stroke(val);
line(ax[i-1], ay[i-1], ax[i], ay[i]);
}
}
This example is for Processing 4+. If you have a previous version, use the examples included with your software. If you see any errors or have suggestions, please
let us know
. |
| Markdown | - [Processing Foundation](https://processingfoundation.org/)
- [Processing](https://processing.org/)
- [p5.js](https://p5js.org/)
- [Processing Android](https://android.processing.org/)
- [Processing Python](https://py.processing.org/)
# [Processing](https://processing.org/)
- [Home](https://processing.org/)
- [Download](https://processing.org/download)
- Documentation
- [Reference](https://processing.org/reference)
- [Environment](https://processing.org/environment)
- [Libraries](https://processing.org/reference/libraries)
- [Tools](https://processing.org/reference/tools)
- [Wiki](https://wiki.processing.org/)
- Learn
- [Tutorials](https://processing.org/tutorials)
- [Examples](https://processing.org/examples)
- [Books](https://processing.org/books)
- [Forum](https://discourse.processing.org/)
- About
- [Overview](https://processing.org/overview)
- [People](https://processing.org/people)
- [Privacy](https://processing.org/privacy)
- [Donate](https://processing.org/donate)
Examples\+
Learn→[Examples](https://processing.org/examples)→[Topics](https://processing.org/examples#topics)→[Motion](https://processing.org/examples#topics-motion)
# Brownian motion
Recording random movement as a continuous line.
### Highlighted Features
- [Array](https://processing.org/reference/array)
- [random()](https://processing.org/reference/random_)
- [constrain()](https://processing.org/reference/constrain_)
- [stroke()](https://processing.org/reference/stroke_)
- [line()](https://processing.org/reference/line_)
- Brownian
Copy
[Open In Processing](processing://open?sketch=LyoqCiAqIEJyb3duaWFuIG1vdGlvbi4gCiAqIAogKiBSZWNvcmRpbmcgcmFuZG9tIG1vdmVtZW50IGFzIGEgY29udGludW91cyBsaW5lLiAKICovCiAKaW50IG51bSA9IDIwMDA7CmludCByYW5nZSA9IDY7CgpmbG9hdFtdIGF4ID0gbmV3IGZsb2F0W251bV07CmZsb2F0W10gYXkgPSBuZXcgZmxvYXRbbnVtXTsgCgoKdm9pZCBzZXR1cCgpIAp7CiAgc2l6ZSg2NDAsIDM2MCk7CiAgZm9yKGludCBpID0gMDsgaSA8IG51bTsgaSsrKSB7CiAgICBheFtpXSA9IHdpZHRoLzI7CiAgICBheVtpXSA9IGhlaWdodC8yOwogIH0KICBmcmFtZVJhdGUoMzApOwp9Cgp2b2lkIGRyYXcoKSAKewogIGJhY2tncm91bmQoNTEpOwogIAogIC8vIFNoaWZ0IGFsbCBlbGVtZW50cyAxIHBsYWNlIHRvIHRoZSBsZWZ0CiAgZm9yKGludCBpID0gMTsgaSA8IG51bTsgaSsrKSB7CiAgICBheFtpLTFdID0gYXhbaV07CiAgICBheVtpLTFdID0gYXlbaV07CiAgfQoKICAvLyBQdXQgYSBuZXcgdmFsdWUgYXQgdGhlIGVuZCBvZiB0aGUgYXJyYXkKICBheFtudW0tMV0gKz0gcmFuZG9tKC1yYW5nZSwgcmFuZ2UpOwogIGF5W251bS0xXSArPSByYW5kb20oLXJhbmdlLCByYW5nZSk7CgogIC8vIENvbnN0cmFpbiBhbGwgcG9pbnRzIHRvIHRoZSBzY3JlZW4KICBheFtudW0tMV0gPSBjb25zdHJhaW4oYXhbbnVtLTFdLCAwLCB3aWR0aCk7CiAgYXlbbnVtLTFdID0gY29uc3RyYWluKGF5W251bS0xXSwgMCwgaGVpZ2h0KTsKICAKICAvLyBEcmF3IGEgbGluZSBjb25uZWN0aW5nIHRoZSBwb2ludHMKICBmb3IoaW50IGk9MTsgaTxudW07IGkrKykgeyAgICAKICAgIGZsb2F0IHZhbCA9IGZsb2F0KGkpL251bSAqIDIwNC4wICsgNTE7CiAgICBzdHJva2UodmFsKTsKICAgIGxpbmUoYXhbaS0xXSwgYXlbaS0xXSwgYXhbaV0sIGF5W2ldKTsKICB9Cn0K)
```
/**
* Brownian motion.
*
* Recording random movement as a continuous line.
*/
int num = 2000;
int range = 6;
float[] ax = new float[num];
float[] ay = new float[num];
void setup()
{
size(640, 360);
for(int i = 0; i < num; i++) {
ax[i] = width/2;
ay[i] = height/2;
}
frameRate(30);
}
void draw()
{
background(51);
// Shift all elements 1 place to the left
for(int i = 1; i < num; i++) {
ax[i-1] = ax[i];
ay[i-1] = ay[i];
}
// Put a new value at the end of the array
ax[num-1] += random(-range, range);
ay[num-1] += random(-range, range);
// Constrain all points to the screen
ax[num-1] = constrain(ax[num-1], 0, width);
ay[num-1] = constrain(ay[num-1], 0, height);
// Draw a line connecting the points
for(int i=1; i<num; i++) {
float val = float(i)/num * 204.0 + 51;
stroke(val);
line(ax[i-1], ay[i-1], ax[i], ay[i]);
}
}
```
### Related Examples
- [ ![Bounce]() Bounce](https://processing.org/examples/bounce)
- [ ![Bouncy Bubbles]() Bouncy Bubbles](https://processing.org/examples/bouncybubbles)
- [ ![Circle Collision]() Circle Collision](https://processing.org/examples/circlecollision)
- [ ![Linear]() Linear](https://processing.org/examples/linear)
- [ ![Morph]() Morph](https://processing.org/examples/morph)
- [ ![Moving On Curves]() Moving On Curves](https://processing.org/examples/movingoncurves)
This example is for Processing 4+. If you have a previous version, use the examples included with your software. If you see any errors or have suggestions, please [let us know](https://github.com/processing/processing-examples/issues).
### Contact Us
Feel free to write us\!
[hello@processing.org](mailto:hello@processing.org)
- [GitHub](http://github.com/processing/)
- [Discord](https://discord.gg/mt2CnebPsJ)
- [Bluesky](https://bsky.app/profile/processing.org)
- [Mastodon](https://mastodon.social/@processing/)
- [Instagram](https://www.instagram.com/processing_core/)
- [Facebook](https://www.facebook.com/people/Processing-Core/61567491443061/)
- [Medium](https://medium.com/@ProcessingOrg)
Processing is an open project initiated by [Ben Fry](https://benfry.com/) and [Casey Reas](http://reas.com/). It is developed by a team of contributors around the world. |
| Readable Markdown | Recording random movement as a continuous line.
```
/**
* Brownian motion.
*
* Recording random movement as a continuous line.
*/
int num = 2000;
int range = 6;
float[] ax = new float[num];
float[] ay = new float[num];
void setup()
{
size(640, 360);
for(int i = 0; i < num; i++) {
ax[i] = width/2;
ay[i] = height/2;
}
frameRate(30);
}
void draw()
{
background(51);
// Shift all elements 1 place to the left
for(int i = 1; i < num; i++) {
ax[i-1] = ax[i];
ay[i-1] = ay[i];
}
// Put a new value at the end of the array
ax[num-1] += random(-range, range);
ay[num-1] += random(-range, range);
// Constrain all points to the screen
ax[num-1] = constrain(ax[num-1], 0, width);
ay[num-1] = constrain(ay[num-1], 0, height);
// Draw a line connecting the points
for(int i=1; i<num; i++) {
float val = float(i)/num * 204.0 + 51;
stroke(val);
line(ax[i-1], ay[i-1], ax[i], ay[i]);
}
}
```
This example is for Processing 4+. If you have a previous version, use the examples included with your software. If you see any errors or have suggestions, please [let us know](https://github.com/processing/processing-examples/issues). |
| Shard | 70 (laksa) |
| Root Hash | 3485889765796472470 |
| Unparsed URL | org,processing!/examples/brownian.html s443 |