<commit_before>/* -*- mode: javascript; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */

// TODO: implement bitmap fills, morphing, filled and non-scaling strokes

/** @const */ var FILL_SOLID                        = 0;
/** @const */ var FILL_LINEAR_GRADIENT              = 16;
/** @const */ var FILL_RADIAL_GRADIENT              = 18;
/** @const */ var FILL_FOCAL_RADIAL_GRADIENT        = 19;
/** @const */ var FILL_REPEATING_BITMAP             = 64;
/** @const */ var FILL_CLIPPED_BITMAP               = 65;
/** @const */ var FILL_NONSMOOTHED_REPEATING_BITMAP = 66;
/** @const */ var FILL_NONSMOOTHED_CLIPPED_BITMAP   = 67;

function morph(start, end) {
  return start + (end ? '*' + (end / start / 0xffff) + '*r' : '');
}

function colorToRgba(color, colorMorph) {
  if (colorMorph) {
    return 'rgba(' + [
      morph(color.red, colorMorph.red),
      morph(color.green, colorMorph.green),
      morph(color.blue, colorMorph.blue),
      morph(color.alpha / 255, colorMorph.alpha / 255)
    ].join(',') + ')';
  }
  return 'rgba(' + [
    color.red,
    color.green,
    color.blue,
    color.alpha / 255
  ].join(',') + ')';
}

function matrixToTransform(matrix, matrixMorph) {
  if (matrixMorph) {
    return 'transform(' + [
      morph(matrix.scaleX, matrixMorph.scaleX),
      morph(matrix.scaleY, matrixMorph.scaleY),
      morph(matrix.skew0, matrixMorph.skew0),
      morph(matrix.skew1, matrixMorph.skew1),
      morph(matrix.translateX, matrixMorph.translateX),
      morph(matrix.translateY, matrixMorph.translateY)
    ].join(',') + ')';
  }
  return 'transform(' + [
    matrix.scaleX,
    matrix.skew0,
    matrix.skew1,
    matrix.scaleY,
    matrix.translateX,
    matrix.translateY
  ].join(',') + ')';
}

function joinCmds() {
  return this.cmds.join(';');
}

function ShapeFactory(graph) {
  var records = graph.records;
  var isMorph = graph.isMorph;
  var recordsMorph = isMorph ? graph.recordsMorph : [];
  var fillStyles = graph.fillStyles;
  var lineStyles = graph.lineStyles;
  var fillOffset = 0;
  var lineOffset = 0;
  var sx = 0;
  var sy = 0;
  var dx = 0;
  var dy = 0;
  var sxm = 0;
  var sym = 0;
  var dxm = 0;
  var dym = 0;
  var dpt = '0,0';
  var fill0 = 0;
  var fill1 = 0;
  var line = 0;
  var fillSegments = { };
  var lineEdges = { };<commit_msg>fix matrixToTransform<commit_after>/* -*- mode: javascript; tab-width: 4; insert-tabs-mode: nil; indent-tabs-mode: nil -*- */

// TODO: implement bitmap fills, morphing, filled and non-scaling strokes

/** @const */ var FILL_SOLID                        = 0;
/** @const */ var FILL_LINEAR_GRADIENT              = 16;
/** @const */ var FILL_RADIAL_GRADIENT              = 18;
/** @const */ var FILL_FOCAL_RADIAL_GRADIENT        = 19;
/** @const */ var FILL_REPEATING_BITMAP             = 64;
/** @const */ var FILL_CLIPPED_BITMAP               = 65;
/** @const */ var FILL_NONSMOOTHED_REPEATING_BITMAP = 66;
/** @const */ var FILL_NONSMOOTHED_CLIPPED_BITMAP   = 67;

function morph(start, end) {
  return start + (end ? '*' + (end / start / 0xffff) + '*r' : '');
}

function colorToRgba(color, colorMorph) {
  if (colorMorph) {
    return 'rgba(' + [
      morph(color.red, colorMorph.red),
      morph(color.green, colorMorph.green),
      morph(color.blue, colorMorph.blue),
      morph(color.alpha / 255, colorMorph.alpha / 255)
    ].join(',') + ')';
  }
  return 'rgba(' + [
    color.red,
    color.green,
    color.blue,
    color.alpha / 255
  ].join(',') + ')';
}

function matrixToTransform(matrix, matrixMorph) {
  if (matrixMorph) {
    return 'transform(' + [
      morph(matrix.scaleX * 20, matrixMorph.scaleX * 20),
      morph(matrix.scaleY * 20, matrixMorph.scaleY * 20),
      morph(matrix.skew0 * 20, matrixMorph.skew0 * 20),
      morph(matrix.skew1 * 20, matrixMorph.skew1 * 20),
      morph(matrix.translateX, matrixMorph.translateX),
      morph(matrix.translateY, matrixMorph.translateY)
    ].join(',') + ')';
  }
  return 'transform(' + [
    matrix.scaleX * 20,
    matrix.skew0 * 20,
    matrix.skew1 * 20,
    matrix.scaleY * 20,
    matrix.translateX,
    matrix.translateY
  ].join(',') + ')';
}

function joinCmds() {
  return this.cmds.join(';');
}

function ShapeFactory(graph) {
  var records = graph.records;
  var isMorph = graph.isMorph;
  var recordsMorph = isMorph ? graph.recordsMorph : [];
  var fillStyles = graph.fillStyles;
  var lineStyles = graph.lineStyles;
  var fillOffset = 0;
  var lineOffset = 0;
  var sx = 0;
  var sy = 0;
  var dx = 0;
  var dy = 0;
  var sxm = 0;
  var sym = 0;
  var dxm = 0;
  var dym = 0;
  var dpt = '0,0';
  var fill0 = 0;
  var fill1 = 0;
  var line = 0;
  var fillSegments = { };
  var lineEdges = { };
{'fraction_non_alphanumeric': 0.15502555366269166, 'fraction_numerical': 0.025979557069846677, 'mean_word_length': 2.6868131868131866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6429051', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1735, 'n_words': 379}