sevgi-showcase 0.95.0 → 0.98.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +125 -0
  3. data/README.md +9 -17
  4. data/lib/sevgi/showcase/dark.rb +4 -0
  5. data/lib/sevgi/showcase/minitest/script.rb +59 -57
  6. data/lib/sevgi/showcase/minitest/shell.rb +132 -128
  7. data/lib/sevgi/showcase/minitest/suite.rb +48 -46
  8. data/lib/sevgi/showcase/minitest.rb +6 -0
  9. data/lib/sevgi/showcase/version.rb +1 -1
  10. data/lib/sevgi/showcase.rb +0 -3
  11. data/srv/checkers.sevgi +79 -0
  12. data/srv/checkers.svg +117 -0
  13. data/srv/clover.sevgi +19 -0
  14. data/srv/clover.svg +11 -0
  15. data/srv/clover.yml +3 -0
  16. data/srv/copperplate.sevgi +50 -0
  17. data/srv/copperplate.svg +99 -0
  18. data/srv/copperplate.yml +5 -0
  19. data/srv/{gear-wheel.sevgi → gear.sevgi} +7 -9
  20. data/srv/gear.svg +11 -0
  21. data/srv/gear.yml +2 -0
  22. data/srv/{grid-cells.sevgi → grid.sevgi} +9 -9
  23. data/srv/{grid-cells.svg → grid.svg} +13 -1
  24. data/srv/heart.sevgi +17 -0
  25. data/srv/{heart-mask.svg → heart.svg} +3 -3
  26. data/srv/heart.yml +3 -0
  27. data/srv/logo.sevgi +39 -0
  28. data/srv/logo.svg +29 -0
  29. data/srv/logo.yml +4 -0
  30. data/srv/logos.sevgi +34 -0
  31. data/srv/logos.svg +38 -0
  32. data/srv/logos.yml +4 -0
  33. data/srv/{meter-face.sevgi → meter.sevgi} +6 -6
  34. data/srv/meter.svg +18 -0
  35. data/srv/pacman.sevgi +18 -0
  36. data/srv/pacman.svg +15 -0
  37. data/srv/pokey.sevgi +14 -0
  38. data/srv/pokey.svg +6 -0
  39. data/srv/{ruler-line.sevgi → ruler-.sevgi} +7 -7
  40. data/srv/ruler.sevgi +61 -0
  41. data/srv/ruler.svg +445 -0
  42. data/srv/{snow-flake.sevgi → snowflake.sevgi} +2 -2
  43. data/srv/{snow-flake.svg → snowflake.svg} +1 -1
  44. data/srv/snowflake.yml +2 -0
  45. data/srv/squared.sevgi +42 -0
  46. data/srv/squared.svg +71 -0
  47. data/srv/squared.yml +4 -0
  48. data/srv/stars.sevgi +19 -0
  49. data/srv/stars.svg +30 -0
  50. data/srv/stars.yml +3 -0
  51. data/srv/tulips.sevgi +27 -0
  52. data/srv/tulips.svg +19 -0
  53. data/srv/tulips.yml +3 -0
  54. metadata +57 -36
  55. data/srv/checker-board.sevgi +0 -96
  56. data/srv/checker-board.svg +0 -117
  57. data/srv/gear-wheel.svg +0 -12
  58. data/srv/gear-wheel.yml +0 -3
  59. data/srv/heart-mask.sevgi +0 -17
  60. data/srv/heart-mask.yml +0 -3
  61. data/srv/meter-face.svg +0 -13
  62. data/srv/pacman-pokey.sevgi +0 -17
  63. data/srv/pacman-pokey.svg +0 -9
  64. data/srv/pacman-single.sevgi +0 -17
  65. data/srv/pacman-single.svg +0 -14
  66. data/srv/ruler-hline.sevgi +0 -55
  67. data/srv/ruler-hline.svg +0 -443
  68. data/srv/snow-flake.yml +0 -1
  69. /data/srv/{checker-board.yml → checkers.yml} +0 -0
  70. /data/srv/{grid-cells.yml → grid.yml} +0 -0
  71. /data/srv/{meter-face.yml → meter.yml} +0 -0
  72. /data/srv/{pacman-pokey.yml → pacman.yml} +0 -0
  73. /data/srv/{pacman-single.yml → pokey.yml} +0 -0
  74. /data/srv/{ruler-line.svg → ruler-.svg} +0 -0
  75. /data/srv/{ruler-hline.yml → ruler-.yml} +0 -0
  76. /data/srv/{ruler-line.yml → ruler.yml} +0 -0
