Repository: pixijs/pixijs
File: src/scene/graphics/shared/path/GraphicsPath.ts (TypeScript)

Code before:
        let y: number;
        let transform: Matrix;

        switch (lastInstruction.action)
        {
            case 'moveTo':
            case 'lineTo':
                out.x = lastInstruction.data[0];
                out.y = lastInstruction.data[1];
                break;
            case 'quadraticCurveTo':
                out.x = lastInstruction.data[2];
                out.y = lastInstruction.data[3];
                break;
            case 'bezierCurveTo':
                out.x = lastInstruction.data[4];
                out.y = lastInstruction.data[5];
                break;
            case 'arc':
            case 'arcToSvg':
                out.x = lastInstruction.data[5];
                out.y = lastInstruction.data[6];
                break;
            case 'addPath':
                // TODO prolly should transform the last point of the path
                lastInstruction.data[0].lastPoint.copyTo(out);
                break;
            case 'rect':
                // TODO transform...

                transform = lastInstruction.data[4];
                x = lastInstruction.data[0];
                y = lastInstruction.data[1];

                if (transform)
                {
                    const { a, b, c, d, tx, ty } = transform;

                    out.x = (a * x) + (c * y) + tx;
                    out.y = (b * x) + (d * y) + ty;
                }
                else
                {
                    out.x = x;
                    out.y = y;
                }

                break;
            default:
                // #if _DEBUG
                warn(`${lastInstruction.action} is not supported yet`);

Review comment (bug):
I believe this is a bug. I discovered it when running the new visual tests after my changes. Looking at the svg visual test which failed, the `GraphicsContext:path` method calls `addPath` of the `_activePath`, passing the path plus a matrix, so the old code referencing `lastInstruction.data[2].lastY` was wrong, it may have just been a completely wrong index to access for the `lastY` as in this case there were only 2 items, the graphics path (which we now look into to get its last point) and a matrix.

Code after:
            case 'moveTo':
            case 'lineTo':
                out.x = lastInstruction.data[0];
                out.y = lastInstruction.data[1];
                break;
            case 'quadraticCurveTo':
                out.x = lastInstruction.data[2];
                out.y = lastInstruction.data[3];
                break;
            case 'bezierCurveTo':
                out.x = lastInstruction.data[4];
                out.y = lastInstruction.data[5];
                break;
            case 'arc':
            case 'arcToSvg':
                out.x = lastInstruction.data[5];
                out.y = lastInstruction.data[6];
                break;
            case 'addPath':
                // TODO prolly should transform the last point of the path
                lastInstruction.data[0].getLastPoint(out);
                break;
            case 'rect':
                // TODO transform...

                transform = lastInstruction.data[4];
                x = lastInstruction.data[0];
                y = lastInstruction.data[1];

                if (transform)
                {
                    const { a, b, c, d, tx, ty } = transform;

                    out.x = (a * x) + (c * y) + tx;
                    out.y = (b * x) + (d * y) + ty;
                }
                else
                {
                    out.x = x;
                    out.y = y;
                }

                break;
            default:
                // #if _DEBUG
                warn(`${lastInstruction.action} is not supported yet`);
                // #endif
                break;
        }

        return out;