From 78ccc6b5d9973aa2cd268b7e98ba0393798a5eb4 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 23 Nov 2017 17:03:33 -0800 Subject: add logo & generating script --- docs/logo.sc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docs/logo.sc (limited to 'docs/logo.sc') diff --git a/docs/logo.sc b/docs/logo.sc new file mode 100644 index 00000000..5d8cee3b --- /dev/null +++ b/docs/logo.sc @@ -0,0 +1,40 @@ +import $ivy.`com.lihaoyi::scalatags:0.6.7` +import scalatags.Text.implicits._ +import scalatags.Text.svgTags._ +import scalatags.Text.svgAttrs._ +import ammonite.ops._ + +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", "" + svgFrag) \ No newline at end of file -- cgit v1.2.3