Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> the only way to make a computer image perfectly deterministically is to set RGB to each single pixel manually.

You don’t need to do it manually. A quick and dirty example is to have each pixel’s colour depend on its position on the canvas. Instant gradient, perfectly deterministic, yet you can still be surprised by the colours.

P5.js example (run interactively at https://editor.p5js.org):

  function setup() {
    createCanvas(256, 256);
    noLoop()
    noStroke()
  }
  
  function draw() {
    for (i = 0; i < 256; i++) {
      for (j = 0; j < 256; j++) {
        fill(i, j, i)
        rect(i, j, 1, 1)
      }
    }
  }
Play with the fill. Make it, e.g. `fill(i, j, 180)` or `fill(i, j, sin(j) * 200)`. Perfectly deterministic and automatic, yet the result can still be unexpected.


Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: