processing/p5.js

noSmooth() breaks positioned WEBGL canvas

Open

#7,548 建立於 2025年2月15日

在 GitHub 查看
 (9 留言) (0 反應) (0 負責人)JavaScript (3,178 fork)batch import
Area:CoreArea:WebGLBugGood First IssueHelp Wanted

倉庫指標

Star
 (20,784 star)
PR 合併指標
 (平均合併 8天 13小時) (30 天內合併 45 個 PR)

描述

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)

p5.js version

1.11.3

Web browser and version

Chrome 133.0.6943.54

Operating system

MacOS

Steps to reproduce this

Steps:

  1. createCanvas(), position it, add noSmooth() in the draw()
  2. 2D renderer, no problem
  3. WEBGL, breaks, creates new empty canvas?

Perhaps one isn't supposed to use noSmooth() in the draw? I don't remember hitting this issue, but maybe never tried it before... Is that how it's supposed to behave? The refs only show examples of it in the setup(), but it doesn't state anywhere that's the only spot for it to go. In 2D renderer, it doesn't cause an issue, so is it normal in WEBGL or a bug?

Snippet:


function setup() {
	let cvn = createCanvas(300, 300)
	cvn = createCanvas(300, 300, WEBGL) // breaks with noSmooth() below
	cvn.position(150, 50)
	
	background(0, 0, 255)
	circle(0, 0, 100)
}

function draw(){
	noSmooth() // breaks sketch in WEBGL mode
}

貢獻者指南