sscharter 0.2.1 → 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 +53 -25
- 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
|
|
@@ -408,44 +409,57 @@ class Sunniesnow::Charter
|
|
408
409
|
end
|
409
410
|
|
410
411
|
def tip_point_chain *args, preserve_beat: true, **opts, &block
|
411
|
-
raise ArgumentError, 'no block given' unless block
|
412
412
|
tip_point :chain, *args, **opts do
|
413
413
|
group preserve_beat: preserve_beat, &block
|
414
|
-
end
|
414
|
+
end#.tap { @tip_point_peak += 1 }
|
415
415
|
end
|
416
416
|
alias tp_chain tip_point_chain
|
417
417
|
|
418
418
|
def tip_point_drop *args, preserve_beat: true, **opts, &block
|
419
|
-
raise ArgumentError, 'no block given' unless block
|
420
419
|
tip_point :drop, *args, **opts do
|
421
420
|
group preserve_beat: preserve_beat, &block
|
422
421
|
end
|
423
422
|
end
|
424
423
|
alias tp_drop tip_point_drop
|
425
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
|
+
|
426
432
|
def group preserve_beat: true, &block
|
427
433
|
raise ArgumentError, 'no block given' unless block
|
428
434
|
@groups.push result = []
|
429
|
-
|
435
|
+
unless preserve_beat
|
436
|
+
last_beat = @current_beat
|
437
|
+
last_offset = @current_offset
|
438
|
+
last_bpm_changes = @bpm_changes
|
439
|
+
end
|
430
440
|
instance_eval &block
|
431
|
-
|
441
|
+
unless preserve_beat
|
442
|
+
@current_beat = last_beat
|
443
|
+
@current_offset = last_offset
|
444
|
+
@bpm_changes = last_bpm_changes
|
445
|
+
end
|
432
446
|
@groups.delete_if { result.equal? _1 }
|
433
447
|
result
|
434
448
|
end
|
435
449
|
|
436
|
-
def clear_tip_point
|
437
|
-
TipPointError.ensure @tip_point_mode, :chain, :drop
|
438
|
-
@tip_point_start_to_add = nil
|
439
|
-
@tip_point_mode = :none
|
440
|
-
end
|
441
|
-
|
442
450
|
def tip_point mode, *args, **opts, &block
|
443
|
-
|
444
|
-
|
445
|
-
|
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
|
446
459
|
result = block.()
|
447
|
-
@
|
448
|
-
@
|
460
|
+
@tip_point_start_to_add_stack.pop
|
461
|
+
@tip_point_mode_stack.pop
|
462
|
+
@current_tip_point_stack.pop
|
449
463
|
result
|
450
464
|
end
|
451
465
|
|
@@ -454,13 +468,14 @@ class Sunniesnow::Charter
|
|
454
468
|
event = Event.new type, @current_beat, duration_beats, @bpm_changes, **properties
|
455
469
|
@groups.each { _1.push event }
|
456
470
|
return event unless event.tip_pointable?
|
457
|
-
case @
|
471
|
+
case @tip_point_mode_stack.last
|
458
472
|
when :chain
|
459
473
|
push_tip_point_start event
|
460
|
-
@
|
474
|
+
@tip_point_start_to_add_stack[-1] = nil
|
461
475
|
when :drop
|
462
476
|
push_tip_point_start event
|
463
|
-
@
|
477
|
+
@current_tip_point_stack[-1] = @tip_point_peak
|
478
|
+
@tip_point_peak += 1
|
464
479
|
when :none
|
465
480
|
# pass
|
466
481
|
end
|
@@ -468,8 +483,8 @@ class Sunniesnow::Charter
|
|
468
483
|
end
|
469
484
|
|
470
485
|
def push_tip_point_start start_event
|
471
|
-
start_event[:tip_point] = @
|
472
|
-
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
|
473
488
|
@groups.each { _1.push tip_point_start } if tip_point_start
|
474
489
|
end
|
475
490
|
|
@@ -530,13 +545,14 @@ class Sunniesnow::Charter
|
|
530
545
|
end
|
531
546
|
if direction.is_a? Symbol
|
532
547
|
direction = DIRECTIONS[direction]
|
548
|
+
raise ArgumentError, "unknown direction #{direction}" unless direction
|
533
549
|
elsif direction.is_a? Numeric
|
534
550
|
warn 'Are you using degrees as angle unit instead of radians?' if direction != 0 && direction % 45 == 0
|
535
551
|
direction = direction.to_f
|
536
552
|
else
|
537
553
|
raise ArgumentError, 'direction must be a symbol or a number'
|
538
554
|
end
|
539
|
-
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
|
540
556
|
end
|
541
557
|
alias f flick
|
542
558
|
|
@@ -554,11 +570,23 @@ class Sunniesnow::Charter
|
|
554
570
|
end
|
555
571
|
|
556
572
|
def big_text duration_beats = 0, text
|
573
|
+
unless duration_beats.is_a? Numeric
|
574
|
+
raise ArgumentError, 'duration_beats must be a number'
|
575
|
+
end
|
576
|
+
if duration_beats < 0
|
577
|
+
raise ArgumentError, 'duration must be non-negative'
|
578
|
+
end
|
579
|
+
if duration_beats.is_a? Float
|
580
|
+
warn 'Rational is recommended over Float for duration_beats'
|
581
|
+
end
|
557
582
|
event :big_text, duration_beats.to_r, text: text.to_s
|
558
583
|
end
|
559
584
|
|
560
585
|
%i[grid hexagon checkerboard diamond_grid pentagon turntable].each do |method_name|
|
561
586
|
define_method method_name do |duration_beats = 0|
|
587
|
+
unless duration_beats.is_a? Numeric
|
588
|
+
raise ArgumentError, 'duration_beats must be a number'
|
589
|
+
end
|
562
590
|
if duration_beats < 0
|
563
591
|
raise ArgumentError, 'duration must be non-negative'
|
564
592
|
end
|
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
|