<commit_before>import { select } from 'd3-selection'
import { Delaunay } from 'd3-delaunay'
import { t } from '../main/colors'
const d3 = { select, Delaunay }

export function generate({ target, n }) {
  // canvas setup
  const { width, height } = target.getBoundingClientRect()
  const canvas = document.createElement('canvas')
  canvas.width = width
  canvas.height = height
  canvas.style.position = 'absolute'
  canvas.style.top = 0
  canvas.style.left = 0
  target.insertBefore(canvas, target.firstChild)

  // voronoi setup
  const context = canvas.getContext('2d')
  const particles = Array.from({ length: n }, () => [Math.random() * width, Math.random() * height])

  function update() {
    const delaunay = d3.Delaunay.from(particles)
    const voronoi = delaunay.voronoi([0.5, 0.5, width - 0.5, height - 0.5])
    context.clearRect(0, 0, width, height)

    // render colors based on t
    // context.beginPath()
    for (let i = 0; i < n; i += 1) {
      context.beginPath()
      // map x, y to [0, 1]
      const [x, y] = particles[i]
      const dx = x / width
      const dy = y / height
      let dist = Math.sqrt(dx * dx + dy * dy) / Math.sqrt(2)

      // magic numbers to select what colors should be displayed
      // dist = 0 + dist * 0.5
      context.fillStyle = t(1 - dist)
      voronoi.renderCell(i, context)
      context.fill()<commit_msg>high dpi setup<commit_after>import { select } from 'd3-selection'
import { Delaunay } from 'd3-delaunay'
import { t } from '../main/colors'
const d3 = { select, Delaunay }

export function generate({ target, n }) {
  // canvas setup
  const { width, height } = target.getBoundingClientRect()
  const scale = window.devicePixelRatio
  const canvas = document.createElement('canvas')
  canvas.width = width * scale
  canvas.height = height * scale
  canvas.style.width = width + 'px'
  canvas.style.height = height + 'px'
  canvas.style.position = 'absolute'
  canvas.style.top = 0
  canvas.style.left = 0
  target.insertBefore(canvas, target.firstChild)
  const context = canvas.getContext('2d')
  context.scale(scale, scale)

  // voronoi setup
  const particles = Array.from({ length: n }, () => [Math.random() * width, Math.random() * height])

  function update() {
    const delaunay = d3.Delaunay.from(particles)
    const voronoi = delaunay.voronoi([0.5, 0.5, width - 0.5, height - 0.5])
    context.clearRect(0, 0, width, height)

    // render colors based on t
    // context.beginPath()
    for (let i = 0; i < n; i += 1) {
      context.beginPath()
      // map x, y to [0, 1]
      const [x, y] = particles[i]
      const dx = x / width
      const dy = y / height
      let dist = Math.sqrt(dx * dx + dy * dy) / Math.sqrt(2)

      // magic numbers to select what colors should be displayed
      // dist = 0 + dist * 0.5
      context.fillStyle = t(1 - dist)
      voronoi.renderCell(i, context)
      context.fill()
{'fraction_non_alphanumeric': 0.13935839944808553, 'fraction_numerical': 0.017937219730941704, 'mean_word_length': 2.7516170763260024, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7619306', 'n_tokens_mistral': 988, 'n_tokens_neox': 959, 'n_words': 278}