<commit_before>#ifndef _CANVAS_GRAPHICSSTATE_H_
#define _CANVAS_GRAPHICSSTATE_H_

#include <Style.h>
#include <Font.h>
#include <TextBaseline.h>
#include <TextAlign.h>
#include <Path2D.h>
#include <ColorAttribute.h>
#include <FloatAttribute.h>
#include <BoolAttribute.h>
#include <Matrix.h>

#include <cmath>

namespace canvas {
  class GraphicsState {
  public:
    GraphicsState()
      : lineWidth(this, 1.0f),
      fillStyle(this),
      strokeStyle(this),
      shadowBlur(this),
      shadowColor(this),
      shadowOffsetX(this), shadowOffsetY(this),
      globalAlpha(this, 1.0f),
      font(this),
      textBaseline(this),
      textAlign(this),
      imageSmoothingEnabled(this, true)
      { }
    GraphicsState(const GraphicsState & other)
      : lineWidth(this, other.lineWidth),
      fillStyle(this, other.fillStyle),
      strokeStyle(this, other.strokeStyle),
      shadowBlur(this, other.shadowBlur),
      shadowColor(this, other.shadowColor),
      shadowOffsetX(this, other.shadowOffsetX),
      shadowOffsetY(this, other.shadowOffsetY),    
      globalAlpha(this, other.globalAlpha),
      font(this, other.font),
      textBaseline(this, other.textBaseline),
      textAlign(this, other.textAlign),     
      imageSmoothingEnabled(this, other.imageSmoothingEnabled),
      currentPath(other.currentPath),
      clipPath(other.clipPath),
      currentTransform(other.currentTransform) {

    }
      
    GraphicsState & operator=(const GraphicsState & other) {
      if (this != &other) {
	lineWidth = other.lineWidth;
	fillStyle = other.fillStyle;
	strokeStyle = other.strokeStyle;
	shadowBlur = other.shadowBlur;
	shadowColor = other.shadowColor;
	shadowOffsetX = other.shadowOffsetX;
	shadowOffsetY = other.shadowOffsetY;
	globalAlpha = other.globalAlpha;
	font = other.font;
	textBaseline = other.textBaseline;
	textAlign = other.textAlign;
	imageSmoothingEnabled = other.imageSmoothingEnabled;
	currentPath = other.currentPath;
	clipPath = other.clipPath;
	currentTransform = other.currentTransform;
      }
      return *this;
    }

    GraphicsState & arc(double x, double y, double r, double a0, double a1, bool t = false) { currentPath.arc(x, y, r, a0, a1, t); return *this; }
    GraphicsState & moveTo(double x, double y) { currentPath.moveTo(x, y); return *this; }
    GraphicsState & lineTo(double x, double y) { currentPath.lineTo(x, y); return *this; }
    GraphicsState & arcTo(double x1, double y1, double x2, double y2, double radius) { currentPath.arcTo(x1, y1, x2, y2, radius); return *this; }

    GraphicsState & clip() {
      clipPath = currentPath;
      currentPath.clear();
      return *this;
    }
    GraphicsState & resetClip() { clipPath.clear(); return *this; }
    GraphicsState & beginPath() { currentPath.clear(); return *this; }
    GraphicsState & closePath() { currentPath.closePath(); return *this; }
    GraphicsState & rect(double x, double y, double w, double h) {
      currentPath.rect(x, y, w, h);
      return *this;
    }

