<commit_before>(function (root, factory) {
	if(typeof define === "function" && define.amd) {
		define(function(){
			return factory();
		});
	} else if(typeof module === "object" && module.exports) {
		module.exports = factory();
	} else {
		root.ViewEESVGRenderer = factory();
	}
}(this, function () {

	// ---------------
	// --- HELPERS ---
	// ---------------

	var SVGNS = 'http://www.w3.org/2000/svg';

	function polarToCartesian(centerX, centerY, radius, angleInDegrees, angleInRadians) {
		if (!angleInRadians)
			angleInRadians = (angleInDegrees-90) * Math.PI / 180.0;

		return {
			x: centerX + (radius * Math.cos(angleInRadians)),
			y: centerY + (radius * Math.sin(angleInRadians))
		};
	}

	function describeArc(x, y, radius, startAngle, endAngle){

		console.log (startAngle, endAngle);

		var start = polarToCartesian(x, y, radius, startAngle);
		var end   = polarToCartesian(x, y, radius, endAngle);

//		var start = polarToCartesian(x, y, radius, endAngle);
//		var end   = polarToCartesian(x, y, radius, startAngle);

		var arcSweep = endAngle - startAngle <= 180 ? "1" : "0";

		var d = [
			"M", start.x.toFixed (3), start.y.toFixed (3),
			"A", radius, radius, 0, arcSweep, 0, end.x.toFixed (3), end.y.toFixed (3)
		].join(" ");

		return d;
	}

	function describeArcRadians (x, y, radius, startAngle, endAngle){

//		var start = polarToCartesian(x, y, radius, null, startAngle);
//		var end   = polarToCartesian(x, y, radius, null, endAngle);

		var start = polarToCartesian(x, y, radius, null, endAngle + 2*Math.PI);
		var end   = polarToCartesian(x, y, radius, null, startAngle + 2*Math.PI);

		var arcSweep = endAngle - startAngle <= Math.PI ? "0" : "1";

		var d = [
			"M", start.x.toFixed (3), start.y.toFixed (3),
			"A", radius, radius, 0, arcSweep, 0, end.x.toFixed (3), end.y.toFixed (3)
		].join(" ");

		return d;
	}

	// ---------------
	// --- DRAWING ---
	// ---------------

	function SVGRenderer (board) {
		var svg = board.svg;

		this.el    = svg;
		this.board = board;

		this.warnings = [];
	}

	SVGRenderer.prototype = Object.create (ViewEERenderer.prototype);

	SVGRenderer.prototype.getScope = function (ctx, attrs) {

		var g = ctx.querySelector ('g[name="'+attrs.name+'"]');
		if (!g) {
			g = MakeEl ('g', {xmlns: SVGNS, name: attrs.name});
			ctx.appendChild (g);
		}

		for (var a in attrs) {
			g.setAttributeNS (null, a, attrs[a]);
		}

		return g;
	}

	SVGRenderer.prototype.redraw = function () {

	}

	SVGRenderer.prototype.draw = function () {
		var svg = this.el;

		var board = this.board;

		if (board.interactive && board.interactive.destroy)
			board.interactive.destroy ();

		while (svg.firstChild) {
			svg.removeChild (svg.firstChild);
		}

		board.ratio = 1;

		var scaleX = board.scale * board.baseScale * board.ratio * (board.boardFlipped ? -1.0 : 1.0);
		var scaleY = (board.coordYFlip ? 1 : -1) * board.scale  * board.baseScale * board.ratio;
		var scaleTransY = board.coordYFlip ? 0 : parseFloat (svg.style.height);

		var transX = board.boardFlipped ? -board.nativeBounds[2] : -board.nativeBounds[0];
		var transY = -board.nativeBounds[1]; //board.coordYFlip ? 0 : board.nativeBounds[1]; //-board.nativeBounds[1];

		var g;

		svg.appendChild (MakeEl ('g', {
			xmlns: SVGNS,
			transform: 'matrix('+scaleX+', 0, 0, '+scaleY+', 0, '+scaleTransY+')', // board.scale*board.baseScale
		}, g = MakeEl ('g', {
			xmlns: SVGNS,
			className: 'container',
			transform: 'translate('+transX+', '+transY+')'
		})));

		var layerOrder = board.boardFlipped ? board.reverseRenderLayerOrder : board.renderLayerOrder;
		for (var layerKey in layerOrder) {
			var layerId = layerOrder[layerKey];
			if (!board.visibleLayers[layerId]) { continue };
			board.layerRenderFunctions[layerId](this, board, g);
		}

		if (board.initInteractive)
			board.initInteractive ();

	}

	SVGRenderer.prototype.drawSingleWire = function (wire, ctx) {
		var path = this.drawWire (wire, ctx);<commit_msg>added viewport to scale easily<commit_after>(function (root, factory) {
	if(typeof define === "function" && define.amd) {
		define(function(){
			return factory();
		});
	} else if(typeof module === "object" && module.exports) {
		module.exports = factory();
	} else {
		root.ViewEESVGRenderer = factory();
	}
}(this, function () {

	// ---------------
	// --- HELPERS ---
	// ---------------

	var SVGNS = 'http://www.w3.org/2000/svg';

	function polarToCartesian(centerX, centerY, radius, angleInDegrees, angleInRadians) {
		if (!angleInRadians)
			angleInRadians = (angleInDegrees-90) * Math.PI / 180.0;

		return {
			x: centerX + (radius * Math.cos(angleInRadians)),
			y: centerY + (radius * Math.sin(angleInRadians))
		};
	}

	function describeArc(x, y, radius, startAngle, endAngle){

		console.log (startAngle, endAngle);

		var start = polarToCartesian(x, y, radius, startAngle);
		var end   = polarToCartesian(x, y, radius, endAngle);

//		var start = polarToCartesian(x, y, radius, endAngle);
//		var end   = polarToCartesian(x, y, radius, startAngle);

		var arcSweep = endAngle - startAngle <= 180 ? "1" : "0";

		var d = [
			"M", start.x.toFixed (3), start.y.toFixed (3),
			"A", radius, radius, 0, arcSweep, 0, end.x.toFixed (3), end.y.toFixed (3)
		].join(" ");

		return d;
	}

	function describeArcRadians (x, y, radius, startAngle, endAngle){

//		var start = polarToCartesian(x, y, radius, null, startAngle);
//		var end   = polarToCartesian(x, y, radius, null, endAngle);

		var start = polarToCartesian(x, y, radius, null, endAngle + 2*Math.PI);
		var end   = polarToCartesian(x, y, radius, null, startAngle + 2*Math.PI);

		var arcSweep = endAngle - startAngle <= Math.PI ? "0" : "1";

		var d = [
			"M", start.x.toFixed (3), start.y.toFixed (3),
			"A", radius, radius, 0, arcSweep, 0, end.x.toFixed (3), end.y.toFixed (3)
		].join(" ");

		return d;
	}

	// ---------------
	// --- DRAWING ---
	// ---------------

	function SVGRenderer (board) {
		var svg = board.svg;

		this.el    = svg;
		this.board = board;

		this.warnings = [];
	}

	SVGRenderer.prototype = Object.create (ViewEERenderer.prototype);

	SVGRenderer.prototype.getScope = function (ctx, attrs) {

		var g = ctx.querySelector ('g[name="'+attrs.name+'"]');
		if (!g) {
			g = MakeEl ('g', {xmlns: SVGNS, name: attrs.name});
			ctx.appendChild (g);
		}

		for (var a in attrs) {
			g.setAttributeNS (null, a, attrs[a]);
		}

		return g;
	}

	SVGRenderer.prototype.redraw = function () {

	}

	SVGRenderer.prototype.draw = function () {
		var svg = this.el;

		var board = this.board;

		if (board.interactive && board.interactive.destroy)
			board.interactive.destroy ();

		while (svg.firstChild) {
			svg.removeChild (svg.firstChild);
		}

		board.ratio = 1;

		var scaleX = board.scale * board.baseScale * board.ratio * (board.boardFlipped ? -1.0 : 1.0);
		var scaleY = (board.coordYFlip ? 1 : -1) * board.scale  * board.baseScale * board.ratio;
		var scaleTransY = board.coordYFlip ? 0 : parseFloat (svg.style.height);

		var transX = board.boardFlipped ? -board.nativeBounds[2] : -board.nativeBounds[0];
		var transY = -board.nativeBounds[1]; //board.coordYFlip ? 0 : board.nativeBounds[1]; //-board.nativeBounds[1];

		var g;

		svg.appendChild (MakeEl ('g', {
			xmlns: SVGNS,
			className: 'viewport'
		}, MakeEl ('g', {
			xmlns: SVGNS,
			transform: 'matrix('+scaleX+', 0, 0, '+scaleY+', 0, '+scaleTransY+')', // board.scale*board.baseScale
		}, g = MakeEl ('g', {
			xmlns: SVGNS,
			className: 'container',
			transform: 'translate('+transX+', '+transY+')'
		}))));

		this.svgCtx = g;

		var layerOrder = board.boardFlipped ? board.reverseRenderLayerOrder : board.renderLayerOrder;
		for (var layerKey in layerOrder) {
			var layerId = layerOrder[layerKey];
			if (!board.visibleLayers[layerId]) { continue };
			board.layerRenderFunctions[layerId](this, board, g);
		}

		if (board.initInteractive)
			board.initInteractive ();

	}

	SVGRenderer.prototype.drawSingleWire = function (wire, ctx) {
		var path = this.drawWire (wire, ctx);
{'fraction_non_alphanumeric': 0.18227341011517276, 'fraction_numerical': 0.012268402603905859, 'mean_word_length': 3.249468085106383, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 7}, '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': '5131883', 'n_tokens_mistral': 3200, 'n_tokens_neox': 2877, 'n_words': 663}