<commit_before>import MiniCanvas;

import thx.color.*;
using thx.Iterators;
using thx.Arrays;
import thx.Ints;

class Demo {
  static function interpolations() {
    var left  : Hsv = 'hsv(160deg,100%,63%)',
        right : Hsv = 'hsv(345deg,88%,77%)';

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Rgb).interpolate(right, t))
      .display('interpolateRgb');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Cmy).interpolate(right, t))
      .display('interpolateCmy');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Cmyk).interpolate(right, t))
      .display('interpolateCmyk');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Grey).interpolate(right, t))
      .display('interpolateGrey');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Hsl).interpolate(right, t))
      .display('interpolateHsl');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Hsv).interpolate(right, t))
      .display('interpolateHsv');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : CieLab).interpolate(right, t))
      .display('interpolateCielab');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : CieLCh).interpolate(right, t))
      .display('interpolateCielch');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Xyz).interpolate(right, t))
      .display('interpolateXyz');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgba return (left : Yxy).interpolate(right, t))
      .display('interpolateYxy');
  }

  public static function main() {
    interpolations();

    MiniCanvas.create(200, 200).box(
      function(x : Float, y : Float) : Rgba
        return Hsl.create(x * 360, 1, y))
      .display("rainbowHsl");

    MiniCanvas.create(200, 200).box(
      function(x : Float, y : Float) : Rgba
        return CieLCh.create(65, y * 65, x * 360))
      .display("rainbowCielch");

    MiniCanvas.create(200, 200).box(
      function(x : Float, y : Float) : Rgba
        return CieLab.create(40, x * 200 - 100, y * 200 - 100))
      .display("rainbowCielab");

    MiniCanvas.create(200, 200).box(
      function(x : Float, y : Float) : Rgba
        return Xyz.create(x * 800, y * 900, 1)
    ).display("xyzChromaticityDiagram");

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t) : Rgba
        return ('#ff0000' : Rgb).darker(t))
      .display('darkerRgb');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t) : Rgba
        return ('#0000ff' : Rgb).lighter(t))
      .display('lighterRgb');

    var c = MiniCanvas.create(900, 1200);
    colorTable(c.ctx, c.width, c.height);
    c.display('colorTable');
  }

  public static function colorTable(ctx, w, h) {
    var columns = 5,
        colors  = Color.names.keys().toArray().filter(function(n) return n.indexOf(' ') < 0),
        cellw   = w / columns,
        cellh   = h / Math.ceil(colors.length / columns);
    ctx.textAlign = "center";
    ctx.textBaseline = "middle";
    ctx.font = '${Math.round(cellh*0.4)}px Verdana, sans-serif';
    colors.mapi(function(name, i) {
      var col   = i % columns,
        row   = Math.floor(i / columns),
        color = Color.names.get(name);

      ctx.fillStyle = color.toString();
      ctx.fillRect(col * cellw, row * cellh, cellw, cellh);

      ctx.fillStyle = color.toRgbx()
        .toPerceivedGrey()
        .contrast()
        .toRgb().toString();
      ctx.fillText(
        name,
        Math.round(col * cellw + cellw / 2) + 0.5,<commit_msg>updated Demo<commit_after>import MiniCanvas;

import thx.color.*;
using thx.Iterators;
using thx.Arrays;
import thx.Ints;

class Demo {
  static function interpolations() {
    var left  : Hsv = 'hsv(160deg,100%,63%)',
        right : Hsv = 'hsv(345deg,88%,77%)';

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Rgb).interpolate(right, t))
      .display('interpolateRgb');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Cmy).interpolate(right, t))
      .display('interpolateCmy');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Cmyk).interpolate(right, t))
      .display('interpolateCmyk');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Grey).interpolate(right, t))
      .display('interpolateGrey');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Hsl).interpolate(right, t))
      .display('interpolateHsl');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Hsv).interpolate(right, t))
      .display('interpolateHsv');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : CieLab).interpolate(right, t))
      .display('interpolateCielab');

    MiniCanvas.create(400, 20)
      .checkboard()
      .gradientHorizontal(function(t : Float) : Rgbxa return (left : CieLCh).interpolate(right, t))
      .display('interpolateCielch');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Xyz).interpolate(right, t))
      .display('interpolateXyz');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t : Float) : Rgbxa return (left : Yxy).interpolate(right, t))
      .display('interpolateYxy');
  }

  public static function main() {
    interpolations();

    var t = Rgbxa.create(0, 0, 0, 0);

    MiniCanvas.create(200, 200).box(
      function(x : Float, y : Float) : Rgbxa
        return Hsl.create(x * 360, 1, y))
      .display("rainbowHsl");

    MiniCanvas.create(200, 200)
      .checkboard()
      .box(function(x : Float, y : Float) : Rgbxa
        return CieLCh.create(75, y * 65, x * 360))
      .display("rainbowCielch");

    MiniCanvas.create(200, 200)
      .checkboard()
      .box(function(x : Float, y : Float) : Rgbxa
        return CieLab.create(75, x * 256 - 128, y * 256 - 128))
      .display("rainbowCielab");

    MiniCanvas.create(200, 200)
      .checkboard()
      .box(
        function(x : Float, y : Float) : Rgbxa
          return Xyz.create(x * 8 + 4, y * 8 + 4, 10))
      .display("xyzChromaticityDiagram");

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t) : Rgbxa
        return ('#ff0000' : Rgb).darker(t))
      .display('darkerRgb');

    MiniCanvas.create(400, 20).gradientHorizontal(
      function(t) : Rgbxa
        return ('#0000ff' : Rgb).lighter(t))
      .display('lighterRgb');

    var c = MiniCanvas.create(900, 1200);
    colorTable(c.ctx, c.width, c.height);
    c.display('colorTable');
  }

  public static function colorTable(ctx, w, h) {
    var columns = 5,
        colors  = Color.names.keys().toArray().filter(function(n) return n.indexOf(' ') < 0),
        cellw   = w / columns,
        cellh   = h / Math.ceil(colors.length / columns);
    ctx.textAlign = "center";
    ctx.textBaseline = "middle";
    ctx.font = '${Math.round(cellh*0.4)}px Verdana, sans-serif';
    colors.mapi(function(name, i) {
      var col   = i % columns,
          row   = Math.floor(i / columns),
          color = Color.names.get(name);
      trace(color);
      ctx.fillStyle = color.toString();
      ctx.fillRect(col * cellw, row * cellh, cellw, cellh);

      ctx.fillStyle = color.toRgbx()
        .toPerceivedGrey()
        .contrast()
        .toRgb().toString();
      ctx.fillText(
        name,
        Math.round(col * cellw + cellw / 2) + 0.5,
{'fraction_non_alphanumeric': 0.15240136140173957, 'fraction_numerical': 0.03895121643766545, 'mean_word_length': 2.931615460852329, 'pattern_counts': {'":': 0, '<': 5, '<?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': '287821', 'n_tokens_mistral': 3006, 'n_tokens_neox': 2699, 'n_words': 550}