<commit_before>﻿/// <reference path="../Runtime/Nullstone.js"/>
/// CODE
/// <reference path="Enums.js"/>

//#region RawPath
var RawPath = Nullstone.Create("RawPath");

RawPath.Instance.Init = function () {
    this._Path = [];
};

RawPath.Instance.Move = function (x, y) {
    this._Path.push({
        type: PathEntryType.Move,
        x: x,
        y: y
    });
};
RawPath.Instance.Line = function (x, y) {
    this._Path.push({
        type: PathEntryType.Line,
        x: x,
        y: y
    });
};
RawPath.Instance.Rect = function (x, y, width, height) {
    this._Path.push({
        type: PathEntryType.Rect,
        x: x,
        y: y,
        width: width,
        height: height
    });
};
RawPath.Instance.RoundedRectFull = function (left, top, width, height, topLeft, topRight, bottomRight, bottomLeft) {
    var right = left + width;
    var bottom = top + height;

    this.Move(left + topLeft, top);
    //top edge
    this.Line(right - topRight, top);
    //top right arc
    if (topRight > 0)
        this.Quadratic(right, top, right, top + topRight);
    //right edge
    this.Line(right, bottom - bottomRight);
    //bottom right arc
    if (bottomRight > 0)
        this.Quadratic(right, bottom, right - bottomRight, bottom);
    //bottom edge
    this.Line(left + bottomLeft, bottom);
    //bottom left arc
    if (bottomLeft > 0)
        this.Quadratic(left, bottom, left, bottom - bottomLeft);
    //left edge
    this.Line(left, top + topLeft);
    //top left arc
    if (topLeft > 0)
        this.Quadratic(left, top, left + topLeft, top);
    this.Close();
};
RawPath.Instance.RoundedRect = function (left, top, width, height, radiusX, radiusY) {
    if (radiusX === 0.0 && radiusY === 0.0) {
        this.Rect(left, top, width, height);
        return;
    }
    var right = left + width;
    var bottom = top + height;
    this.Move(left + radiusX, top);
    //top edge
    this.Line(right - radiusX, top);
    //top right arc
    this.Quadratic(right, top, right, top + radiusY);
    //right edge
    this.Line(right, bottom - radiusY);
    //bottom right arc
    this.Quadratic(right, bottom, right - radiusX, bottom);
    //bottom edge
    this.Line(left + radiusX, bottom);
    //bottom left arc
    this.Quadratic(left, bottom, left, bottom - radiusY);
    //left edge
    this.Line(left, top + radiusY);
    //top left arc
    this.Quadratic(left, top, left + radiusX, top);
    this.Close();
};
RawPath.Instance.Quadratic = function (cpx, cpy, x, y) {
    this._Path.push({
        type: PathEntryType.Quadratic,
        cpx: cpx,
        cpy: cpy,
        x: x,
        y: y
    });
};
RawPath.Instance.Bezier = function (cp1x, cp1y, cp2x, cp2y, x, y) {
    this._Path.push({
        type: PathEntryType.Bezier,
        cp1x: cp1x,
        cp1y: cp1y,
        cp2x: cp2x,
        cp2y: cp2y,
        x: x,
        y: y
    });
};
RawPath.Instance.Ellipse = function (x, y, width, height) {
    var kappa = .5522848; // 4 * ((sqrt(2) - 1) / 3)
    var ox = width / 2 * kappa;
    var oy = height / 2 * kappa;
    var right = x + width;
    var bottom = y + height;
    var centerX = x + width / 2;
    var centerY = y + height / 2;
    //move to left edge, halfway down
    this.Move(x, centerY);
    //top left bezier curve
    this.Bezier(x, centerY - oy, centerX - ox, y, centerX, y);
    //top right bezier curve
    this.Bezier(centerX + ox, y, right, centerY - oy, right, centerY);
    //bottom right bezier curve
    this.Bezier(right, centerY + oy, centerX + ox, bottom, centerX, bottom);
    //bottom left bezier curve
    this.Bezier(centerX - ox, bottom, x, centerY + oy, x, centerY);
    this.Close();
};
RawPath.Instance.EllipticalArc = function (width, height, rotationAngle, isLargeArcFlag, sweepDirectionFlag, ex, ey) {
    NotImplemented("EllipticalArc");
};
RawPath.Instance.Arc = function (x, y, r, sAngle, eAngle, aClockwise) {<commit_msg>Optimized Ellipse and also fixed Chrome. If Ellipse defines a circle rather than an oval, we will only draw 1 arc 360 degrees.<commit_after>﻿/// <reference path="../Runtime/Nullstone.js"/>
/// CODE
/// <reference path="Enums.js"/>

//#region RawPath
var RawPath = Nullstone.Create("RawPath");

RawPath.Instance.Init = function () {
    this._Path = [];
};

RawPath.Instance.Move = function (x, y) {
    this._Path.push({
        type: PathEntryType.Move,
        x: x,
        y: y
    });
};
RawPath.Instance.Line = function (x, y) {
    this._Path.push({
        type: PathEntryType.Line,
        x: x,
        y: y
    });
};
RawPath.Instance.Rect = function (x, y, width, height) {
    this._Path.push({
        type: PathEntryType.Rect,
        x: x,
        y: y,
        width: width,
        height: height
    });
};
RawPath.Instance.RoundedRectFull = function (left, top, width, height, topLeft, topRight, bottomRight, bottomLeft) {
    var right = left + width;
    var bottom = top + height;

    this.Move(left + topLeft, top);
    //top edge
    this.Line(right - topRight, top);
    //top right arc
    if (topRight > 0)
        this.Quadratic(right, top, right, top + topRight);
    //right edge
    this.Line(right, bottom - bottomRight);
    //bottom right arc
    if (bottomRight > 0)
        this.Quadratic(right, bottom, right - bottomRight, bottom);
    //bottom edge
    this.Line(left + bottomLeft, bottom);
    //bottom left arc
    if (bottomLeft > 0)
        this.Quadratic(left, bottom, left, bottom - bottomLeft);
    //left edge
    this.Line(left, top + topLeft);
    //top left arc
    if (topLeft > 0)
        this.Quadratic(left, top, left + topLeft, top);
    this.Close();
};
RawPath.Instance.RoundedRect = function (left, top, width, height, radiusX, radiusY) {
    if (radiusX === 0.0 && radiusY === 0.0) {
        this.Rect(left, top, width, height);
        return;
    }
    var right = left + width;
    var bottom = top + height;
    this.Move(left + radiusX, top);
    //top edge
    this.Line(right - radiusX, top);
    //top right arc
    this.Quadratic(right, top, right, top + radiusY);
    //right edge
    this.Line(right, bottom - radiusY);
    //bottom right arc
    this.Quadratic(right, bottom, right - radiusX, bottom);
    //bottom edge
    this.Line(left + radiusX, bottom);
    //bottom left arc
    this.Quadratic(left, bottom, left, bottom - radiusY);
    //left edge
    this.Line(left, top + radiusY);
    //top left arc
    this.Quadratic(left, top, left + radiusX, top);
    this.Close();
};
RawPath.Instance.Quadratic = function (cpx, cpy, x, y) {
    this._Path.push({
        type: PathEntryType.Quadratic,
        cpx: cpx,
        cpy: cpy,
        x: x,
        y: y
    });
};
RawPath.Instance.Bezier = function (cp1x, cp1y, cp2x, cp2y, x, y) {
    this._Path.push({
        type: PathEntryType.Bezier,
        cp1x: cp1x,
        cp1y: cp1y,
        cp2x: cp2x,
        cp2y: cp2y,
        x: x,
        y: y
    });
};
RawPath.Instance.Ellipse = function (x, y, width, height) {
    var radiusX = width / 2;
    var radiusY = height / 2;
    var right = x + width;
    var bottom = y + height;
    var centerX = x + radiusX;
    var centerY = y + radiusY;
    if (width === height) { //circle
        this.Arc(centerX, centerY, radiusX, 0, Math.PI * 2, false);
    } else { //oval
        var kappa = .5522848; // 4 * ((sqrt(2) - 1) / 3)
        var ox = radiusX * kappa;
        var oy = radiusY * kappa;

        //move to left edge, halfway down
        this.Move(x, centerY);
        //top left bezier curve
        this.Bezier(x, centerY - oy, centerX - ox, y, centerX, y);
        //top right bezier curve
        this.Bezier(centerX + ox, y, right, centerY - oy, right, centerY);
        //bottom right bezier curve
        this.Bezier(right, centerY + oy, centerX + ox, bottom, centerX, bottom);
        //bottom left bezier curve
        this.Bezier(centerX - ox, bottom, x, centerY + oy, x, centerY);
        this.Close();
    }
};
RawPath.Instance.EllipticalArc = function (width, height, rotationAngle, isLargeArcFlag, sweepDirectionFlag, ex, ey) {
    NotImplemented("EllipticalArc");
};
RawPath.Instance.Arc = function (x, y, r, sAngle, eAngle, aClockwise) {
{'fraction_non_alphanumeric': 0.14287469287469287, 'fraction_numerical': 0.00909090909090909, 'mean_word_length': 2.321501427988576, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '1088313', 'n_tokens_mistral': 2829, 'n_tokens_neox': 2764, 'n_words': 793}