    GraphicsState & scale(double x, double y) { return transform(Matrix(x, 0.0, 0.0, y, 0.0, 0.0)); }
    GraphicsState & rotate(double angle) {
      double cos_angle = cos(angle), sin_angle = sin(angle);
      return transform(Matrix(cos_angle, sin_angle, -sin_angle, cos_angle, 0.0, 0.0));
    }
    GraphicsState & translate(double x, double y) {
      return transform(Matrix(1.0, 0.0, 0.0, 1.0, x, y));<commit_msg>add transformation<commit_after>#ifndef _CANVAS_GRAPHICSSTATE_H_
#define _CANVAS_GRAPHICSSTATE_H_

#include <Style.h>
#include <Font.h>
#include <TextBaseline.h>
#include <TextAlign.h>
#include <Path2D.h>
#include <ColorAttribute.h>
#include <FloatAttribute.h>
#include <BoolAttribute.h>
#include <Matrix.h>

#include <cmath>

namespace canvas {
  class GraphicsState {
  public:
    GraphicsState()
      : lineWidth(this, 1.0f),
      fillStyle(this),
      strokeStyle(this),
      shadowBlur(this),
      shadowColor(this),
      shadowOffsetX(this), shadowOffsetY(this),
      globalAlpha(this, 1.0f),
      font(this),
      textBaseline(this),
      textAlign(this),
      imageSmoothingEnabled(this, true)
      { }
    GraphicsState(const GraphicsState & other)
      : lineWidth(this, other.lineWidth),
      fillStyle(this, other.fillStyle),
      strokeStyle(this, other.strokeStyle),
      shadowBlur(this, other.shadowBlur),
      shadowColor(this, other.shadowColor),
      shadowOffsetX(this, other.shadowOffsetX),
      shadowOffsetY(this, other.shadowOffsetY),    
      globalAlpha(this, other.globalAlpha),
      font(this, other.font),
      textBaseline(this, other.textBaseline),
      textAlign(this, other.textAlign),     
      imageSmoothingEnabled(this, other.imageSmoothingEnabled),
      currentPath(other.currentPath),
      clipPath(other.clipPath),
      currentTransform(other.currentTransform) {

    }
      
    GraphicsState & operator=(const GraphicsState & other) {
      if (this != &other) {
	lineWidth = other.lineWidth;
	fillStyle = other.fillStyle;
	strokeStyle = other.strokeStyle;
	shadowBlur = other.shadowBlur;
	shadowColor = other.shadowColor;
	shadowOffsetX = other.shadowOffsetX;
	shadowOffsetY = other.shadowOffsetY;
	globalAlpha = other.globalAlpha;
	font = other.font;
	textBaseline = other.textBaseline;
	textAlign = other.textAlign;
	imageSmoothingEnabled = other.imageSmoothingEnabled;
	currentPath = other.currentPath;
	clipPath = other.clipPath;
	currentTransform = other.currentTransform;
      }
      return *this;
    }

    GraphicsState & arc(double x, double y, double r, double a0, double a1, bool t = false) { currentPath.arc(x, y, r, a0, a1, t); return *this; }
    GraphicsState & moveTo(double x, double y) { currentPath.moveTo(currentTransform.multiply(x, y)); return *this; }
    GraphicsState & lineTo(double x, double y) { currentPath.lineTo(currentTransform.multiply(x, y)); return *this; }
    GraphicsState & arcTo(double x1, double y1, double x2, double y2, double radius) { currentPath.arcTo(currentTransform.multiply(x1, y1), currentTransform.multiply(x2, y2), radius); return *this; }

    GraphicsState & clip() {
      clipPath = currentPath;
      currentPath.clear();
      return *this;
    }
    GraphicsState & resetClip() { clipPath.clear(); return *this; }
    GraphicsState & beginPath() { currentPath.clear(); return *this; }
    GraphicsState & closePath() { currentPath.closePath(); return *this; }
    GraphicsState & rect(double x, double y, double w, double h) {
      currentPath.rect(x, y, w, h);
      return *this;
    }

    GraphicsState & scale(double x, double y) { return transform(Matrix(x, 0.0, 0.0, y, 0.0, 0.0)); }
    GraphicsState & rotate(double angle) {
      double cos_angle = cos(angle), sin_angle = sin(angle);
      return transform(Matrix(cos_angle, sin_angle, -sin_angle, cos_angle, 0.0, 0.0));
    }
    GraphicsState & translate(double x, double y) {
      return transform(Matrix(1.0, 0.0, 0.0, 1.0, x, y));
{'fraction_non_alphanumeric': 0.1239752624766288, 'fraction_numerical': 0.010642887962030778, 'mean_word_length': 3.756497948016416, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3271639', 'n_tokens_mistral': 2302, 'n_tokens_neox': 2217, 'n_words': 496}