<commit_before>package client.js

import org.scalajs.dom.raw.CanvasRenderingContext2D
import shared.geometry._
import shared.map.RoadMap

object MapViewer {
  private val MapCoordinatesRange = 1000.0
  private val PixelsMapRange = 800.0
  private val PixelsForMargins = 50.0

  private val PixelsPerMapStep = PixelsMapRange / MapCoordinatesRange

  private val HalfCrossingSize = 20.0

  def drawMap(context: CanvasRenderingContext2D, map: RoadMap): Unit = {
    context.font = HalfCrossingSize + "px Arial"

    map.crossings.foreach(crossing => {
      drawCrossing(context, crossing.coordinates.x, crossing.coordinates.y, crossing.name)
    })

    map.roads.foreach(road => {
      val allPoints = road.start.coordinates :: road.bendingPoints ::: road.end.coordinates :: List.empty
      allPoints.sliding(2).foreach { case List(start, end) => drawRoad(context, start, end) }
    })

    context.stroke
  }

  def drawCrossing(context: CanvasRenderingContext2D, x: Double, y: Double, name: String): Unit = {
    val scaledX = PixelsForMargins + x * PixelsPerMapStep
    val scaledY = PixelsForMargins + y * PixelsPerMapStep

    context.moveTo(scaledX - HalfCrossingSize, scaledY - HalfCrossingSize)
    context.lineTo(scaledX + HalfCrossingSize, scaledY + HalfCrossingSize)
    context.moveTo(scaledX - HalfCrossingSize, scaledY + HalfCrossingSize)
    context.lineTo(scaledX + HalfCrossingSize, scaledY - HalfCrossingSize)

    context.fillText(name, scaledX + HalfCrossingSize, scaledY)
  }

  def drawRoad(context: CanvasRenderingContext2D, start: Coordinates, end: Coordinates): Unit = {
    val scaledStartX = PixelsForMargins + start.x * PixelsPerMapStep
    val scaledStartY = PixelsForMargins + start.y * PixelsPerMapStep<commit_msg>Pink crossings<commit_after>package client.js

import org.scalajs.dom.raw.CanvasRenderingContext2D
import shared.geometry._
import shared.map.RoadMap

object MapViewer {
  private val MapCoordinatesRange = 1000.0
  private val PixelsMapRange = 800.0
  private val PixelsForMargins = 50.0

  private val PixelsPerMapStep = PixelsMapRange / MapCoordinatesRange

  private val HalfCrossingSize = 20.0

  def drawMap(context: CanvasRenderingContext2D, map: RoadMap): Unit = {
    context.font = HalfCrossingSize + "px Arial"

    map.crossings.foreach(crossing => {
      drawCrossing(context, crossing.coordinates.x, crossing.coordinates.y, crossing.name)
    })

    map.roads.foreach(road => {
      val allPoints = road.start.coordinates :: road.bendingPoints ::: road.end.coordinates :: List.empty
      allPoints.sliding(2).foreach { case List(start, end) => drawRoad(context, start, end) }
    })

    context.stroke
  }

  def drawCrossing(context: CanvasRenderingContext2D, x: Double, y: Double, name: String): Unit = {
    val scaledX = PixelsForMargins + x * PixelsPerMapStep
    val scaledY = PixelsForMargins + y * PixelsPerMapStep

    context.beginPath
    context.arc(scaledX, scaledY, HalfCrossingSize, 0, 2 * Math.PI)
    context.closePath
    context.fillStyle = "#803CA2"
    context.fill
    context.stroke

    context.fillStyle = "#000000"

    context.fillText(name, scaledX + 1.5 * HalfCrossingSize, scaledY - 0.5 * HalfCrossingSize)
  }

  def drawRoad(context: CanvasRenderingContext2D, start: Coordinates, end: Coordinates): Unit = {
    val scaledStartX = PixelsForMargins + start.x * PixelsPerMapStep
    val scaledStartY = PixelsForMargins + start.y * PixelsPerMapStep
{'fraction_non_alphanumeric': 0.09415867480383609, 'fraction_numerical': 0.016274338854984017, 'mean_word_length': 4.191553544494721, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5757931', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1079, 'n_words': 239}