@@ -1,4 +1,4 @@
1
- <svg width="160" height="60" viewBox="0 0 160 60">
1
+ <svg width="180" height="80" viewBox="0 0 180 80">
2
2
  <style type="text/css">
3
3
  <![CDATA[
4
4
  .cell {
@@ -9,25 +9,37 @@
9
9
  <rect class="cell" x="0" y="0" width="20" height="20" rx="2" fill="#FF6961"/>
10
10
  <rect class="cell" x="0" y="20" width="20" height="20" rx="2" fill="#77DD77"/>
11
11
  <rect class="cell" x="0" y="40" width="20" height="20" rx="2" fill="#FFD700"/>
12
+ <rect class="cell" x="0" y="60" width="20" height="20" rx="2" fill="#FF6961"/>
12
13
  <rect class="cell" x="20" y="0" width="20" height="20" rx="2" fill="#77DD77"/>
13
14
  <rect class="cell" x="20" y="20" width="20" height="20" rx="2" fill="#FFD700"/>
14
15
  <rect class="cell" x="20" y="40" width="20" height="20" rx="2" fill="#FF6961"/>
16
+ <rect class="cell" x="20" y="60" width="20" height="20" rx="2" fill="#77DD77"/>
15
17
  <rect class="cell" x="40" y="0" width="20" height="20" rx="2" fill="#FFD700"/>
16
18
  <rect class="cell" x="40" y="20" width="20" height="20" rx="2" fill="#FF6961"/>
17
19
  <rect class="cell" x="40" y="40" width="20" height="20" rx="2" fill="#77DD77"/>
20
+ <rect class="cell" x="40" y="60" width="20" height="20" rx="2" fill="#FFD700"/>
18
21
  <rect class="cell" x="60" y="0" width="20" height="20" rx="2" fill="#FF6961"/>
19
22
  <rect class="cell" x="60" y="20" width="20" height="20" rx="2" fill="#77DD77"/>
20
23
  <rect class="cell" x="60" y="40" width="20" height="20" rx="2" fill="#FFD700"/>
24
+ <rect class="cell" x="60" y="60" width="20" height="20" rx="2" fill="#FF6961"/>
21
25
  <rect class="cell" x="80" y="0" width="20" height="20" rx="2" fill="#77DD77"/>
22
26
  <rect class="cell" x="80" y="20" width="20" height="20" rx="2" fill="#FFD700"/>
23
27
  <rect class="cell" x="80" y="40" width="20" height="20" rx="2" fill="#FF6961"/>
28
+ <rect class="cell" x="80" y="60" width="20" height="20" rx="2" fill="#77DD77"/>
24
29
  <rect class="cell" x="100" y="0" width="20" height="20" rx="2" fill="#FFD700"/>
25
30
  <rect class="cell" x="100" y="20" width="20" height="20" rx="2" fill="#FF6961"/>
26
31
  <rect class="cell" x="100" y="40" width="20" height="20" rx="2" fill="#77DD77"/>
32
+ <rect class="cell" x="100" y="60" width="20" height="20" rx="2" fill="#FFD700"/>
27
33
  <rect class="cell" x="120" y="0" width="20" height="20" rx="2" fill="#FF6961"/>
28
34
  <rect class="cell" x="120" y="20" width="20" height="20" rx="2" fill="#77DD77"/>
29
35
  <rect class="cell" x="120" y="40" width="20" height="20" rx="2" fill="#FFD700"/>
36
+ <rect class="cell" x="120" y="60" width="20" height="20" rx="2" fill="#FF6961"/>
30
37
  <rect class="cell" x="140" y="0" width="20" height="20" rx="2" fill="#77DD77"/>
31
38
  <rect class="cell" x="140" y="20" width="20" height="20" rx="2" fill="#FFD700"/>
32
39
  <rect class="cell" x="140" y="40" width="20" height="20" rx="2" fill="#FF6961"/>
40
+ <rect class="cell" x="140" y="60" width="20" height="20" rx="2" fill="#77DD77"/>
41
+ <rect class="cell" x="160" y="0" width="20" height="20" rx="2" fill="#FFD700"/>
42
+ <rect class="cell" x="160" y="20" width="20" height="20" rx="2" fill="#FF6961"/>
43
+ <rect class="cell" x="160" y="40" width="20" height="20" rx="2" fill="#77DD77"/>
44
+ <rect class="cell" x="160" y="60" width="20" height="20" rx="2" fill="#FFD700"/>
33
45
  </svg>
data/srv/heart.sevgi ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env -S ruby -S sevgi
2
+ # frozen_string_literal: true
3
+
4
+ HEART = "M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z"
5
+
6
+ SVG :minimal, width: 120, height: 120, viewBox: "-10 -10 120 120" do
7
+ mask id: "heart",
8
+ maskUnits: "userSpaceOnUse",
9
+ maskContentUnits: "userSpaceOnUse",
10
+ x: 0, y: 0, width: 100, height: 100 do
11
+ square length: 100, fill: "white"
12
+ path d: HEART, fill: "black"
13
+ end
14
+
15
+ polygon points: %w[-10,120 120,120 120,-10], fill: "#e5c39c"
16
+ circle cx: 50, cy: 50, r: 50, mask: "url(#heart)", fill: "purple"
17
+ end.Save
@@ -1,8 +1,8 @@
1
1
  <svg width="120" height="120" viewBox="-10 -10 120 120">
2
2
  <mask id="heart" maskUnits="userSpaceOnUse" maskContentUnits="userSpaceOnUse" x="0" y="0" width="100" height="100">
3
- <rect x="0" y="0" width="100" height="100" fill="white"/>
3
+ <rect width="100" height="100" fill="white"/>
4
4
  <path d="M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z" fill="black"/>
5
5
  </mask>
6
- <polygon points="-10,120 120,120 120,-10" fill="orange"/>
7
- <circle cx="50" cy="50" r="50" mask="url(#heart)" fill="red"/>
6
+ <polygon points="-10,120 120,120 120,-10" fill="#e5c39c"/>
7
+ <circle cx="50" cy="50" r="50" mask="url(#heart)" fill="purple"/>
8
8
  </svg>
data/srv/heart.yml ADDED
@@ -0,0 +1,3 @@
1
+ dark:
2
+ "#e5c39c": "#800080"
3
+ purple: "#e5c39c"
data/srv/logo.sevgi ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env -S ruby -S sevgi
2
+ # frozen_string_literal: true
3
+
4
+ module Logo
5
+ extend SVG::Module
6
+
7
+ LOGO = <<~PATH
8
+ m 30,30 c 0,0 18.39,7.089444 18.39,15 C 48.39,52.910556 30,60 30,60
9
+ M 30,0 C 30,0 11.61,7.089442 11.61,14.999998 C 11.61,22.910556 30,30 30,30
10
+ PATH
11
+
12
+ STYLE = {
13
+ ".active" => {
14
+ fill: "none", stroke: "purple", "stroke-linecap": "round", "stroke-width": 1.5
15
+ },
16
+ ".passive" => {
17
+ fill: "none", stroke: "lightgrey", "stroke-linecap": "round", "stroke-width": 1.5
18
+ }
19
+ }.freeze
20
+
21
+ base do
22
+ css STYLE
23
+ defs { path id: "Logo", d: LOGO }
24
+ end
25
+
26
+ def call
27
+ negative = use id: "SCVN", href: "#Logo"
28
+ negative.Classify :passive
29
+ negative.Matrix(-1, 0, 0, 1, 60, 0)
30
+
31
+ positive = use id: "SCVP", href: "#Logo"
32
+ positive.Classify :active
33
+ end
34
+ end
35
+
36
+ SVG :minimal, width: 120, height: 120, viewBox: "-1 -1 62 62" do
37
+ rect x: -1, y: -1, width: 62, height: 62, fill: "white"
38
+ Call Logo
39
+ end.Save
data/srv/logo.svg ADDED
@@ -0,0 +1,29 @@
1
+ <svg width="120" height="120" viewBox="-1 -1 62 62">
2
+ <rect x="-1" y="-1" width="62" height="62" fill="white"/>
3
+ <style type="text/css">
4
+ <![CDATA[
5
+ .active {
6
+ fill: none;
7
+ stroke: purple;
8
+ stroke-linecap: round;
9
+ stroke-width: 1.5;
10
+ }
11
+ .passive {
12
+ fill: none;
13
+ stroke: lightgrey;
14
+ stroke-linecap: round;
15
+ stroke-width: 1.5;
16
+ }
17
+ ]]>
18
+ </style>
19
+ <defs>
20
+ <path
21
+ id="Logo"
22
+ d="m 30,30 c 0,0 18.39,7.089444 18.39,15 C 48.39,52.910556 30,60 30,60
23
+ M 30,0 C 30,0 11.61,7.089442 11.61,14.999998 C 11.61,22.910556 30,30 30,30
24
+ "
25
+ />
26
+ </defs>
27
+ <use id="SCVN" href="#Logo" class="passive" transform="matrix(-1 0 0 1 60 0)"/>
28
+ <use id="SCVP" href="#Logo" class="active"/>
29
+ </svg>
data/srv/logo.yml ADDED
@@ -0,0 +1,4 @@
1
+ dark:
2
+ lightgrey: "#52525b"
3
+ purple: "#e5c39c"
4
+ white: "#222222"
data/srv/logos.sevgi ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env -S ruby -S sevgi
2
+ # frozen_string_literal: true
3
+
4
+ logo = Decompile <<~SVG, id: "Mark"
5
+ <svg xmlns="http://www.w3.org/2000/svg">
6
+ <g id="Mark">
7
+ <path id="Logo" d="m 30,30 c 0,0 18.39,7.089444 18.39,15 C 48.39,52.910556 30,60 30,60 M 30,0 C 30,0 11.61,7.089442 11.61,14.999998 C 11.61,22.910556 30,30 30,30" fill="none"/>
8
+ <use id="SCVN" href="#Logo" class="passive" transform="matrix(-1,0,0,1,60,0)"/>
9
+ <use id="SCVP" href="#Logo" class="active"/>
10
+ </g>
11
+ </svg>
12
+ SVG
13
+
14
+ STYLE = {
15
+ ".active" => {
16
+ fill: "none", stroke: "purple", "stroke-linecap": "round", "stroke-width": 2.0
17
+ },
18
+ ".passive" => {
19
+ fill: "none", stroke: "lightgrey", "stroke-linecap": "round", "stroke-width": 2.0
20
+ }
21
+ }.freeze
22
+
23
+ opacities = [0.8, 0.86, 0.92, 0.97, 1.0].freeze
24
+ fade = proc do |tile, x:, y:, **|
25
+ tile[:opacity] = opacities.fetch(x + y)
26
+ end
27
+
28
+ SVG :minimal, width: 260, height: 135, viewBox: "0 0 260 135" do
29
+ css STYLE
30
+ rect width: 260, height: 135, fill: "white"
31
+
32
+ defs { logo.evaluate self }
33
+ Tile "Mark", nx: 4, dx: 65, ox: 5, ny: 2, dy: 65, oy: 5, proc: fade
34
+ end.Save
data/srv/logos.svg ADDED
@@ -0,0 +1,38 @@
1
+ <svg width="260" height="135" viewBox="0 0 260 135">
2
+ <style type="text/css">
3
+ <![CDATA[
4
+ .active {
5
+ fill: none;
6
+ stroke: purple;
7
+ stroke-linecap: round;
8
+ stroke-width: 2.0;
9
+ }
10
+ .passive {
11
+ fill: none;
12
+ stroke: lightgrey;
13
+ stroke-linecap: round;
14
+ stroke-width: 2.0;
15
+ }
16
+ ]]>
17
+ </style>
18
+ <rect width="260" height="135" fill="white"/>
19
+ <defs>
20
+ <g id="Mark" xmlns="http://www.w3.org/2000/svg">
21
+ <path
22
+ id="Logo"
23
+ d="m 30,30 c 0,0 18.39,7.089444 18.39,15 C 48.39,52.910556 30,60 30,60 M 30,0 C 30,0 11.61,7.089442 11.61,14.999998 C 11.61,22.910556 30,30 30,30"
24
+ fill="none"
25
+ />
26
+ <use id="SCVN" href="#Logo" class="passive" transform="matrix(-1,0,0,1,60,0)"/>
27
+ <use id="SCVP" href="#Logo" class="active"/>
28
+ </g>
29
+ </defs>
30
+ <use id="Mark-1-1" href="#Mark" class="tile-row-1 tile-row-first tile-col-1 tile-col-first" x="5" y="5" opacity="0.8"/>
31
+ <use id="Mark-1-2" href="#Mark" class="tile-row-1 tile-row-first tile-col-2" x="70" y="5" opacity="0.86"/>
32
+ <use id="Mark-1-3" href="#Mark" class="tile-row-1 tile-row-first tile-col-3" x="135" y="5" opacity="0.92"/>
33
+ <use id="Mark-1-4" href="#Mark" class="tile-row-1 tile-row-first tile-col-4 tile-col-last" x="200" y="5" opacity="0.97"/>
34
+ <use id="Mark-2-1" href="#Mark" class="tile-row-2 tile-row-last tile-col-1 tile-col-first" x="5" y="70" opacity="0.86"/>
35
+ <use id="Mark-2-2" href="#Mark" class="tile-row-2 tile-row-last tile-col-2" x="70" y="70" opacity="0.92"/>
36
+ <use id="Mark-2-3" href="#Mark" class="tile-row-2 tile-row-last tile-col-3" x="135" y="70" opacity="0.97"/>
37
+ <use id="Mark-2-4" href="#Mark" class="tile-row-2 tile-row-last tile-col-4 tile-col-last" x="200" y="70" opacity="1.0"/>
38
+ </svg>
data/srv/logos.yml ADDED
@@ -0,0 +1,4 @@
1
+ dark:
2
+ lightgrey: "#52525b"
3
+ purple: "#e5c39c"
4
+ white: "#222222"
@@ -6,15 +6,15 @@ LED_GAP = 2
6
6
  LED_WIDTH = 10
7
7
  TOTAL_WIDTH = (LED_COUNT * (LED_WIDTH + LED_GAP)) + 8
8
8
 
9
+ dim = proc do |led, x:, **|
10
+ led[:"fill-opacity"] = 0.3 if x >= 7
11
+ end
12
+
9
13
  SVG :minimal, width: TOTAL_WIDTH, height: 30, viewBox: "0 0 #{TOTAL_WIDTH} 30" do
10
14
  rect x: 2, y: 2, width: TOTAL_WIDTH - 4, height: 26,
11
15
  rx: 4, fill: "none", stroke: "#666"
12
16
 
13
- x = 5
14
- LED_COUNT.times do |i|
15
- rect x:, y: 5, width: LED_WIDTH, height: 20,
16
- rx: 3, fill: "green", "fill-opacity": (i < 7 ? 1 : 0.3)
17
-
18
- x += LED_WIDTH + LED_GAP
17
+ TileX "led", n: LED_COUNT, d: LED_WIDTH + LED_GAP, o: 5, proc: dim do
18
+ rect y: 5, width: LED_WIDTH, height: 20, rx: 3, fill: "green"
19
19
  end
20
20
  end.Save
data/srv/meter.svg ADDED
@@ -0,0 +1,18 @@
1
+ <svg width="128" height="30" viewBox="0 0 128 30">
2
+ <rect x="2" y="2" width="124" height="26" rx="4" fill="none" stroke="#666"/>
3
+ <defs>
4
+ <g id="led">
5
+ <rect y="5" width="10" height="20" rx="3" fill="green"/>
6
+ </g>
7
+ </defs>
8
+ <use id="led-1" href="#led" class="tile-col-1 tile-col-first" x="5"/>
9
+ <use id="led-2" href="#led" class="tile-col-2" x="17"/>
10
+ <use id="led-3" href="#led" class="tile-col-3" x="29"/>
11
+ <use id="led-4" href="#led" class="tile-col-4" x="41"/>
12
+ <use id="led-5" href="#led" class="tile-col-5" x="53"/>
13
+ <use id="led-6" href="#led" class="tile-col-6" x="65"/>
14
+ <use id="led-7" href="#led" class="tile-col-7" x="77"/>
15
+ <use id="led-8" href="#led" class="tile-col-8" x="89" fill-opacity="0.3"/>
16
+ <use id="led-9" href="#led" class="tile-col-9" x="101" fill-opacity="0.3"/>
17
+ <use id="led-10" href="#led" class="tile-col-10 tile-col-last" x="113" fill-opacity="0.3"/>
18
+ </svg>
data/srv/pacman.sevgi ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env -S ruby -S sevgi
2
+ # frozen_string_literal: true
3
+
4
+ SVG :minimal, width: 180, height: 90 do
5
+ rect id: "frame", width: 180, height: 90, rx: 5, fill: "white"
6
+
7
+ circle id: "head", cx: 70, cy: 45, r: 40, fill: "purple"
8
+ circle id: "eye", cx: 80, cy: 23, r: 6, fill: "white"
9
+ polygon id: "mouth", points: %w[70,45 110,15 110,75], fill: "white"
10
+
11
+ Symbol "dot" do
12
+ circle cx: 110, cy: 45, r: 6, fill: "purple"
13
+ end
14
+
15
+ g id: "dots" do
16
+ TileX "dot", n: 3, d: 18
17
+ end
18
+ end.Save
data/srv/pacman.svg ADDED
@@ -0,0 +1,15 @@
1
+ <svg width="180" height="90">
2
+ <rect id="frame" width="180" height="90" rx="5" fill="white"/>
3
+ <circle id="head" cx="70" cy="45" r="40" fill="purple"/>
4
+ <circle id="eye" cx="80" cy="23" r="6" fill="white"/>
5
+ <polygon id="mouth" points="70,45 110,15 110,75" fill="white"/>
6
+ <symbol id="dot">
7
+ <title>Dot</title>
8
+ <circle cx="110" cy="45" r="6" fill="purple"/>
9
+ </symbol>
10
+ <g id="dots">
11
+ <use id="dot-1" href="#dot" class="tile-col-1 tile-col-first"/>
12
+ <use id="dot-2" href="#dot" class="tile-col-2" x="18"/>
13
+ <use id="dot-3" href="#dot" class="tile-col-3 tile-col-last" x="36"/>
14
+ </g>
15
+ </svg>
data/srv/pokey.sevgi ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env -S ruby -S sevgi
2
+ # frozen_string_literal: true
3
+
4
+ SVG :minimal, width: 100, height: 100 do
5
+ rect x: 0, y: 0, width: 100, height: 100, fill: "white"
6
+ path fill: "purple", d: %w[
7
+ M10 101 V50 A40 40 0 0 1 90 50 V101
8
+ L76 85 L63 101 L50 85 L37 101 L24 85 Z
9
+ ]
10
+
11
+ [25, 50].each do |x|
12
+ circle cx: x, cy: 40, r: 8, fill: "white"
13
+ end
14
+ end.Save
data/srv/pokey.svg ADDED
@@ -0,0 +1,6 @@
1
+ <svg width="100" height="100">
2
+ <rect x="0" y="0" width="100" height="100" fill="white"/>
3
+ <path fill="purple" d="M10 101 V50 A40 40 0 0 1 90 50 V101 L76 85 L63 101 L50 85 L37 101 L24 85 Z"/>
4
+ <circle cx="25" cy="40" r="8" fill="white"/>
5
+ <circle cx="50" cy="40" r="8" fill="white"/>
6
+ </svg>
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env -S ruby -S sevgi
2
2
  # frozen_string_literal: true
3
3
 
4
- WIDTH = 150 # 15 cm width (ruler's length)
5
- HEIGHT = 20 # 2 cm height
4
+ WIDTH = 150 # 15 cm width (ruler's length)
5
+ HEIGHT = 20 # 2 cm height
6
6
 
7
7
  STYLE = {
8
- ".labels": { fill: "black", font: "3pt monospace" },
9
- ".majors": { stroke: "black", "stroke-width": 0.2 },
10
- ".halves": { stroke: "black", "stroke-width": 0.1 },
11
- ".minors": { stroke: "black", "stroke-width": 0.1 },
12
- ".frame": { stroke: "black", "stroke-width": 0.05, fill: "none" }
8
+ ".labels" => { fill: "black", font: "3pt monospace" },
9
+ ".majors" => { stroke: "black", "stroke-width": 0.2 },
10
+ ".halves" => { stroke: "black", "stroke-width": 0.1 },
11
+ ".minors" => { stroke: "black", "stroke-width": 0.1 },
12
+ ".frame" => { stroke: "black", "stroke-width": 0.05, fill: "none" }
13
13
  }.freeze
14
14
 
15
15
  SVG width: "210mm", height: "50mm", viewBox: "0 0 210 50" do
data/srv/ruler.sevgi ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env -S ruby -S sevgi
2
+ # frozen_string_literal: true
3
+
4
+ WIDTH = 150 # 15 cm width (ruler's length)
5
+ HEIGHT = 20 # 2 cm height
6
+ PAGE_WIDTH = 170
7
+ PAGE_HEIGHT = 30
8
+
9
+ STYLE = {
10
+ ".labels" => { fill: "black", font: "3pt monospace" },
11
+ ".majors" => { stroke: "black", "stroke-width": 0.3 },
12
+ ".halves" => { stroke: "black", "stroke-width": 0.15 },
13
+ ".minors" => { stroke: "black", "stroke-width": 0.15 },
14
+ ".frame" => { stroke: "black", "stroke-width": 0.15, fill: "none" }
15
+ }.freeze
16
+
17
+ SVG width: "#{PAGE_WIDTH}mm", height: "#{PAGE_HEIGHT}mm",
18
+ viewBox: "0 0 #{PAGE_WIDTH} #{PAGE_HEIGHT}" do
19
+ css STYLE
20
+
21
+ ruler = g id: "ruler" do
22
+ rect id: "frame", width: WIDTH, height: HEIGHT, class: "frame"
23
+
24
+ layer id: "minors" do
25
+ length = 2
26
+
27
+ (0..WIDTH).step(1) do |x|
28
+ VLineBy x:, y: 0, length:, class: "minors"
29
+ VLineBy x:, y: HEIGHT, length: -length, class: "minors"
30
+ end
31
+ end
32
+
33
+ layer id: "halves" do
34
+ length = 4
35
+
36
+ (0..WIDTH).step(5) do |x|
37
+ VLineBy x:, y: 0, length:, class: "halves"
38
+ VLineBy x:, y: HEIGHT, length: -length, class: "halves"
39
+ end
40
+ end
41
+
42
+ layer id: "majors" do
43
+ length = 6
44
+
45
+ (10..(WIDTH - 10)).step(10) do |x|
46
+ VLineBy x:, y: 0, length:, class: "majors"
47
+ VLineBy x:, y: HEIGHT, length: -length, class: "majors"
48
+ end
49
+
50
+ layer id: "labels" do
51
+ (10..(WIDTH - 10)).step(10).each_with_index do |x, i|
52
+ text (i + 1).to_s, "text-anchor": "middle", x:, y: length + 5.5, class: "labels"
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ offset_x = (PAGE_WIDTH - WIDTH) / 2
59
+ offset_y = (PAGE_HEIGHT - HEIGHT) / 2
60
+ ruler.Translate offset_x, offset_y
61
+ end.Save