Closed gwhitney closed 7 months ago
probably good to just grep the code for occurrences of {} as
and try to minimize the number that are in use, and clearly comment the rationale for each of those that need to remain unless it's obvious.
Turns out that the p5 documentation is misleading. You can't execute new p5.Color()
-- the sketch really is mandatory. So instead in #293 we put the {} as p5.Color
hack into just one place -- the base P5Visualizer.ts -- so that if p5.Color ever improves on this score we can fix it in just one place. Since there's no prospect of that on the horizon, closing this issue.
This is used in a few places, I think only in Visualizers, to get a variable to have the right type at initialization time when there is not a known sketch to get it from (since one usually asks a sketch to create a color for you). Anyhow, such an instance can just be replaced by
new p5.Color()
, which is much less hacky. The resulting color is not associated with any sketch (and I have no idea what color it actually is -- black? white? transparent?) so you shouldn't really draw with it, but it makes an OK placeholder and serves to get TypeScript to type the variable correctly.