reight 0.1.6 → 0.1.7
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.
- checksums.yaml +4 -4
- data/ChangeLog.md +52 -0
- data/Rakefile +4 -1
- data/VERSION +1 -1
- data/lib/reight/all.rb +6 -2
- data/lib/reight/app/map/brush.rb +1 -1
- data/lib/reight/app/map/brush_base.rb +3 -3
- data/lib/reight/app/map/canvas.rb +4 -13
- data/lib/reight/app/map/chips.rb +6 -2
- data/lib/reight/app/map/editor.rb +4 -4
- data/lib/reight/app/map/line.rb +5 -5
- data/lib/reight/app/map/rect.rb +2 -2
- data/lib/reight/app/navigator.rb +27 -27
- data/lib/reight/app/runner.rb +106 -84
- data/lib/reight/app/sound/brush.rb +32 -0
- data/lib/reight/app/sound/canvas.rb +190 -0
- data/lib/reight/app/sound/editor.rb +170 -10
- data/lib/reight/app/sound/eraser.rb +28 -0
- data/lib/reight/app/sound/tool.rb +29 -0
- data/lib/reight/app/sound.rb +4 -0
- data/lib/reight/app/sprite/canvas.rb +18 -15
- data/lib/reight/app/sprite/chips.rb +6 -1
- data/lib/reight/app/sprite/color.rb +3 -1
- data/lib/reight/app/sprite/editor.rb +15 -28
- data/lib/reight/app/sprite/line.rb +1 -1
- data/lib/reight/app/sprite/shape.rb +1 -1
- data/lib/reight/app.rb +19 -1
- data/lib/reight/button.rb +7 -4
- data/lib/reight/chip.rb +24 -6
- data/lib/reight/context.rb +168 -0
- data/lib/reight/helpers.rb +2 -2
- data/lib/reight/index.rb +76 -0
- data/lib/reight/map.rb +131 -11
- data/lib/reight/project.rb +34 -6
- data/lib/reight/reight.rb +1 -3
- data/lib/reight/sound.rb +238 -0
- data/lib/reight/sprite.rb +42 -0
- data/lib/reight/text.rb +116 -0
- data/lib/reight.rb +7 -3
- data/reight.gemspec +7 -7
- data/res/icons.png +0 -0
- data/test/helper.rb +16 -0
- data/test/test_map.rb +7 -7
- data/test/test_map_chunk.rb +6 -6
- data/test/test_sprite.rb +28 -0
- metadata +39 -30
- data/lib/reight/app/music/editor.rb +0 -25
- data/lib/reight/app/music.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71e95252b70e9d2cf1eb2ec6022d58912ccb4409a583b30f2bb9a63926d6216
|
4
|
+
data.tar.gz: b3abfeb44477f44f79eaea1323f47eeef1e41d9bdcff6bf8c67991a4362d7055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 254f31c3435558aac8e57f65346a4f4e5f72eef0bf6c2a70e6cba20c248111c5b7ea8896cf6d37ebfce7c40ec85f0b231c45f2a90dc7ac8c2bdd83b9586e36cf
|
7
|
+
data.tar.gz: 4cbcedca74269acc8f29ee80826a0691fff58b4c0c201c685f009ea09a6a2db76f78e5c17ba2f9b953c1f2ca21f3dc5b805d909ce8e209787d9a246425fd429d
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,58 @@
|
|
1
1
|
# reight ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.1.7] - 2025-03-07
|
5
|
+
|
6
|
+
- Add Reight::Context
|
7
|
+
- Add docs for Reight::Context
|
8
|
+
- Add Reight::Sprite class
|
9
|
+
- Add sound editor
|
10
|
+
- Add size() and createCanvas()
|
11
|
+
- Add App#active?
|
12
|
+
- Project: Add clear_all_sprites()
|
13
|
+
- Map: Add to_sprites(), sprites(), sprites_at(), clear_sprites()
|
14
|
+
- Map::Chunk: Add sprites(), clear_sprites(), and each()
|
15
|
+
- Chip: Add sprite(), clear_sprites(), and each()
|
16
|
+
- Add Map::SpriteArray class
|
17
|
+
- Add SpriteWorld#offset and SpriteWorld#zoom
|
18
|
+
|
19
|
+
- Define Sprite and Sound classes in the main context
|
20
|
+
- Change pixelsPerMeter from 100 to 8
|
21
|
+
- createSprite() creates a new Reight::Sprite instance
|
22
|
+
- Map: delete/delete_chip -> Map#remove/remove_chip
|
23
|
+
- Map::Chunk: Caches drawing contents
|
24
|
+
- Disable the '<=>' operators for Map, Map::Chunk, Chip, ChipList
|
25
|
+
- Sound: play() accepts a block parameter that is called when playback ends
|
26
|
+
- Sound: play() can take gain parameter
|
27
|
+
- Sound: Default gain: 0.1 -> 0.2
|
28
|
+
- Sound: apply envelope and gain
|
29
|
+
- Offset the button text while it is pressed
|
30
|
+
|
31
|
+
- Runner: During game execution, the Run button re-runs the game
|
32
|
+
- Runner: Delete F10 to restart
|
33
|
+
- Runner: Delete restart button
|
34
|
+
- Runner: Rescue exceptions raised by user script
|
35
|
+
- Runner: Stop all timers on stop running user script
|
36
|
+
- Runner: runner.rb does not use 'using Reight', so define funcs in runner context
|
37
|
+
- Runner: User script paths are relative to project directory
|
38
|
+
|
39
|
+
- SpriteEditor: Black is treated as a transparent color
|
40
|
+
- SpriteEditor: Update color palette to 32 colors
|
41
|
+
- SpriteEditor: Show color code
|
42
|
+
|
43
|
+
- SoundEditor: Cancel attack and release on successive notes to avoid click noise
|
44
|
+
- SoundEditor: Display tone colors on each tone button
|
45
|
+
- SoundEditor: Canvas is scrollable
|
46
|
+
|
47
|
+
- Fix pick_color fails to get pixel color
|
48
|
+
- Fix crash on moving window
|
49
|
+
- Fix crash on switching from editer to another editor
|
50
|
+
- Fix yard crash caused by pattern matching rightward assginment
|
51
|
+
- Fix misaligned mouse position on sound editor canvas
|
52
|
+
- Fix error on drawing line tool at map editor
|
53
|
+
- Fix the angle mode of Reight::Context does not sync with root context
|
54
|
+
|
55
|
+
|
4
56
|
## [v0.1.6] - 2025-01-30
|
5
57
|
|
6
58
|
- Update dependencies: processing, rubysketch
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
.map {|s| File.expand_path "#{s}/lib", __dir__}
|
5
5
|
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'rucy/rake'
|
8
8
|
|
9
9
|
require 'xot/extension'
|
10
10
|
require 'rucy/extension'
|
@@ -18,8 +18,11 @@ require 'reight/extension'
|
|
18
18
|
|
19
19
|
EXTENSIONS = [Xot, Rucy, Beeps, Rays, Reflex, Processing, RubySketch, Reight]
|
20
20
|
|
21
|
+
ENV['RDOC'] = 'yardoc --no-private'
|
22
|
+
|
21
23
|
default_tasks
|
22
24
|
test_ruby_extension
|
25
|
+
generate_documents
|
23
26
|
build_ruby_gem
|
24
27
|
|
25
28
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/lib/reight/all.rb
CHANGED
@@ -21,17 +21,21 @@ end# Reight
|
|
21
21
|
|
22
22
|
require 'reight/extension'
|
23
23
|
require 'reight/helpers'
|
24
|
-
require 'reight/project'
|
25
24
|
require 'reight/history'
|
26
25
|
require 'reight/button'
|
26
|
+
require 'reight/text'
|
27
|
+
require 'reight/index'
|
27
28
|
|
28
29
|
require 'reight/reight'
|
30
|
+
require 'reight/context'
|
31
|
+
require 'reight/project'
|
32
|
+
require 'reight/sprite'
|
29
33
|
require 'reight/chip'
|
30
34
|
require 'reight/map'
|
35
|
+
require 'reight/sound'
|
31
36
|
require 'reight/app'
|
32
37
|
require 'reight/app/navigator'
|
33
38
|
require 'reight/app/runner'
|
34
39
|
require 'reight/app/sprite'
|
35
40
|
require 'reight/app/map'
|
36
41
|
require 'reight/app/sound'
|
37
|
-
require 'reight/app/music'
|
data/lib/reight/app/map/brush.rb
CHANGED
@@ -5,15 +5,15 @@ class Reight::MapEditor::BrushBase < Reight::MapEditor::Tool
|
|
5
5
|
|
6
6
|
def brush(cursor_from, cursor_to, chip) = nil
|
7
7
|
|
8
|
-
def
|
8
|
+
def put_or_remove_chip(x, y, chip)
|
9
9
|
return false unless x && y && chip
|
10
10
|
m = canvas.map
|
11
11
|
return false if !@deleting && m[x, y]&.id == chip.id
|
12
12
|
|
13
13
|
result = false
|
14
14
|
m.each_chip x, y, chip.w, chip.h do |ch|
|
15
|
-
m.
|
16
|
-
result |= history.append [:
|
15
|
+
m.remove_chip ch
|
16
|
+
result |= history.append [:remove_chip, ch.pos.x, ch.pos.y, ch.id]
|
17
17
|
end
|
18
18
|
unless @deleting
|
19
19
|
m.put x, y, chip
|
@@ -3,28 +3,19 @@ using Reight
|
|
3
3
|
|
4
4
|
class Reight::MapEditor::Canvas
|
5
5
|
|
6
|
-
include Reight::Hookable
|
7
|
-
|
8
6
|
def initialize(app, map, path)
|
9
|
-
hook :tool_changed
|
10
|
-
|
11
7
|
@app, @map, @path = app, map, path
|
12
8
|
@x, @y, @tool, @cursor = 0, 0, nil, nil, nil
|
13
9
|
end
|
14
10
|
|
15
|
-
attr_accessor :x, :y
|
11
|
+
attr_accessor :x, :y, :tool
|
16
12
|
|
17
|
-
attr_reader :map, :
|
13
|
+
attr_reader :map, :cursor
|
18
14
|
|
19
15
|
def save()
|
20
16
|
@app.project.save
|
21
17
|
end
|
22
18
|
|
23
|
-
def tool=(tool)
|
24
|
-
@tool = tool
|
25
|
-
tool_changed! tool
|
26
|
-
end
|
27
|
-
|
28
19
|
def set_cursor(x, y, w, h)
|
29
20
|
@cursor = correct_bounds x, y, w, h
|
30
21
|
end
|
@@ -47,7 +38,7 @@ class Reight::MapEditor::Canvas
|
|
47
38
|
end
|
48
39
|
|
49
40
|
def sprite()
|
50
|
-
@sprite ||= Sprite.new.tap do |sp|
|
41
|
+
@sprite ||= RubySketch::Sprite.new.tap do |sp|
|
51
42
|
pos = -> {to_image sp.mouse_x, sp.mouse_y}
|
52
43
|
sp.draw {draw}
|
53
44
|
sp.mouse_pressed {mouse_pressed( *pos.call, sp.mouse_button)}
|
@@ -76,7 +67,7 @@ class Reight::MapEditor::Canvas
|
|
76
67
|
clip sp.x, sp.y, sp.w, sp.h
|
77
68
|
translate @x, @y
|
78
69
|
|
79
|
-
fill 0
|
70
|
+
fill 0
|
80
71
|
no_stroke
|
81
72
|
rect(-@x, -@y, sp.w, sp.h)
|
82
73
|
|
data/lib/reight/app/map/chips.rb
CHANGED
@@ -25,8 +25,12 @@ class Reight::MapEditor::Chips
|
|
25
25
|
|
26
26
|
def draw()
|
27
27
|
sp = sprite
|
28
|
-
|
29
28
|
clip sp.x, sp.y, sp.w, sp.h
|
29
|
+
|
30
|
+
fill 0
|
31
|
+
no_stroke
|
32
|
+
rect 0, 0, sp.w, sp.h
|
33
|
+
|
30
34
|
translate(*clamp_offset(@offset).to_a)
|
31
35
|
image @chips.image, 0, 0
|
32
36
|
|
@@ -59,7 +63,7 @@ class Reight::MapEditor::Chips
|
|
59
63
|
end
|
60
64
|
|
61
65
|
def sprite()
|
62
|
-
@sprite ||= Sprite.new.tap do |sp|
|
66
|
+
@sprite ||= RubySketch::Sprite.new.tap do |sp|
|
63
67
|
sp.draw {draw}
|
64
68
|
sp.mouse_pressed {mouse_pressed sp.mouse_x, sp.mouse_y}
|
65
69
|
sp.mouse_released {mouse_released sp.mouse_x, sp.mouse_y}
|
@@ -11,7 +11,7 @@ class Reight::MapEditor < Reight::App
|
|
11
11
|
@chips ||= Chips.new self, project.chips
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def setup()
|
15
15
|
super
|
16
16
|
history.disable do
|
17
17
|
tools[0].click
|
@@ -69,8 +69,8 @@ class Reight::MapEditor < Reight::App
|
|
69
69
|
def undo(flash: true)
|
70
70
|
history.undo do |action|
|
71
71
|
case action
|
72
|
-
in [:put_chip, x, y, id] then canvas.map.
|
73
|
-
in [:
|
72
|
+
in [:put_chip, x, y, id] then canvas.map.remove x, y
|
73
|
+
in [:remove_chip, x, y, id] then canvas.map.put x, y, project.chips[id]
|
74
74
|
in [ :select, sel, _] then sel ? canvas.select(*sel) : canvas.deselect
|
75
75
|
in [:deselect, sel] then canvas.select(*sel)
|
76
76
|
end
|
@@ -82,7 +82,7 @@ class Reight::MapEditor < Reight::App
|
|
82
82
|
history.redo do |action|
|
83
83
|
case action
|
84
84
|
in [:put_chip, x, y, id] then canvas.map.put x, y, project.chips[id]
|
85
|
-
in [:
|
85
|
+
in [:remove_chip, x, y, id] then canvas.map.remove x, y
|
86
86
|
in [ :select, _, sel] then canvas.select(*sel)
|
87
87
|
in [:deselect, _] then canvas.deselect
|
88
88
|
end
|
data/lib/reight/app/map/line.rb
CHANGED
@@ -4,7 +4,7 @@ using Reight
|
|
4
4
|
class Reight::MapEditor::Line < Reight::MapEditor::BrushBase
|
5
5
|
|
6
6
|
def initialize(app, &block)
|
7
|
-
super app, icon: app.icon(
|
7
|
+
super app, icon: app.icon(4, 2, 8), &block
|
8
8
|
set_help left: name, right: 'Pick Chip'
|
9
9
|
end
|
10
10
|
|
@@ -17,15 +17,15 @@ class Reight::MapEditor::Line < Reight::MapEditor::BrushBase
|
|
17
17
|
dy = fromy < toy ? chip.h : -chip.h
|
18
18
|
if (tox - fromx).abs > (toy - fromy).abs
|
19
19
|
(fromx..tox).step(dx).each do |x|
|
20
|
-
y = map
|
20
|
+
y = fromy == toy ? toy : map(x, fromx, tox, fromy, toy)
|
21
21
|
y = y / chip.h * chip.h
|
22
|
-
result |=
|
22
|
+
result |= put_or_remove_chip x, y, chip
|
23
23
|
end
|
24
24
|
else
|
25
25
|
(fromy..toy).step(dy).each do |y|
|
26
|
-
x = map
|
26
|
+
x = fromx == tox ? tox : map(y, fromy, toy, fromx, tox)
|
27
27
|
x = x / chip.w * chip.w
|
28
|
-
result |=
|
28
|
+
result |= put_or_remove_chip x, y, chip
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/reight/app/map/rect.rb
CHANGED
@@ -5,7 +5,7 @@ class Reight::MapEditor::Rect < Reight::MapEditor::BrushBase
|
|
5
5
|
|
6
6
|
def initialize(app, fill:, &block)
|
7
7
|
@fill = fill
|
8
|
-
super app, icon: app.icon(fill ?
|
8
|
+
super app, icon: app.icon(fill ? 6 : 5, 2, 8), &block
|
9
9
|
set_help left: "#{fill ? 'Fill' : 'Stroke'} #{name}", right: 'Pick Chip'
|
10
10
|
end
|
11
11
|
|
@@ -19,7 +19,7 @@ class Reight::MapEditor::Rect < Reight::MapEditor::BrushBase
|
|
19
19
|
(fromy..toy).step(chip.h).each do |y|
|
20
20
|
(fromx..tox).step(chip.w).each do |x|
|
21
21
|
next if !@fill && fromx < x && x < tox && fromy < y && y < toy
|
22
|
-
result |=
|
22
|
+
result |= put_or_remove_chip x, y, chip
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/reight/app/navigator.rb
CHANGED
@@ -36,10 +36,11 @@ class Reight::Navigator
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def window_resized()
|
39
|
-
[app_buttons, history_buttons, edit_buttons]
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
[app_buttons, history_buttons, edit_buttons]
|
40
|
+
.flatten.map(&:sprite).each do |sp|
|
41
|
+
sp.w = sp.h = Reight::App::NAVIGATOR_HEIGHT
|
42
|
+
sp.y = 0
|
43
|
+
end
|
43
44
|
|
44
45
|
space = Reight::App::SPACE
|
45
46
|
x = space
|
@@ -47,20 +48,23 @@ class Reight::Navigator
|
|
47
48
|
app_buttons.map {_1.sprite}.each do |sp|
|
48
49
|
sp.x = x + 1
|
49
50
|
x = sp.right
|
51
|
+
end.tap do
|
52
|
+
x += space unless _1.empty?
|
50
53
|
end
|
51
|
-
x += space
|
52
54
|
|
53
55
|
history_buttons.map {_1.sprite}.each do |sp|
|
54
56
|
sp.x = x + 1
|
55
57
|
x = sp.right
|
58
|
+
end.tap do
|
59
|
+
x += space unless _1.empty?
|
56
60
|
end
|
57
|
-
x += space unless history_buttons.empty?
|
58
61
|
|
59
62
|
edit_buttons.map {_1.sprite}.each do |sp|
|
60
63
|
sp.x = x + 1
|
61
64
|
x = sp.right
|
65
|
+
end.tap do
|
66
|
+
x += space unless _1.empty?
|
62
67
|
end
|
63
|
-
x += space unless edit_buttons.empty?
|
64
68
|
|
65
69
|
message.sprite.tap do |sp|
|
66
70
|
sp.x = x + space
|
@@ -86,50 +90,46 @@ class Reight::Navigator
|
|
86
90
|
Reight::Button.new(name: 'Sound Editor', icon: @app.icon(3, 0, 8)) {
|
87
91
|
switch_app Reight::SoundEditor
|
88
92
|
},
|
89
|
-
Reight::Button.new(name: 'Music Editor', icon: @app.icon(4, 0, 8)) {
|
90
|
-
switch_app Reight::MusicEditor
|
91
|
-
},
|
92
93
|
]
|
93
94
|
end
|
94
95
|
|
95
96
|
def history_buttons()
|
96
|
-
@history_buttons ||=
|
97
|
-
|
97
|
+
@history_buttons ||= [].tap do |buttons|
|
98
|
+
next unless @app.respond_to? :undo
|
99
|
+
buttons << Reight::Button.new(name: 'Undo', icon: @app.icon(3, 1, 8)) {
|
98
100
|
@app.undo flash: false
|
99
101
|
}.tap {|b|
|
100
102
|
b.enabled? {@app.history.can_undo?}
|
101
|
-
}
|
102
|
-
Reight::Button.new(name: 'Redo', icon: @app.icon(4, 1, 8)) {
|
103
|
+
}
|
104
|
+
buttons << Reight::Button.new(name: 'Redo', icon: @app.icon(4, 1, 8)) {
|
103
105
|
@app.redo flash: false
|
104
106
|
}.tap {|b|
|
105
107
|
b.enabled? {@app.history.can_redo?}
|
106
108
|
}
|
107
|
-
|
109
|
+
end
|
108
110
|
end
|
109
111
|
|
110
112
|
def edit_buttons()
|
111
|
-
@edit_buttons ||=
|
112
|
-
|
113
|
+
@edit_buttons ||= [].tap do |buttons|
|
114
|
+
next unless @app.respond_to? :paste
|
115
|
+
buttons << Reight::Button.new(name: 'Cut', icon: @app.icon(0, 1, 8)) {
|
113
116
|
@app.cut flash: false
|
114
117
|
}.tap {|b|
|
115
118
|
b.enabled? {@app.can_cut?}
|
116
|
-
}
|
117
|
-
Reight::Button.new(name: 'Copy', icon: @app.icon(1, 1, 8)) {
|
119
|
+
}
|
120
|
+
buttons << Reight::Button.new(name: 'Copy', icon: @app.icon(1, 1, 8)) {
|
118
121
|
@app.copy flash: false
|
119
122
|
}.tap {|b|
|
120
123
|
b.enabled? {@app.can_copy?}
|
121
|
-
}
|
122
|
-
Reight::Button.new(name: 'Paste', icon: @app.icon(2, 1, 8)) {
|
124
|
+
}
|
125
|
+
buttons << Reight::Button.new(name: 'Paste', icon: @app.icon(2, 1, 8)) {
|
123
126
|
@app.paste flash: false
|
124
127
|
}.tap {|b|
|
125
128
|
b.enabled? {@app.can_paste?}
|
126
|
-
}
|
127
|
-
|
129
|
+
}
|
130
|
+
end
|
128
131
|
end
|
129
132
|
|
130
|
-
def history_buttons? = @app.respond_to? :undo
|
131
|
-
def edit_buttons? = @app.respond_to? :cut
|
132
|
-
|
133
133
|
def message()
|
134
134
|
@message ||= Message.new
|
135
135
|
end
|
@@ -159,7 +159,7 @@ class Reight::Navigator::Message
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def sprite()
|
162
|
-
@sprite ||= Sprite.new.tap do |sp|
|
162
|
+
@sprite ||= RubySketch::Sprite.new.tap do |sp|
|
163
163
|
sp.draw do
|
164
164
|
next unless @text
|
165
165
|
fill 100
|