sscharter 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sscharter/version.rb +1 -1
- data/lib/sscharter.rb +30 -21
- data/tutorial/tutorial.md +21 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e016849d4638b4a228dbefaf3d770a571c52b5d23b8a7a4e19c344f6fd91d9e
|
4
|
+
data.tar.gz: 7210246753c60a6f5873ae82ba9d9abdcea3e8301b08ba92ab6231f01060ef9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d79d0dd40fa573ea967223a8e5573f48e9e019374cfc294070efff83fe71f6732fdbaa81ce3f249987a9875e41fdeb2424f5ff6eac6fb9a16ca8c8769b30cc61
|
7
|
+
data.tar.gz: 87f8f7e56ef2ecc61e07fc09d35baad818b6105e5ea193766c5599c1041fd936b877f8e3f1173f0ec13f39d178bf09911893a43b958d1b21f58bebb7d1810c4a
|
data/Gemfile.lock
CHANGED
data/lib/sscharter/version.rb
CHANGED
data/lib/sscharter.rb
CHANGED
@@ -312,10 +312,11 @@ class Sunniesnow::Charter
|
|
312
312
|
@current_offset = nil
|
313
313
|
@current_beat = nil
|
314
314
|
@bpm_changes = nil
|
315
|
-
@
|
316
|
-
@
|
315
|
+
@tip_point_mode_stack = [:none]
|
316
|
+
@current_tip_point_stack = []
|
317
|
+
@tip_point_peak = 0
|
317
318
|
@current_duplicate = 0
|
318
|
-
@
|
319
|
+
@tip_point_start_to_add_stack = [nil]
|
319
320
|
@groups = [@events]
|
320
321
|
end
|
321
322
|
|
@@ -410,7 +411,7 @@ class Sunniesnow::Charter
|
|
410
411
|
def tip_point_chain *args, preserve_beat: true, **opts, &block
|
411
412
|
tip_point :chain, *args, **opts do
|
412
413
|
group preserve_beat: preserve_beat, &block
|
413
|
-
end
|
414
|
+
end#.tap { @tip_point_peak += 1 }
|
414
415
|
end
|
415
416
|
alias tp_chain tip_point_chain
|
416
417
|
|
@@ -421,6 +422,13 @@ class Sunniesnow::Charter
|
|
421
422
|
end
|
422
423
|
alias tp_drop tip_point_drop
|
423
424
|
|
425
|
+
def tip_point_none preserve_beat: true, &block
|
426
|
+
tip_point :none do
|
427
|
+
group preserve_beat: preserve_beat, &block
|
428
|
+
end
|
429
|
+
end
|
430
|
+
alias tp_none tip_point_none
|
431
|
+
|
424
432
|
def group preserve_beat: true, &block
|
425
433
|
raise ArgumentError, 'no block given' unless block
|
426
434
|
@groups.push result = []
|
@@ -439,19 +447,19 @@ class Sunniesnow::Charter
|
|
439
447
|
result
|
440
448
|
end
|
441
449
|
|
442
|
-
def clear_tip_point
|
443
|
-
TipPointError.ensure @tip_point_mode, :chain, :drop
|
444
|
-
@tip_point_start_to_add = nil
|
445
|
-
@tip_point_mode = :none
|
446
|
-
end
|
447
|
-
|
448
450
|
def tip_point mode, *args, **opts, &block
|
449
|
-
|
450
|
-
|
451
|
-
|
451
|
+
@tip_point_mode_stack.push mode
|
452
|
+
if mode == :none
|
453
|
+
@current_tip_point_stack.push nil
|
454
|
+
else
|
455
|
+
@tip_point_start_to_add_stack.push TipPointStart.new *args, **opts
|
456
|
+
@current_tip_point_stack.push @tip_point_peak
|
457
|
+
@tip_point_peak += 1
|
458
|
+
end
|
452
459
|
result = block.()
|
453
|
-
@
|
454
|
-
@
|
460
|
+
@tip_point_start_to_add_stack.pop
|
461
|
+
@tip_point_mode_stack.pop
|
462
|
+
@current_tip_point_stack.pop
|
455
463
|
result
|
456
464
|
end
|
457
465
|
|
@@ -460,13 +468,14 @@ class Sunniesnow::Charter
|
|
460
468
|
event = Event.new type, @current_beat, duration_beats, @bpm_changes, **properties
|
461
469
|
@groups.each { _1.push event }
|
462
470
|
return event unless event.tip_pointable?
|
463
|
-
case @
|
471
|
+
case @tip_point_mode_stack.last
|
464
472
|
when :chain
|
465
473
|
push_tip_point_start event
|
466
|
-
@
|
474
|
+
@tip_point_start_to_add_stack[-1] = nil
|
467
475
|
when :drop
|
468
476
|
push_tip_point_start event
|
469
|
-
@
|
477
|
+
@current_tip_point_stack[-1] = @tip_point_peak
|
478
|
+
@tip_point_peak += 1
|
470
479
|
when :none
|
471
480
|
# pass
|
472
481
|
end
|
@@ -474,8 +483,8 @@ class Sunniesnow::Charter
|
|
474
483
|
end
|
475
484
|
|
476
485
|
def push_tip_point_start start_event
|
477
|
-
start_event[:tip_point] = @
|
478
|
-
tip_point_start = @
|
486
|
+
start_event[:tip_point] = @current_tip_point_stack.last.to_s
|
487
|
+
tip_point_start = @tip_point_start_to_add_stack.last&.get_start_placeholder start_event
|
479
488
|
@groups.each { _1.push tip_point_start } if tip_point_start
|
480
489
|
end
|
481
490
|
|
@@ -543,7 +552,7 @@ class Sunniesnow::Charter
|
|
543
552
|
else
|
544
553
|
raise ArgumentError, 'direction must be a symbol or a number'
|
545
554
|
end
|
546
|
-
event :flick, x: x, y: y, angle: direction, text: text.to_s
|
555
|
+
event :flick, x: x.to_f, y: y.to_f, angle: direction, text: text.to_s
|
547
556
|
end
|
548
557
|
alias f flick
|
549
558
|
|
data/tutorial/tutorial.md
CHANGED
@@ -701,6 +701,13 @@ end
|
|
701
701
|
transform(notes) { translate 25, 25 }
|
702
702
|
```
|
703
703
|
|
704
|
+
> Because argument of `rotate` is in radians,
|
705
|
+
> you may want to use the Math constant $\pi$.
|
706
|
+
> In Ruby, it is `Math::PI`.
|
707
|
+
> If you use this constant a lot, you may want to write `include Math`
|
708
|
+
> at the beginning of the source codes file so that you can just write `PI`
|
709
|
+
> instead of `Math::PI` every time.
|
710
|
+
|
704
711
|
### Navigate among beats
|
705
712
|
|
706
713
|
You have already learned how to use `beat` to proceed the current beat
|
@@ -853,33 +860,46 @@ in the call of `tip_point_chain` or `tip_point_drop`.
|
|
853
860
|
The beat speed may be specified as a float number,
|
854
861
|
and this is the only case where something related to beats is not preferred to be specified as a rational number.
|
855
862
|
|
856
|
-
|
863
|
+
Besides the two methods `tip_point_chain` and `tip_point_drop`,
|
864
|
+
there is another method `tip_point_none` (abbreviated as `tp_none`)
|
865
|
+
for you to specify that those events in the code block are not connected by tip points.
|
866
|
+
This is useful when you nest those methods inside each other.
|
867
|
+
Different from `tip_point_chain` and `tip_point_drop`,
|
868
|
+
the method `tip_point_none` does not take any arguments
|
869
|
+
(besides `preserve_beat`, which will be mentioned later).
|
870
|
+
|
871
|
+
We can summarize all of them in the following table:
|
857
872
|
|
858
873
|
<table>
|
859
874
|
<tr>
|
860
875
|
<th>Method</th>
|
861
876
|
<td><code>tip_point_chain</code></td>
|
862
877
|
<td><code>tip_point_drop</code></td>
|
878
|
+
<td><code>tip_point_none</code></td>
|
863
879
|
</tr>
|
864
880
|
<tr>
|
865
881
|
<th><code>relative_time</code></th>
|
866
882
|
<td><code>tip_point_chain x=0, y=0, relative_time=0.0, relative: true</code></td>
|
867
883
|
<td><code>tip_point_drop x=0, y=0, relative_time=0.0, relative: true</code></td>
|
884
|
+
<td></td>
|
868
885
|
</tr>
|
869
886
|
<tr>
|
870
887
|
<th><code>speed</code></th>
|
871
888
|
<td><code>tip_point_chain x=0, y=0, relative: true, speed:</code></td>
|
872
889
|
<td><code>tip_point_drop x=0, y=0, relative: true, speed:</code></td>
|
890
|
+
<td></td>
|
873
891
|
</tr>
|
874
892
|
<tr>
|
875
893
|
<th><code>relative_beat</code></th>
|
876
894
|
<td><code>tip_point_chain x=0, y=0, relative: true, relative_beat:</code></td>
|
877
895
|
<td><code>tip_point_drop x=0, y=0, relative: true, relative_beat:</code></td>
|
896
|
+
<td></td>
|
878
897
|
</tr>
|
879
898
|
<tr>
|
880
899
|
<th><code>beat_speed</code></th>
|
881
900
|
<td><code>tip_point_chain x=0, y=0, relative: true, beat_speed:</code></td>
|
882
901
|
<td><code>tip_point_drop x=0, y=0, relative: true, beat_speed:</code></td>
|
902
|
+
<td></td>
|
883
903
|
</tr>
|
884
904
|
</table>
|
885
905
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sscharter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ulysses Zhan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|