Skip to content

[2.0] Proposal: A consistent mechanism for reading renderer properties (2d) #8278

@dhowe

Description

@dhowe

As discussed with @limzykenneth, there is not currently a consistent usage pattern for reading renderer state properties. In some cases (e.g. textWeight()) calling the function with no argument returns the current setting, while in other cases (rectMode(), for example) it results in an error message.

There are many use-cases for this information (for example, writing a function which needs to adjust to the various rect-modes) and in v1.x, people have used non-API access like _renderer._rectMode. In 2.x, this info is available in _renderer.states, also not part of the API, and also not available in global mode (for example, in the editor, where one would have to do p5.instance._renderer.states.rectMode.

The proposal here is to standardise the API so that calling no-argument versions of the state-setting functions return the current values. This will require evaluating whether there are existing uses of any of the existing no-argument versions of these methods (for example, randomSeed()) as well as checking for any other problematic cases

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Completed

Relationships

None yet

Development

No branches or pull requests

Issue actions