<commit_before>/**
 * Inspired by the jQuery Knob project
 * https://github.com/aterrien/jQuery-Knob
 */

 var Dial = function Dial(element, options) {
    this.startAngle = null;
    this.xy = null;
    this.radius = null;
    this.lineWidth = null;
    this.scale = 1;
    this.ctx = null;
    this.v = null;
    this.$canvas = null;
    this.$element = $(element);

    this.options = $.extend({
        min: 0,
        max: 100,
        thickness: 0.35,
        lineCap: 'butt',
        width: 200,
        height: 200,
        bgColor: '#EEEEEE',
        fgColor: '#87CEEB',
    }, options || {});


    this.val = function (v) {
        if (v !== null) {
            this.v = Math.max(Math.min(v, this.options.max), this.options.min);
            this.draw();
        } else {
            return this.v;
        }
    };

    this.init = function () {
        this.$canvas = $(document.createElement('canvas'));
        if (typeof G_vmlCanvasManager !== 'undefined') {
          G_vmlCanvasManager.initElement(this.$canvas[0]);
        }
        this.ctx = this.$canvas[0].getContext ? this.$canvas[0].getContext('2d') : null;

        // this.scale = (window.devicePixelRatio || 1) / (
        //     this.ctx.webkitBackingStorePixelRatio ||
        //     this.ctx.mozBackingStorePixelRatio ||
        //     this.ctx.msBackingStorePixelRatio ||
        //     this.ctx.oBackingStorePixelRatio ||
        //     this.ctx.backingStorePixelRatio || 1
        // );

        //this.ctx.scale(this.scale, this.scale);

        // TODO(dcramer): figure out this scale
        this.width = this.options.width * 4;
        this.height = this.options.height * 4;

        this.$canvas.width = this.width;
        this.$canvas.height = this.height;
        this.$canvas.attr({
            width: this.width,
            height: this.height
        });
        this.$canvas.css({
            width: this.options.width + 'px',
            height: this.options.height + 'px'
        })

        this.$element.html(this.$canvas);

        this.xy = (this.width / 2) * this.scale;
        this.lineWidth = this.xy * this.options.thickness;
        this.lineCap = this.options.lineCap;
        this.radius = this.xy - this.lineWidth / 2;

        // deg to rad
        this.angleOffset = Math.PI / 180;
        this.angleArc = 360 * Math.PI / 180;

        // compute start and end angles
        this.startAngle = 1.5 * Math.PI + this.angleOffset;
        this.endAngle = 1.5 * Math.PI + this.angleOffset + this.angleArc;

        var s = Math.max(
            String(Math.abs(this.options.max)).length,
            String(Math.abs(this.options.min)).length,
            2
        ) + 2;

    };

    this.angle = function (v) {
        return (v - this.options.min) * this.angleArc / (this.options.max - this.options.min);
    };
<commit_msg>Correct smoothing via scale on Dial<commit_after>/**
 * Inspired by the jQuery Knob project
 * https://github.com/aterrien/jQuery-Knob
 */

 var Dial = function Dial(element, options) {
    this.startAngle = null;
    this.xy = null;
    this.radius = null;
    this.lineWidth = null;
    this.scale = 1;
    this.ctx = null;
    this.v = null;
    this.$canvas = null;
    this.$element = $(element);

    this.options = $.extend({
        min: 0,
        max: 100,
        thickness: 0.35,
        lineCap: 'butt',
        width: 200,
        height: 200,
        bgColor: '#EEEEEE',
        fgColor: '#87CEEB',
    }, options || {});


    this.val = function (v) {
        if (v !== null) {
            this.v = Math.max(Math.min(v, this.options.max), this.options.min);
            this.draw();
        } else {
            return this.v;
        }
    };

    this.init = function () {
        this.$canvas = $(document.createElement('canvas'));
        if (typeof G_vmlCanvasManager !== 'undefined') {
          G_vmlCanvasManager.initElement(this.$canvas[0]);
        }
        this.ctx = this.$canvas[0].getContext ? this.$canvas[0].getContext('2d') : null;

        this.scale = (window.devicePixelRatio || 1) / (
            this.ctx.webkitBackingStorePixelRatio ||
            this.ctx.mozBackingStorePixelRatio ||
            this.ctx.msBackingStorePixelRatio ||
            this.ctx.oBackingStorePixelRatio ||
            this.ctx.backingStorePixelRatio || 1
        );

        this.width = this.options.width * this.scale;
        this.height = this.options.height * this.scale;

        this.$canvas.width = this.width;
        this.$canvas.height = this.height;
        this.$canvas.attr({
            width: this.width,
            height: this.height
        });
        this.$canvas.css({
            width: this.options.width + 'px',
            height: this.options.height + 'px'
        })

        this.$element.html(this.$canvas);

        this.xy = (this.width / 2);
        this.lineWidth = this.xy * this.options.thickness;
        this.lineCap = this.options.lineCap;
        this.radius = this.xy - this.lineWidth / 2;

        // deg to rad
        this.angleOffset = Math.PI / 180;
        this.angleArc = 360 * Math.PI / 180;

        // compute start and end angles
        this.startAngle = 1.5 * Math.PI + this.angleOffset;
        this.endAngle = 1.5 * Math.PI + this.angleOffset + this.angleArc;

        var s = Math.max(
            String(Math.abs(this.options.max)).length,
            String(Math.abs(this.options.min)).length,
            2
        ) + 2;

    };

    this.angle = function (v) {
        return (v - this.options.min) * this.angleArc / (this.options.max - this.options.min);
    };

{'fraction_non_alphanumeric': 0.14459774234008244, 'fraction_numerical': 0.014334348683031715, 'mean_word_length': 1.7784967645594822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4965464', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1702, 'n_words': 335}