<commit_before>/**
 * 
 */
function RainbowScratchPaper() {
    this.MenuAgent = new MenuAgent();
    this.ScratchOffAgent = new ScratchOffAgent();
    this.BackgroundAgent = new BackgroundAgent();
    
    this.setButtonCallbacks();
    this.setMenuScratchHiding();
}

/**
 * 
 */
RainbowScratchPaper.prototype.setButtonCallbacks = function () {
    this.MenuAgent.setButtonStatusCallbacks({
        "brush-1": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 1),
        "brush-2": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 3),
        "brush-3": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 7),
        "brush-4": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 14),
        "erasor": this.ScratchOffAgent.toggleErasor.bind(this.ScratchOffAgent)
    });
    
    this.MenuAgent.setButtonActionCallbacks({
        "front-refresh": this.ScratchOffAgent.resetBlackCover.bind(this.ScratchOffAgent)
    });
    
    this.MenuAgent.buttons[1].click();
};

/**
 * 
 */
RainbowScratchPaper.prototype.setMenuScratchHiding = function () {
    this.ScratchOffAgent.onMouseDown = this.MenuAgent.hide.bind(this.MenuAgent);
    this.ScratchOffAgent.onMouseUp = this.MenuAgent.show.bind(this.MenuAgent);
};

/**
 * 
 */
RainbowScratchPaper.prototype.uploadImage = function (callback) {
    
};<commit_msg>Implemented save (screenshot)<commit_after>/**
 * 
 */
function RainbowScratchPaper() {
    this.MenuAgent = new MenuAgent();
    this.ScratchOffAgent = new ScratchOffAgent();
    this.BackgroundAgent = new BackgroundAgent();
    
    this.setButtonCallbacks();
    this.setMenuScratchHiding();
}

/**
 * 
 */
RainbowScratchPaper.prototype.setButtonCallbacks = function () {
    this.MenuAgent.setButtonStatusCallbacks({
        "brush-1": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 1),
        "brush-2": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 3),
        "brush-3": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 7),
        "brush-4": this.ScratchOffAgent.setBrushSize.bind(this.ScratchOffAgent, 14),
        "erasor": this.ScratchOffAgent.toggleErasor.bind(this.ScratchOffAgent)
    });
    
    this.MenuAgent.setButtonActionCallbacks({
        "front-refresh": this.ScratchOffAgent.resetBlackCover.bind(this.ScratchOffAgent),
        "save": this.saveScreenshot.bind(this)
    });
    
    this.MenuAgent.buttons[1].click();
};

/**
 * 
 */
RainbowScratchPaper.prototype.setMenuScratchHiding = function () {
    this.ScratchOffAgent.onMouseDown = this.MenuAgent.hide.bind(this.MenuAgent);
    this.ScratchOffAgent.onMouseUp = this.MenuAgent.show.bind(this.MenuAgent);
};

/**
 * 
 */
RainbowScratchPaper.prototype.saveScreenshot = function () {
    var canvas = document.createElement("canvas"),
        context = canvas.getContext("2d"),
        format = "image/png",
        link = document.createElement("a");
    
    canvas.width = this.ScratchOffAgent.canvas.width;
    canvas.height = this.ScratchOffAgent.canvas.height;
    
    context.drawImage(this.ScratchOffAgent.canvas, 0, 0);
    // context.drawImage(this.BackgroundAgent.canvas, 0, 0);
    
    link.download = "RainbowScratchPaper Screenshot.png";
    link.href = canvas.toDataURL(format).replace(format, "image/octet-stream");
    link.click();
};

/**
 * 
 */
RainbowScratchPaper.prototype.uploadImage = function (callback) {
    
};
{'fraction_non_alphanumeric': 0.13997071742313325, 'fraction_numerical': 0.007320644216691069, 'mean_word_length': 3.8112676056338026, 'pattern_counts': {'":': 13, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5906073', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1142, 'n_words': 120}