<commit_before>define([
    '../utility/retina.js',
], (isRetina) => {
    var Renderer = function($canvas, canvasContext) {
        var myself = self;
        var resolution = isRetina ? 2 : 1;
        var backgroundRatio = {
            width: 1,
            height: 1,
        };
        var offset = {
            x: 0,
            y: 0,
        }
        var backgroundDimensions = {
            cornerX: undefined,
            cornerY: undefined,
            width: undefined,
            height: undefined,
        };

        this.getBackgroundRatio = () => {
            return backgroundRatio;
        }

        this.setBackgroundRatio = (width, height) => {
            backgroundRatio.width = width;
            backgroundRatio.height = height;
        }

        this.setBackgroundDimensions = (cornerX, cornerY, width, height) => {
            backgroundDimensions = {
                cornerX: cornerX,
                cornerY: cornerY,
                width: width,
                height: height,
            };
        }

        this.getBackgroundDimensions = () => {
            return backgroundDimensions;
        }

        this.get$Canvas = () => {
            return $canvas;
        }

        this.getCanvas = () => {
            return canvas;
        }

        this.getContext = () => {
            return canvasContext;
        }

        this.convertCoordonateToBackground = (point, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return {
                x: point.x * backgroundRatio.width * r + offset.x,
                y: point.y * backgroundRatio.height * r + offset.y,
            };
        }

        this.convertBackgroundToCoordinate = (point, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return {
                x: (point.x - offset.x) / backgroundRatio.width / r,
                y: (point.y - offset.y) / backgroundRatio.height/ r,
            };
        }

        this.convertValueToBackground = (value, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return value * backgroundRatio.width* r;
        }

        this.convertBackgroundToValue = (value, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return value / backgroundRatio.width/ r;<commit_msg>Fix renderer coordinates conversion<commit_after>define([
    '../utility/retina.js',
], (isRetina) => {
    var Renderer = function($canvas, canvasContext) {
        var myself = self;
        var resolution = isRetina ? 2 : 1;
        var backgroundRatio = {
            width: 1,
            height: 1,
        };
        var offset = {
            x: 0,
            y: 0,
        }
        var backgroundDimensions = {
            cornerX: undefined,
            cornerY: undefined,
            width: undefined,
            height: undefined,
        };

        this.getBackgroundRatio = () => {
            return backgroundRatio;
        }

        this.setBackgroundRatio = (width, height) => {
            backgroundRatio.width = width;
            backgroundRatio.height = height;
        }

        this.setBackgroundDimensions = (cornerX, cornerY, width, height) => {
            backgroundDimensions = {
                cornerX: cornerX,
                cornerY: cornerY,
                width: width,
                height: height,
            };
        }

        this.getBackgroundDimensions = () => {
            return backgroundDimensions;
        }

        this.get$Canvas = () => {
            return $canvas;
        }

        this.getCanvas = () => {
            return canvas;
        }

        this.getContext = () => {
            return canvasContext;
        }

        this.convertCoordonateToBackground = (point, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return {
                x: (point.x * backgroundRatio.width + offset.x / resolution)* r,
                y: (point.y * backgroundRatio.height + offset.y / resolution)* r,
            };
        }

        this.convertBackgroundToCoordinate = (point, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return {
                x: (point.x / r - offset.x / resolution) / backgroundRatio.width,
                y: (point.y / r - offset.y / resolution) / backgroundRatio.height,
            };
        }

        this.convertValueToBackground = (value, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return value * backgroundRatio.width* r;
        }

        this.convertBackgroundToValue = (value, forDisplay) => {
            var r = forDisplay ? resolution : 1;
            return value / backgroundRatio.width/ r;
{'fraction_non_alphanumeric': 0.1054414567012492, 'fraction_numerical': 0.004234596654668642, 'mean_word_length': 1.399187404773997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1731774', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1191, 'n_words': 276}