/**
 * Composes row-major transform matrix, row-major format is used in OpenGL
 *
 * @param {number[]|Float32Array} result
 * @param {number} tX translation X offset
 * @param {number} tY translation Y offset
 * @param {number} sX scale in X axis
 * @param {number} sY scale in Y axis
 * @param {number} cx center of rotation X
 * @param {number} cy center of rotation Y
 * @param {number} angle rotation angle
 */
export function m3_rm_compose_transform(
    result,
    tX, tY,
    sX, sY,
    cx, cy,
    angle
) {
    const neg_angle = -angle;

    const sin = Math.sin(neg_angle);
    const cos = Math.cos(neg_angle);

    result[0] = sX * cos;
    result[3] = sX * sin;
    result[6] = -sX * (cos * cx + sin * cy) + cx + tX;

    result[1] = -sY * sin;
    result[4] = sY * cos;
    result[7] = -sY * (-sin * cx + cos * cy) + cy + tY;

    result[2] = 0;
    result[5] = 0;
    result[8] = 1;
}
