Skip to content

suggestion about createCanvas argument naming #6548

Closed
@micuat

Description

@micuat

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
  • Internalization
  • Friendly Errors
  • Other (specify if possible)

p5.js version

1.8.0

Web browser and version

No response

Operating System

No response

Steps to reproduce this

I'm a bit confused about the arguments of createCanvas.

In this part where detecting the case createCanvas(w, h, canvas):

if (arguments[2] instanceof HTMLCanvasElement) {
renderer = constants.P2D;
canvas = arguments[2];
} else {
r = renderer || constants.P2D;
}

I think instead of the variable renderer (which is not used afterwards), the constant should be assigned to r. Furthermore, to me it makes sense to rename the arguments to createCanvas(w, h, ...args) or so and unpack it later to avoid duplication of r, renderer and so on.

The change seemed to be introduced with this PR (nevertheless I really love this feature) #6229

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions