@@ -157,27 +157,30 @@ def __init__(self, x, y, tone, desc):
157157 self .tone = tone
158158 self .desc = desc
159159 self .target = None
160+ self .last_col = 0
160161
161162 def update (self ):
162- wx = (pyxel .mouse_x - self .x - 1 ) // 5
163- wy = 15 - (pyxel .mouse_y - self .y - 8 ) // 3
163+ col = (pyxel .mouse_x - self .x - 1 ) // 5
164+ row = 15 - (pyxel .mouse_y - self .y - 8 ) // 3
164165
165- gx = (pyxel .mouse_x - self .x - 168 ) // 5
166- gy = 16 - (pyxel .mouse_y - self .y - 8 ) // 3
167-
168- if pyxel .btnp (pyxel .MOUSE_BUTTON_LEFT ):
169- if 0 <= wx <= 31 and 0 <= wy <= 15 :
166+ if pyxel .btnp (pyxel .MOUSE_BUTTON_LEFT ) and 0 <= row <= 15 :
167+ if 0 <= col <= 31 :
170168 self .target = "wave"
171- elif gx == 0 and 0 <= gy <= 16 :
169+ elif 167 <= pyxel . mouse_x - self . x <= 174 :
172170 self .target = "gain"
173171
174172 if pyxel .btnr (pyxel .MOUSE_BUTTON_LEFT ):
175173 self .target = None
176174
177175 if self .target == "wave" :
178- pyxel .tones [self .tone ].wavetable [max (0 , min (31 , wx ))] = max (0 , min (15 , wy ))
176+ for x in range (min (self .last_col , col ), max (self .last_col , col ) + 1 ):
177+ pyxel .tones [self .tone ].wavetable [max (0 , min (31 , x ))] = max (
178+ 0 , min (15 , row )
179+ )
179180 elif self .target == "gain" :
180- pyxel .tones [self .tone ].gain = max (0 , min (15 , gy / 16 ))
181+ pyxel .tones [self .tone ].gain = max (0 , min (15 , row )) / 15
182+
183+ self .last_col = col
181184
182185 def draw (self ):
183186 pyxel .text (self .x , self .y , f"TONE:{ self .tone } { self .desc } " , 12 )
0 commit comments