Skip to content

point() should default to 1px and respect strokeWeight(1) in WEBGL mode; update point() examples for visible points #8266

@perminder-17

Description

@perminder-17

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

1.x and 2.x

Web browser and version

Firefox

Operating system

linux

Steps to reproduce this

In webgl: strokeWeight(1) ignored for point(), always uses larger default size

Steps:

// WEBGL
function setup() {
  createCanvas(100, 100, WEBGL);
  background(200);

  stroke(0);
  strokeWeight(1);
  point(0, 0);
}

Compare that with:

function setup() {
  createCanvas(100, 100, WEBGL);
  background(200);

  stroke(0);
  strokeWeight(2);
  point(0, 0);
}

Docs say a point’s default width is 1 pixel, and strokeWeight() sets the width in pixels for points. So in WEBGL, strokeWeight(1) should give a 1px point, and increasing to 2 should visibly double it.

Actual behavior:

With strokeWeight(1) or without strokeWeight() called, the point appears ~5-6px wide.
So strokeWeight(1) appears to be ignored and WebGL falls back to a larger default size, also without calling strokeWeight(), it still not defaults to 1px.

The idea is that point() should work the same way as described in the docs. If the default is 1px (and that works correctly in P2D), then WEBGL mode should also use 1px by default.

Also, currently in the docs, when we see the examples, it uses the default 1px points. We can add strokeWeight() to make it more visible.

Image

So, the goal is to update the docs for adding strokeWeight() in the example, and also make the point() being consistent in both WEBGL and 2D mode.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions