whirled_peas 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/doc/components.md +0 -4
  4. data/doc/themes.md +35 -0
  5. data/examples/components.rb +2 -4
  6. data/examples/graph.rb +1 -1
  7. data/lib/whirled_peas/animator/debug_consumer.rb +2 -2
  8. data/lib/whirled_peas/animator/easing.rb +57 -0
  9. data/lib/whirled_peas/animator/frameset.rb +13 -8
  10. data/lib/whirled_peas/animator/producer.rb +7 -8
  11. data/lib/whirled_peas/animator/renderer_consumer.rb +7 -5
  12. data/lib/whirled_peas/command/frames.rb +1 -3
  13. data/lib/whirled_peas/command/play.rb +5 -7
  14. data/lib/whirled_peas/command/record.rb +1 -3
  15. data/lib/whirled_peas/command/still.rb +6 -2
  16. data/lib/whirled_peas/command/themes.rb +4 -3
  17. data/lib/whirled_peas/component/list_with_active.rb +1 -1
  18. data/lib/whirled_peas/config.rb +1 -8
  19. data/lib/whirled_peas/device/null_device.rb +1 -1
  20. data/lib/whirled_peas/device/output_file.rb +2 -2
  21. data/lib/whirled_peas/device/rendered_frame.rb +12 -0
  22. data/lib/whirled_peas/device/screen.rb +12 -8
  23. data/lib/whirled_peas/graphics/pixel_grid.rb +44 -0
  24. data/lib/whirled_peas/graphics/renderer.rb +4 -5
  25. data/lib/whirled_peas/settings/border.rb +1 -1
  26. data/lib/whirled_peas/utils/ansi.rb +4 -2
  27. data/lib/whirled_peas/utils/file_handler.rb +14 -9
  28. data/lib/whirled_peas/utils/formatted_string.rb +5 -3
  29. data/lib/whirled_peas/version.rb +1 -1
  30. data/screen_test/components/list_with_active/l2r_position_end.frame +1 -1
  31. data/screen_test/components/list_with_active/l2r_position_middle.frame +1 -1
  32. data/screen_test/components/list_with_active/l2r_position_start.frame +1 -1
  33. data/screen_test/components/list_with_active/l2r_separator.frame +1 -1
  34. data/screen_test/components/list_with_active/t2b_position_end.frame +1 -1
  35. data/screen_test/components/list_with_active/t2b_position_middle.frame +1 -1
  36. data/screen_test/components/list_with_active/t2b_position_start.frame +1 -1
  37. data/screen_test/components/list_with_active/t2b_separator.frame +1 -1
  38. data/screen_test/elements/box.frame +1 -1
  39. data/screen_test/elements/graph_asc.frame +1 -1
  40. data/screen_test/elements/graph_desc.frame +1 -1
  41. data/screen_test/elements/graph_horiz.frame +1 -1
  42. data/screen_test/elements/graph_sin.frame +1 -1
  43. data/screen_test/elements/grid.frame +1 -1
  44. data/screen_test/elements/screen_overflow_x.frame +1 -1
  45. data/screen_test/elements/screen_overflow_y.frame +1 -1
  46. data/screen_test/elements/text.frame +1 -1
  47. data/screen_test/elements/text_multiline.frame +1 -1
  48. data/screen_test/elements/theme.frame +1 -1
  49. data/screen_test/settings/align/box_around.frame +1 -1
  50. data/screen_test/settings/align/box_between.frame +1 -1
  51. data/screen_test/settings/align/box_center.frame +1 -1
  52. data/screen_test/settings/align/box_default.frame +1 -1
  53. data/screen_test/settings/align/box_evenly.frame +1 -1
  54. data/screen_test/settings/align/box_left.frame +1 -1
  55. data/screen_test/settings/align/box_right.frame +1 -1
  56. data/screen_test/settings/align/children_center.frame +1 -1
  57. data/screen_test/settings/align/children_left.frame +1 -1
  58. data/screen_test/settings/align/children_right.frame +1 -1
  59. data/screen_test/settings/align/grid_center.frame +1 -1
  60. data/screen_test/settings/align/grid_default.frame +1 -1
  61. data/screen_test/settings/align/grid_left.frame +1 -1
  62. data/screen_test/settings/align/grid_right.frame +1 -1
  63. data/screen_test/settings/ansi/bold.frame +1 -1
  64. data/screen_test/settings/ansi/color.frame +1 -1
  65. data/screen_test/settings/ansi/underline.frame +1 -1
  66. data/screen_test/settings/border.frame +1 -1
  67. data/screen_test/settings/content_start/box_bottom.frame +1 -1
  68. data/screen_test/settings/content_start/box_left.frame +1 -1
  69. data/screen_test/settings/content_start/box_left_negative.frame +1 -1
  70. data/screen_test/settings/content_start/box_right.frame +1 -1
  71. data/screen_test/settings/content_start/box_top.frame +1 -1
  72. data/screen_test/settings/content_start/box_top_negative.frame +1 -1
  73. data/screen_test/settings/content_start/grid_left.frame +1 -1
  74. data/screen_test/settings/content_start/grid_left_negative.frame +1 -1
  75. data/screen_test/settings/content_start/grid_top.frame +1 -1
  76. data/screen_test/settings/content_start/grid_top_negative.frame +1 -1
  77. data/screen_test/settings/flow/box_b2t.frame +1 -1
  78. data/screen_test/settings/flow/box_l2r.frame +1 -1
  79. data/screen_test/settings/flow/box_r2l.frame +1 -1
  80. data/screen_test/settings/flow/box_t2b.frame +1 -1
  81. data/screen_test/settings/flow/grid_b2t.frame +1 -1
  82. data/screen_test/settings/flow/grid_l2r.frame +1 -1
  83. data/screen_test/settings/flow/grid_r2l.frame +1 -1
  84. data/screen_test/settings/flow/grid_t2b.frame +1 -1
  85. data/screen_test/settings/height/box.frame +1 -1
  86. data/screen_test/settings/height/box_border_sizing.frame +1 -1
  87. data/screen_test/settings/height/grid.frame +1 -1
  88. data/screen_test/settings/height/overflow_box.frame +1 -1
  89. data/screen_test/settings/height/overflow_box_l2r.frame +1 -1
  90. data/screen_test/settings/height/overflow_box_t2b.frame +1 -1
  91. data/screen_test/settings/height/overflow_grid.frame +1 -1
  92. data/screen_test/settings/margin.frame +1 -1
  93. data/screen_test/settings/padding.frame +1 -1
  94. data/screen_test/settings/scroll/horiz_box.frame +1 -1
  95. data/screen_test/settings/scroll/vert_box.frame +1 -1
  96. data/screen_test/settings/title_font.frame +1 -1
  97. data/screen_test/settings/valign/box_around.frame +1 -1
  98. data/screen_test/settings/valign/box_between.frame +1 -1
  99. data/screen_test/settings/valign/box_bottom.frame +1 -1
  100. data/screen_test/settings/valign/box_default.frame +1 -1
  101. data/screen_test/settings/valign/box_evenly.frame +1 -1
  102. data/screen_test/settings/valign/box_middle.frame +1 -1
  103. data/screen_test/settings/valign/box_top.frame +1 -1
  104. data/screen_test/settings/valign/grid_bottom.frame +1 -1
  105. data/screen_test/settings/valign/grid_default.frame +1 -1
  106. data/screen_test/settings/valign/grid_middle.frame +1 -1
  107. data/screen_test/settings/valign/grid_top.frame +1 -1
  108. data/screen_test/settings/width/box_border_sizing.frame +1 -1
  109. data/screen_test/settings/width/box_content.frame +1 -1
  110. data/screen_test/settings/width/box_default.frame +1 -1
  111. data/screen_test/settings/width/grid.frame +1 -1
  112. data/screen_test/settings/width/overflow_align_center.frame +1 -1
  113. data/screen_test/settings/width/overflow_align_right.frame +1 -1
  114. data/screen_test/settings/width/overflow_box.frame +1 -1
  115. data/screen_test/settings/width/overflow_box_l2r.frame +1 -1
  116. data/screen_test/settings/width/overflow_box_t2b.frame +1 -1
  117. data/screen_test/settings/width/overflow_grid.frame +1 -1
  118. data/tools/whirled_peas/tools/screen_tester.rb +5 -2
  119. metadata +3 -5
  120. data/screen_test/components/list_with_active/l2r_active_color.frame +0 -1
  121. data/screen_test/components/list_with_active/l2r_active_color.rb +0 -18
  122. data/screen_test/components/list_with_active/t2b_active_color.frame +0 -1
  123. data/screen_test/components/list_with_active/t2b_active_color.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16dc58df5e4b6dbb2bdf51d95841d02bc9172f1e116efd8afd0633df592a7c8e
