You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ColorLayer is constructed as super(0, 0, Infinity, Infinity) with the default 0.5 anchor. By the time ColorLayer.draw() runs, Renderable.preDraw has already translated by (-anchorX·width, -anchorY·height) = (-Infinity, -Infinity), leaving currentTransform.tx/ty non-finite.
Effects:
Any user-set colorLayer.pos.set(...) is masked by the -Infinity translate.
Nesting a ColorLayer inside a transformed Container (translate/scale/rotate) has no effect — the parent transform composes with -Infinity and stays non-finite.
So ColorLayer is effectively a "fill the entire framebuffer with this color" command, not a positionable layer. The class API (pos, parent containers, etc.) suggests otherwise.
This came up while reviewing PR #1435 — a custom PartialColorLayer extends ColorLayer (used in the new clipping example) needed an explicit renderer.resetTransform() to make a sub-rect clipRect work, because the inherited -Infinity translate would otherwise turn the partial-band clip into a no-op.
Proposed fix
Honor pos/size. Drop super(0, 0, Infinity, Infinity) + 0.5 anchor in the constructor. New signature:
ColorLayer(name,color,z?,x?,y?,w?,h?)
Defaults to viewport-sized (so the most common "full-canvas backdrop" case stays a one-liner).
Anchor stays at (0, 0) so pos means top-left.
draw() issues clipRect(0, 0, this.width, this.height) under the layer's own (finite) transform — sub-rect bands, transformed parents, and pos changes all just work.
The clipping example's PartialColorLayer workaround can then be deleted.
Out of scope for #1435 (which is the clipRect fix). Happy to take this in a follow-up PR.
Problem
ColorLayeris constructed assuper(0, 0, Infinity, Infinity)with the default 0.5 anchor. By the timeColorLayer.draw()runs,Renderable.preDrawhas already translated by(-anchorX·width, -anchorY·height) = (-Infinity, -Infinity), leavingcurrentTransform.tx/tynon-finite.Effects:
colorLayer.pos.set(...)is masked by the-Infinitytranslate.ColorLayerinside a transformedContainer(translate/scale/rotate) has no effect — the parent transform composes with-Infinityand stays non-finite.ColorLayer.draw()callsrenderer.clipRect(0, 0, viewport.w, viewport.h). On WebGL this only "works" because of the non-finite-transform guard added in fix(clipping): correct Container.clipping under nested transforms (closes #1349) #1435 — it falls through to "no scissor", thenclearColorpaints the full framebuffer.So
ColorLayeris effectively a "fill the entire framebuffer with this color" command, not a positionable layer. The class API (pos, parent containers, etc.) suggests otherwise.This came up while reviewing PR #1435 — a custom
PartialColorLayer extends ColorLayer(used in the new clipping example) needed an explicitrenderer.resetTransform()to make a sub-rectclipRectwork, because the inherited-Infinitytranslate would otherwise turn the partial-band clip into a no-op.Proposed fix
Honor pos/size. Drop
super(0, 0, Infinity, Infinity)+ 0.5 anchor in the constructor. New signature:(0, 0)soposmeans top-left.draw()issuesclipRect(0, 0, this.width, this.height)under the layer's own (finite) transform — sub-rect bands, transformed parents, and pos changes all just work.PartialColorLayerworkaround can then be deleted.Out of scope for #1435 (which is the clipRect fix). Happy to take this in a follow-up PR.