dieses 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e460b0467bf1fb5b34295fb10d8cb1a477b45c3ce46b00f75c7b910c51277c60
4
- data.tar.gz: 8b689557c7f6357840f7a549acba2f1e3eba31464fbbbbce77fb0e4007ae1e72
3
+ metadata.gz: 228a00e8d18798888221d4dd9a0f9437e57b9dd0b360f8902f6e2e6d0bc4fd41
4
+ data.tar.gz: 23dec797ddb7dc00e6d3bd0490a6e8bc4016d2ebc498ed4184e71d4af848d407
5
5
  SHA512:
6
- metadata.gz: 92c64d445a336625cb86715d975914eafa3c00150139d66bd9a996bba4231e79871df2697ee3d680e22647190fd3d23435d09d530057f294e404182e4faf3b85
7
- data.tar.gz: 0be3ede03b34c7c64df50ebdf7c3a5bd72b72a98c93d84f8927dd17282b96ed1e714ec38ddf614c36d4a80e359970a8bed5aed9adec475e1c3110460f6c6aea8
6
+ metadata.gz: 8b52961fcc1d1b8b9ece35de31977b2f4719917deb4725d545a544bb8975c379eb66acde2f33decdf96ea32e1a2298bf2b4cfbb857de3c36091da1f5153305f0
7
+ data.tar.gz: 2bec77689964240ab83d088a3b97175e80d77e53870e0c8bed91db3b9fbc6d57edaf296cbc40b120172882bf687f1f89a735db237e3fd88bdcc5c39f1ae778d1
data/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@ Changelog
3
3
 
4
4
  All notable changes to this project will be documented in this file.
5
5
 
6
+ [0.1.0] - 2021-08-25
7
+ --------------------
8
+
9
+ ### Added
10
+
11
+ - New sheet: table
12
+
13
+
6
14
  [0.0.3] - 2021-08-25
7
15
  --------------------
8
16
 
data/README.md CHANGED
@@ -2,7 +2,7 @@ Dieses
2
2
  ======
3
3
 
