summaryrefslogtreecommitdiff
path: root/docs/logo.sc
blob: 3464f9a902197bdb20e26321a7e53dd95a166a5f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import $ivy.`com.lihaoyi::scalatags:0.6.7`
import scalatags.Text.implicits._
import scalatags.Text.svgTags._
import scalatags.Text.svgAttrs._


val svgWidth = 24
val svgHeight = 24
val numSections = 3
val bandWidth = 16
val bandGap = 8
val screwPitch = 2.0

def section(verticalOffset: Double) = {
  val p = sectionLine(0).map{case (x, y) => (x, y + verticalOffset)}
  val p1 = p.map{case (x, y) => (x, y - bandWidth/2)}
  val p2 = p.map{case (x, y) => (x, y + bandWidth/2)}
  (p1 ++ p2.reverse).map{case (x, y) => s"$x,$y"}.mkString(" ")
}

def sectionLine(startRadians: Double) = for{
  y <- Seq(-svgHeight / 2, svgHeight / 2)
} yield {
  val x = -y * svgWidth / svgHeight
  (x.toInt + svgWidth/2, y.toInt * screwPitch + svgHeight/2)
}

val sections = for(i <- -numSections/2 to numSections/2) yield polyline(
  points := section(i * (bandWidth + bandGap)),
  fill := "#666",
)
val svgFrag = svg(
  xmlns := "http://www.w3.org/2000/svg",
  height := svgHeight,
  width := svgWidth
)(
  sections:_*
)

write.over(pwd/"logo.svg", "<!DOCTYPE html>" + svgFrag)