4
- data.tar.gz: 0a2a14b167b502954a9ec2e58d762b32b60a2ab62e136d976b7d1d70e5630189
3
+ metadata.gz: 1c57dd3e70f4d79c41731d220f9cb3f7fec0a3e554a715f7da556dec5e0a5cde
4
+ data.tar.gz: 736d62121796101237e9aaa4fc5f37b0fe59f6d8c7670b149e63e0faf0ff9f3e
5
5
  SHA512:
6
- metadata.gz: 94d96284d6b3201496456fad7b464f3b71ab02c51878817e81856331fa3cb763a36383198ffe2be31f2e9747580656cb13a587b630f4f5866cd40340c1617744
7
- data.tar.gz: 51e6271630fda2450af38f59f9c8d888b2b9338efacb6f8c7664393b1fdea8e616f00e20eec47b8bba59c25db510cade9a359119e06d02f8ac9c8de79f372664
6
+ metadata.gz: 1823dc0eba84af3a78992c349c1d922bfd7837452133a0e1b6e35de2fe1d94ad589b0eda8cf5c7a70ae41ec92345ef8dcde6c2e0eeb63193de806582a5d2578a
7
+ data.tar.gz: d10d355b30e2cc1a0cc15413c5681b04135ec7f53a2e20e9a4ea307a8ae9bd0b69fb04cacb494dcfee8b7a9d473ae852173d140a708d1bb04210084f824acd99
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.12.0- 2021-01-31
4
+
5
+ - [f218ed5](https://github.com/tcollier/whirled_peas/tree/f218ed5a8bbc20fc332a42ad9720467784a916e2): Optimize rendered frames
6
+
3
7
  ## v0.11.1 - 2021-01-31
4
8
 
5
9
  - [36e48cf](https://github.com/tcollier/whirled_peas/tree/36e48cf6731706539c6c41ce0ef66e86c62380a5): Add highlight colors and border style to theme
@@ -33,8 +33,6 @@ This component takes the following options
33
33
 
34
34
  #### Optional
35
35
 
36
- - `active_bg_color` - background color of the active item
37
- - `active_color` - text color of the active item
38
36
  - `flow` - `:l2r` or `:t2b`
39
37
  - `separator` - string used to separate items in the list, e.g. `", "` for a horizontal list or `"----"` for a vertical list
40
38
  - `viewport_size` - number of characters of the viewport in the flow direction
@@ -48,8 +46,6 @@ WhirledPeas.template do |composer, settings|
48
46
  component.separator = ', '
49
47
  component.active_index = active
50
48
  component.viewport_size = 27
51
- component.active_color = :blue
52
- component.active_bg_color = :bright_yellow
53
49
  end
54
50
  end
55
51
  ```
@@ -13,3 +13,38 @@ end
13
13
  ```
14
14
 
15
15
  Theme settings will be used as default settings throughout the template, however theme settings can be overridden on any element.
16
+
17
+ ### Theme Settings
18
+
19
+ The following theme settings override the existing default settings for all elements.
20
+
21
+ - `axis_color` - axis color for graphs (defaults to `border_color`)
22
+ - `bg_color` - background color (defaults to system color)
23
+ - `border_color` - border color (defaults to `color`)
24
+ - `border_style` - border style (defaults to `bold`)
25
+ - `color` - text color (defaults to system color)
26
+
27
+ The following theme settings provide new options that can be applied to existing settings. E.g.
28
+
29
+ ```ruby
30
+ WhirledPeas.register_theme(:my_theme) do |theme|
31
+ theme.highlight_bg_color = :bright_white
32
+ theme.highlight_color = :red
33
+ # ...
34
+ end
35
+
36
+ WhirledPeas.template(:my_theme) do |composer, settings|
37
+ # ...
38
+ composer.add_text do |composer, settings|
39
+ composer.bg_color = :highlight
40
+ composer.color = :highlight
41
+ "This Is Important!!!"
42
+ end
43
+ end
44
+ ```
45
+
46
+ - `highlight_bg_color` - provides a new `:highlight` option that can be applied to `bg_color` settings (defaults to `color`)
47
+ - `highlight_color` - provides a new `:highlight` option that can be applied to `color` settings (defaults to `bg_color`)
48
+ - `title_font` - provides a new `:theme` option that can be applied to `title_font` settings (defaults to system default)
49
+
50
+ Note: the defaults for the `highlight_bg_color` and `highlight_color` options result in inverting the background and text colors.
@@ -13,8 +13,6 @@ class TemplateFactory
13
13
  component.separator = ', '
14
14
  component.active_index = active
15
15
  component.viewport_size = 27
16
- component.active_color = :green
17
- component.active_bg_color = :yellow
18
16
  end
19
17
  end
20
18
  end
@@ -23,9 +21,9 @@ end
23
21
  class Application
24
22
  def start(producer)
25
23
  producer.frameset(5, easing: :parametric) do |fs|
26
- ITEMS.length.times { |i| fs.add_frame('intro', args: { active: i }) }
24
+ TemplateFactory::ITEMS.length.times { |i| fs.add_frame('intro', args: { active: i }) }
27
25
  end
28
- producer.add_frame('hold', duration: 1, args: { active: ITEMS.length - 1 })
26
+ producer.add_frame('hold', duration: 1, args: { active: TemplateFactory::ITEMS.length - 1 })
29
27
  end
30
28
  end
31
29
 
@@ -32,7 +32,7 @@ class TemplateFactory
32
32
  settings.color = :bright_blue
33
33
  settings.height = 15
34
34
  INNER_WIDTH.times.map do |i|
35
- easing.ease(i.to_f / (INNER_WIDTH - 1))
35
+ easing.invert(i.to_f / (INNER_WIDTH - 1))
36
36
  end
37
37
  end
38
38
  end
@@ -4,8 +4,8 @@ module WhirledPeas
4
4
  def add_frameset(frameset)
5
5
  require 'json'
6
6
 
7
- frameset.each_frame do |frame, args|
8
- puts [frame, *(JSON.generate(args) unless args.empty?)].join(' ')
7
+ frameset.each_frame do |frame, duration, args|
8
+ puts [frame, "duration=#{duration}", *(JSON.generate(args) unless args.empty?)].join(' ')
9
9
  end
10
10
  end
11
11
 
@@ -21,6 +21,10 @@ module WhirledPeas
21
21
 
22
22
  EFFECTS = %i[in out in_out]
23
23
 
24
+ INVERSE_MAX_ITERATIONS = 10
25
+ INVERSE_DELTA = 0.0001
26
+ INVERSE_EPSILON = 0.00001
27
+
24
28
  def initialize(easing=:linear, effect=:in_out)
25
29
  unless EASING.key?(easing)
26
30
  raise ArgumentError,
@@ -45,6 +49,56 @@ module WhirledPeas
45
49
  end
46
50
  end
47
51
 
52
+ def invert(target)
53
+ ease_fn = case effect
54
+ when :in
55
+ proc { |v| ease_in(v) }
56
+ when :out
57
+ proc { |v| ease_out(v) }
58
+ else
59
+ proc { |v| ease_in_out(v) }
60
+ end
61
+
62
+ # Use Newton's method(!!) to find the inverse values of the easing function for the
63
+ # specified target. Make an initial guess that is equal to the target and see how
64
+ # far off the eased value is from the target. If we are close enough (as dictated by
65
+ # INVERSE_EPSILON constant), then we return our guess. If we aren't close enough, then
66
+ # find the slope of the eased line (approximated with a small step of INVERSE_DELTA
67
+ # along the x-axis). The intersection of the slope and target will give us the value
68
+ # of our next guess.
69
+ #
70
+ # Since most easing functions only vary slightly from the identity line (y = x), we
71
+ # can typically get the eased guess within epsilon of the target in a few iterations,
72
+ # however only iterate at most INVERSE_MAX_ITERATIONS times.
73
+ #
74
+ # ┃ ......
75
+ # ┃ ...
76
+ # target -┃------------+ ...
77
+ # ┃ /.|..
78
+ # ┃ ../. |
79
+ # ┃ ... | |
80
+ # ┃... | |
81
+ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━
82
+ # | |
83
+ # guess next guess
84
+ #
85
+ # IMPORTANT: This method only works well for monotonic easing functions
86
+
87
+ # Pick the target as the first guess. For targets of 0 and 1 (and 0.5 for ease_in_out),
88
+ # this guess will be the exact value that yields the target. For other values, the
89
+ # eased guess will generally be close to the target.
90
+ guess = target
91
+ INVERSE_MAX_ITERATIONS.times do |i|
92
+ eased_guess = ease_fn.call(guess)
93
+ error = eased_guess - target
94
+ break if error.abs < INVERSE_EPSILON
95
+ next_eased_guess = ease_fn.call(guess + INVERSE_DELTA)
96
+ delta_eased = next_eased_guess - eased_guess
97
+ guess -= INVERSE_DELTA * error / delta_eased
98
+ end
99
+ guess
100
+ end
101
+
48
102
  private
49
103
 
50
104
  attr_reader :easing, :effect
@@ -60,6 +114,9 @@ module WhirledPeas
60
114
  1 - EASING[easing].call(1 - value)
61
115
  end
62
116
 
117
+ # Ease in/ease out
118
+ #
119
+ # @see https://www.youtube.com/watch?v=5WPbqYoz9HA
63
120
  def ease_in_out(value)
64
121
  if value < 0.5
65
122
  ease_in(value * 2) / 2
@@ -4,8 +4,8 @@ require_relative 'frame'
4
4
  module WhirledPeas
5
5
  module Animator
6
6
  class Frameset
7
- def initialize(frame_slots, easing, effect)
8
- @frame_slots = frame_slots
7
+ def initialize(duration, easing, effect)
8
+ @duration = duration
9
9
  @easing = Easing.new(easing, effect)
10
10
  @frames = []
11
11
  end
@@ -16,17 +16,22 @@ module WhirledPeas
16
16
 
17
17
  # Yield each frame in an "eased" order
18
18
  def each_frame(&block)
19
- frame_slots.times do |i|
20
- input = i.to_f / (frame_slots - 1)
21
- eased_value = @easing.ease(input)
22
- index = (eased_value * (frames.length - 1)).floor
23
- yield *frames[index]
19
+ return if frames.length == 0
20
+ if frames.length == 1
21
+ frame, args = frames[0]
22
+ yield frame, duration, args
23
+ else
24
+ frames.each.with_index do |(frame, args), index|
25
+ curr_ease = @easing.invert(index.to_f / frames.length)
26
+ next_ease = @easing.invert((index + 1).to_f / frames.length)
27
+ yield frame, duration * (next_ease - curr_ease), args
28
+ end
24
29
  end
25
30
  end
26
31
 
27
32
  private
28
33
 
29
- attr_reader :frame_slots, :easing, :frames
34
+ attr_reader :duration, :easing, :frames
30
35
  end
31
36
  private_constant :Frameset
32
37
  end
@@ -4,32 +4,31 @@ require_relative 'frameset'
4
4
  module WhirledPeas
5
5
  module Animator
6
6
  class Producer
7
- def self.produce(consumer, refresh_rate)
8
- producer = new(consumer, refresh_rate)
7
+ def self.produce(consumer)
8
+ producer = new(consumer)
9
9
  yield producer
10
10
  consumer.process
11
11
  end
12
12
 
13
- def initialize(consumer, refresh_rate)
13
+ def initialize(consumer)
14
14
  @consumer = consumer
15
- @refresh_rate = refresh_rate
16
15
  end
17
16
 
18
- def add_frame(name, duration: nil, args: {})
19
- frameset(duration || 1 / refresh_rate) do |fs|
17
+ def add_frame(name, duration:, args: {})
18
+ frameset(duration) do |fs|
20
19
  fs.add_frame(name, args: args)
21
20
  end
22
21
  end
23
22
 
24
23
  def frameset(duration, easing: :linear, effect: :in_out, &block)
25
- fs = Frameset.new((duration * refresh_rate).round, easing, effect)
24
+ fs = Frameset.new(duration, easing, effect)
26
25
  yield fs
27
26
  consumer.add_frameset(fs)
28
27
  end
29
28
 
30
29
  private
31
30
 
32
- attr_reader :consumer, :refresh_rate
31
+ attr_reader :consumer
33
32
  end
34
33
  end
35
34
  end
@@ -1,5 +1,6 @@
1
1
  require 'whirled_peas/graphics/renderer'
2
2
  require 'whirled_peas/utils/ansi'
3
+ require 'whirled_peas/device/rendered_frame'
3
4
 
4
5
  module WhirledPeas
5
6
  module Animator
@@ -9,23 +10,24 @@ module WhirledPeas
9
10
  @device = device
10
11
  @width = width
11
12
  @height = height
12
- @renders = []
13
+ @rendered_frames = []
13
14
  end
14
15
 
15
16
  def add_frameset(frameset)
16
- frameset.each_frame do |frame, args|
17
+ frameset.each_frame do |frame, duration, args|
17
18
  template = template_factory.build(frame, args)
18
- renders << Graphics::Renderer.new(template, width, height).paint
19
+ strokes = Graphics::Renderer.new(template, width, height).paint
20
+ rendered_frames << Device::RenderedFrame.new(strokes, duration)
19
21
  end
20
22
  end
21
23
 
22
24
  def process
23
- device.handle_renders(renders)
25
+ device.handle_rendered_frames(rendered_frames)
24
26
  end
25
27
 
26
28
  private
27
29
 
28
- attr_reader :template_factory, :device, :width, :height, :renders
30
+ attr_reader :template_factory, :device, :width, :height, :rendered_frames
29
31
  end
30
32
  end
31
33
  end
@@ -13,9 +13,7 @@ module WhirledPeas
13
13
  require 'whirled_peas/animator/debug_consumer'
14
14
  require 'whirled_peas/animator/producer'
15
15
 
16
- Animator::Producer.produce(
17
- Animator::DebugConsumer.new, WhirledPeas.config.refresh_rate
18
- ) do |producer|
16
+ Animator::Producer.produce(Animator::DebugConsumer.new) do |producer|
19
17
  config.application.start(producer)
20
18
  end
21
19
  end
@@ -28,13 +28,11 @@ module WhirledPeas
28
28
  Utils::Ansi.with_screen do |width, height|
29
29
  consumer = Animator::RendererConsumer.new(
30
30
  WhirledPeas.config.template_factory,
31
- Device::Screen.new(WhirledPeas.config.refresh_rate),
31
+ Device::Screen.new,
32
32
  width,
33
33
  height
34
34
  )
35
- Animator::Producer.produce(
36
- consumer, WhirledPeas.config.refresh_rate
37
- ) do |producer|
35
+ Animator::Producer.produce(consumer) do |producer|
38
36
  config.application.start(producer)
39
37
  end
40
38
  end
@@ -60,9 +58,9 @@ module WhirledPeas
60
58
  require 'whirled_peas/utils/file_handler'
61
59
 
62
60
  Utils::Ansi.with_screen do
63
- screen = Device::Screen.new(WhirledPeas.config.refresh_rate)
64
- renders = Utils::FileHandler.read(wpz_file)
65
- screen.handle_renders(renders)
61
+ screen = Device::Screen.new
62
+ rendered_frames = Utils::FileHandler.read(wpz_file)
63
+ screen.handle_rendered_frames(rendered_frames)
66
64
  end
67
65
  end
68
66
 
@@ -21,9 +21,7 @@ module WhirledPeas
21
21
  width,
22
22
  height
23
23
  )
24
- Animator::Producer.produce(
25
- consumer, WhirledPeas.config.refresh_rate
26
- ) do |producer|
24
+ Animator::Producer.produce(consumer) do |producer|
27
25
  config.application.start(producer)
28
26
  end
29
27
  end
@@ -1,3 +1,5 @@
1
+ require 'whirled_peas/device/rendered_frame'
2
+
1
3
  require_relative 'frame_command'
2
4
 
3
5
  module WhirledPeas
@@ -16,12 +18,14 @@ module WhirledPeas
16
18
  require 'whirled_peas/utils/ansi'
17
19
 
18
20
  Utils::Ansi.with_screen do |width, height|
19
- rendered = Graphics::Renderer.new(
21
+ strokes = Graphics::Renderer.new(
20
22
  WhirledPeas.config.template_factory.build(frame, frame_args),
21
23
  width,
22
24
  height
23
25
  ).paint
24
- Device::Screen.new(10000).handle_renders([rendered])
26
+ Device::Screen.new.handle_rendered_frames(
27
+ [Device::RenderedFrame.new(strokes, 0)]
28
+ )
25
29
  end
26
30
  end
27
31
  end
@@ -35,12 +35,14 @@ module WhirledPeas
35
35
  end
36
36
  end
37
37
  Utils::Ansi.with_screen do |width, height|
38
- rendered = Graphics::Renderer.new(
38
+ strokes = Graphics::Renderer.new(
39
39
  template,
40
40
  80,
41
41
  30
42
42
  ).paint
43
- Device::Screen.new(10000).handle_renders([rendered])
43
+ Device::Screen.new.handle_rendered_frames(
44
+ [Device::RenderedFrame.new(strokes, 0)]
45
+ )
44
46
  end
45
47
 
46
48
  if index < theme_names.length - 1
@@ -62,7 +64,6 @@ module WhirledPeas
62
64
  def validate!
63
65
  super
64
66
  config_file = args.shift
65
- @error_text = 'hi'
66
67
  unless config_file.nil?
67
68
  # We think we have a valid ruby config file, set the absolute path to @config
68
69
  @config_file = config_file[0] == '/' ? config_file : File.join(Dir.pwd, config_file)
@@ -32,7 +32,7 @@ module WhirledPeas
32
32
  def compose(composer, settings)
33
33
  %i[items active_index].each do |required_attr|
34
34
  if send(required_attr).nil?
35
- raise ArugmentError, "Require field #{required_attr} missing"
35
+ raise ArgumentError, "Required field #{required_attr} missing"
36
36
  end
37
37
  end
38
38
 
@@ -2,9 +2,6 @@ require 'logger'
2
2
 
3
3
  module WhirledPeas
4
4
  class Config
5
- # Refreshed rate measured in frames per second
6
- DEFAULT_REFRESH_RATE = 30
7
-
8
5
  DEFAULT_LOG_LEVEL = Logger::INFO
9
6
  DEFAULT_LOG_FILE = 'whirled_peas.log'
10
7
 
@@ -35,7 +32,7 @@ module WhirledPeas
35
32
  "[#{severity}] #{datetime.strftime('%Y-%m-%dT%H:%M:%S.%L')} (#{progname}) - #{msg}\n"
36
33
  end
37
34
 
38
- attr_writer :application, :template_factory, :refresh_rate, :log_level, :log_formatter, :log_file
35
+ attr_writer :application, :template_factory, :log_level, :log_formatter, :log_file
39
36
 
40
37
  def application
41
38
  unless @application
@@ -51,10 +48,6 @@ module WhirledPeas
51
48
  @template_factory
52
49
  end
53
50
 
54
- def refresh_rate
55
- @refresh_rate || DEFAULT_REFRESH_RATE
56
- end
57
-
58
51
  def log_level
59
52
  @log_level || DEFAULT_LOG_LEVEL
60
53
  end