4
4
  [![test](https://github.com/alaturka/dieses/actions/workflows/test.yml/badge.svg)](https://github.com/alaturka/dieses/actions/workflows/test.yml)
5
- [![codebeat badge](https://codebeat.co/badges/7e57d6fa-d244-4359-a324-c4239217b749)](https://codebeat.co/projects/github-com-alaturka-dieses-master)
5
+ [![codebeat badge](https://codebeat.co/badges/3fe38471-6dbc-4ca1-ba22-759508cbf3b0)](https://codebeat.co/projects/github-com-alaturka-dieses-dev)
6
6
 
7
7
  Guide sheets for penmanship, calligraphy, lettering, and sketching.
8
8
  [Click](https://github.com/alaturka/dieses/tree/master/docs/sheets) to reach the all available guide sheet combinations.
@@ -23,5 +23,7 @@ module Dieses
23
23
  Param = Class.new struct
24
24
 
25
25
  Orientation = Geometry::Rect::Orientation
26
+
27
+ Ruler = Support::Ruler
26
28
  end
27
29
  end
@@ -9,28 +9,10 @@ module Dieses
9
9
  @canvas = canvas
10
10
  end
11
11
 
12
- def draw(unit:, multiple: nil, &block)
12
+ def draw(unit:, multiple: 1, &block)
13
13
  Draw.(self, Ruler.(unit, multiple), &block)
14
14
  end
15
15
 
16
- Ruler = Struct.new :unit, :multiple do
17
- def self.call(unit, multiple = nil)
18
- new unit, (multiple || 1)
19
- end
20
-
21
- def major
22
- @major ||= multiple * unit
23
- end
24
-
25
- def even(length)
26
- major * (length / major).to_i
27
- end
28
-
29
- def measure(n)
30
- n * unit
31
- end
32
- end
33
-
34
16
  class Draw
35
17
  extend Forwardable
36
18
 
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dieses
4
+ module Application
5
+ module Sheets
6
+ class Table < Sheet
7
+ sheet :table, 'Table'
8
+
9
+ style linewidth: 0.2, color: '#007f80'
10
+
11
+ TABLES = {
12
+ '1': Param.(row: 2, col: 2),
13
+ '2': Param.(row: 5, col: 2),
14
+ '3': Param.(row: 4, col: 4),
15
+ '4': Param.(row: 10, col: 4)
16
+ }.freeze
17
+
18
+ variate table: TABLES.keys, unit: 1 do
19
+ self.name = table
20
+
21
+ param = TABLES[table]
22
+ self.desc = "Table #{table} (#{param.row}x#{param.col} table on A4 paper)"
23
+ end
24
+
25
+ def call # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
26
+ row, col = TABLES[param.table].to_a
27
+
28
+ cell_width, total_width = Ruler.divide(unit: param.unit, multiple: col, length: canvas.width)
29
+ cell_height, total_height = Ruler.divide(unit: param.unit, multiple: row, length: canvas.height)
30
+
31
+ draw unit: param.unit do
32
+ repeat row + 1 do
33
+ hline :hline, length: total_width
34
+ down cell_height
35
+ end
36
+ repeat row do
37
+ down cell_height / 2
38
+ hline :half, :dashed, :fine, length: total_width
39
+ down cell_height / 2
40
+ end
41
+ repeat col + 1 do
42
+ vline :vline, length: total_height
43
+ right cell_width
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -8,22 +8,22 @@ module Dieses
8
8
 
9
9
  style linewidth: 0.3, color: '#007f80'
10
10
 
11
- DENSITY = {
11
+ DENSITIES = {
12
12
  '1': Param.(row: 5, col: 3, width: 10, height: 10),
13
13
  '2': Param.(row: 4, col: 4, width: 8, height: 10),
14
14
  '3': Param.(row: 5, col: 5, width: 6, height: 8),
15
15
  '4': Param.(row: 6, col: 5, width: 6, height: 6)
16
16
  }.freeze
17
17
 
18
- variate density: DENSITY.keys, unit: 5 do
18
+ variate density: DENSITIES.keys, unit: 5 do
19
19
  self.name = density
20
20
 
21
- param = DENSITY[density]
21
+ param = DENSITIES[density]
22
22
  self.desc = "Density #{density} (#{param.row}x#{param.col} thumbnails on A4 paper)"
23
23
  end
24
24
 
25
25
  def call
26
- row, col, width, height = DENSITY[param.density].to_a
26
+ row, col, width, height = DENSITIES[param.density].to_a
27
27
 
28
28
  draw unit: param.unit do
29
29
  repeat row do
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dieses
4
+ module Support
5
+ class Ruler
6
+ def self.call(unit, multiple = 1)
7
+ new unit, (multiple || 1)
8
+ end
9
+
10
+ def self.divide(unit:, multiple:, length:)
11
+ ruler = new(unit, multiple)
12
+ [ruler.division(length), ruler.even(length)]
13
+ end
14
+
15
+ attr_reader :unit, :multiple
16
+
17
+ def initialize(unit, multiple = 1)
18
+ @unit = unit.to_f
19
+ @multiple = multiple.to_f
20
+ end
21
+
22
+ def major
23
+ @major ||= multiple * unit
24
+ end
25
+
26
+ def even(length)
27
+ major * division(length)
28
+ end
29
+
30
+ def division(length)
31
+ (length / major).to_i.to_f
32
+ end
33
+
34
+ def measure(n)
35
+ n * unit
36
+ end
37
+ end
38
+ end
39
+ end
@@ -7,3 +7,4 @@ require_relative 'support/enum'
7
7
  require_relative 'support/float'
8
8
  require_relative 'support/math'
9
9
  require_relative 'support/hash'
10
+ require_relative 'support/ruler'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dieses
4
- VERSION = '0.0.3'
4
+ VERSION = '0.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dieses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recai Oktaş
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-24 00:00:00.000000000 Z
11
+ date: 2021-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -176,6 +176,7 @@ files:
176
176
  - lib/dieses/application/sheets/print.rb
177
177
  - lib/dieses/application/sheets/ruled.rb
178
178
  - lib/dieses/application/sheets/spencerian.rb
179
+ - lib/dieses/application/sheets/table.rb
179
180
  - lib/dieses/application/sheets/thumbnail.rb
180
181
  - lib/dieses/error.rb
181
182
  - lib/dieses/geometry.rb
@@ -196,6 +197,7 @@ files:
196
197
  - lib/dieses/support/hash.rb
197
198
  - lib/dieses/support/kernel.rb
198
199
  - lib/dieses/support/math.rb
200
+ - lib/dieses/support/ruler.rb
199
201
  - lib/dieses/version.rb
200
202
  homepage: https://alaturka.github.io/dieses
201
203
  licenses: