◐ Shell
clean mode source ↗

`stroke()` does not handle float values correctly

stroke() appears to mis-handle float inputs. When using floats (e.g. 150.0), the rendered color is incorrect

Expected behavior

Float values in the same range as integers should produce identical results, as in Processing.

Actual behavior

  • stroke(150) → correct grayscale
  • stroke(150.0) → renders as white

Reproduction (mewnala)

from mewnala import *

def setup():
    size(640, 360)
    background(255)

def draw():
    stroke(150.0)
    line(0, 0, width, height)
    line(width, 0, 0, height)

    stroke(155.0, 100.0, 0.0)
    line(0, height // 2, width, height // 2)
    line(width // 2, 0, width // 2, height)

run()

Image

Equivalent Processing sketch (works as expected)

void setup() {
  size(640, 360);
  background(255);
}

void draw() {
  stroke(150.0);
  line(0, 0, width, height);
  line(width, 0, 0, height);

  stroke(155.0, 100.0, 0.0);
  line(0, height/2, width, height/2);
  line(width/2, 0, width/2, height);
}

Image