openfl icon indicating copy to clipboard operation
openfl copied to clipboard

Contents with applied ColorTransform/ColorMatrixFilter freeze when scrollRect changes

Open NipponSunrise opened this issue 5 years ago • 1 comments

Describe the bug If we apply CollorTransform or ColorMatrixFilter to some contents inside of the scrollable area, that contents coords stay unchanged when scrollRect of the parent changes.

Interesting to note: children of the sprite with filter/transform applied move accordingly with the changed scrollRect while their parent not.

To Reproduce

import openfl.events.MouseEvent;
import openfl.geom.Rectangle;
import openfl.geom.ColorTransform;
import openfl.Lib;
import openfl.display.Sprite;

class Main extends Sprite {
    public function new() {
        super();

        // draw scrollable window
        graphics.beginFill(0xFFFFFF); 
        graphics.drawRect(0,0,500,500);
        graphics.endFill();
        graphics.lineStyle(2, 0xff0000, 100); 
        graphics.drawRect(0,0,500,500);

        scrollRect = new Rectangle(0, 0, 500, 200);


        // draw BLUE square (our window's content)
        var content:Sprite = new Sprite();
        content.graphics.beginFill(0x0000FF); 
        content.graphics.drawRect(0,0,20,20);
        content.graphics.endFill();
        content.x = 200;
        content.y = 175;

        addChild(content);
              
        // change color of the square to RED
        var ct = new ColorTransform();
        ct.color = 0xFF0000;

        // comment this line to see that square moves up with other parent's contents as expected
        content.transform.colorTransform = ct;

        // change scrollRect (increase y coord) on click event
        Lib.current.stage.addEventListener(MouseEvent.CLICK, (e) -> {
            
            // uncomment next line to see that after assigning different color content moves as expected
            // content.transform.colorTransform.color = Std.int(Math.random() * 0xFFFFFF);

            // change scrollRect position as we scroll window's content for example.
            this.scrollRect = new Rectangle(this.scrollRect.x, this.scrollRect.y + 10, this.scrollRect.width, this.scrollRect.height);
        });
    }

    public static function main() {        
        Lib.current.stage.addChild(new Main());
    }
}

Expected behavior content moves accordingly

OpenFL Targets 9.0.2 html5-canvas

NipponSunrise avatar Jan 26 '21 17:01 NipponSunrise

Seem this ticket duplicates this one: if https://github.com/openfl/openfl/issues/2169

NipponSunrise avatar Jan 26 '21 19:01 NipponSunrise