Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use canvas dimensions instead of arbitrary constants for noise() and noiseDetail() doc iterators #7329

Closed
1 of 17 tasks
RandomGamingDev opened this issue Oct 22, 2024 · 0 comments · Fixed by #7330
Closed
1 of 17 tasks

Comments

@RandomGamingDev
Copy link
Contributor

Increasing access

This would increase the consistency of the code and make the purpose of the code easier to understand for those looking at the docs.

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

Feature enhancement details

For instance, this:

function setup() {
  createCanvas(100, 100);

  background(200);

  // Set the noise level and scale.
  let noiseLevel = 255;
  let noiseScale = 0.01;

  // Iterate from top to bottom.
  for (let y = 0; y < 100; y += 1) {
    // Iterate from left to right.
    for (let x = 0; x < 100; x += 1) {
      // Scale the input coordinates.
      let nx = noiseScale * x;
      let ny = noiseScale * y;

      // Compute the noise value.
      let c = noiseLevel * noise(nx, ny);

      // Draw the point.
      stroke(c);
      point(x, y);
    }
  }

  describe('A gray cloudy pattern.');
}

instead of having this:

  // Iterate from top to bottom.
  for (let y = 0; y < 100; y += 1) {
    // Iterate from left to right.
    for (let x = 0; x < 100; x += 1) {

would have this:

  // Iterate from top to bottom.
  for (let y = 0; y < height; y += 1) {
    // Iterate from left to right.
    for (let x = 0; x < width; x += 1) {
@RandomGamingDev RandomGamingDev changed the title Use canvas dimensions instead of arbitrary constants for noise() and noiseDetail() Use canvas dimensions instead of arbitrary constants for noise() and noiseDetail() doc iterators Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant