Skip to content

Add shader examples to noise random and millis functions#8803

Open
SOUMITRO-SAHA wants to merge 3 commits into
processing:dev-2.0from
SOUMITRO-SAHA:docs-8777-strands-noise-random-time
Open

Add shader examples to noise random and millis functions#8803
SOUMITRO-SAHA wants to merge 3 commits into
processing:dev-2.0from
SOUMITRO-SAHA:docs-8777-strands-noise-random-time

Conversation

@SOUMITRO-SAHA
Copy link
Copy Markdown

Resolves #8777 (Noise, Random, Time batch)

Changes:
Adds inline p5.strands examples to the reference documentation for 3 functions across 3 files:

src/math/noise.js

  • noise() — cloud-like texture effect using buildFilterShader() with filterColor

src/math/random.js

  • random() — random RGB colors on a shape

src/utilities/time_date.js

  • millis() — time-based color transitions

Each example includes a brief explanation that the function can be used in shaders with p5.strands. The noise() example demonstrates buildFilterShader() for 2D filter effects, while random() and millis() use buildColorShader().

Screenshots of the change:

PR Checklist

Add practical examples showing how noise random and millis can be used
with p5.strands shader system including complete working code examples
for cloud effects random colors and time-based transitions
Copy link
Copy Markdown
Contributor

@nbogie nbogie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

Comment thread src/math/noise.js Outdated
* let coord = filterColor.texCoord;
* let t = millis() / 2000;
* let value = noise(coord.x * 5, coord.y * 5, t);
* filterColor.set(mix([0.1, 0.1, 0.3, 1], [0.9, 0.9, 1, 1], value));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could better be split out fully:

let mixFraction = noise( /* ... omitted... */)
let color1 = [0.1, 0.1, 0.3, 1]; 
let color2 = //etc
let mixedColor = mix(color1, color2, mixFraction)
filterColor.set(mixedColor)

Reasoning:

  • this might be read by someone coming to strands for the first time, who loves noise() and is excited to move on with it. The more we can do to reduce the chance of overwhelming them, the better.
  • shorter lines are also more readable on lower-res devices without wrap
  • separate lines allow easier experimentation and replacement in the editable sketch with less chance of the user getting in a mess

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if a second example showing the effects of noiseDetail would be suitable here, too (perhaps driven by the mouseX)? I guess that's for the noiseDetail() page itself but I worry about lesser discoverability of that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll add a second inline example on the noise() page showing noiseDetail() driven by mouseX. That way readers see both functions together without having to hunt for noiseDetail(). Pushing shortly!

Comment thread src/math/noise.js Outdated
* filterColor.begin();
* let coord = filterColor.texCoord;
* let t = millis() / 2000;
* let value = noise(coord.x * 5, coord.y * 5, t);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth commenting on what range of values noise will return here.

@p5-bot
Copy link
Copy Markdown

p5-bot Bot commented May 18, 2026

Continuous Release

CDN link

Published Packages

Commit hash: aaf35c5

Previous deployments

This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants