Skip to content

stroke() does not handle float values correctly #132

@SableRaf

Description

@SableRaf

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions