import { downloadUrlAsFile } from "../../../../core/binary/downloadUrlAsFile.js";
import { sampler2d_to_data_url } from "./sampler2d_to_data_url.js";

/**
 *
 * @param {Sampler2D} sampler
 * @param {string} [file_name] what should the file be named?
 */
export function downloadSampler2DAsPNG(
    sampler,
    file_name = 'image'
) {

    const dataURL = sampler2d_to_data_url(sampler);

    downloadUrlAsFile(dataURL, `${file_name}.png`);

    URL.revokeObjectURL(dataURL);

}
