- Edited
Hello again. Problems arise when you do things. This time im confused on how to deal with it.
The problem is that the ColorRect has defined size(x,y) yet it draws pixels outside its size.
Im calling draw function to draw pixels onto the rect. And the result is like this.
What you see in the picture is a screenshot of grayish colorrect with yellow pattern on it (waveform). It was drawn on the rect. At the mouse pointer you see a vertical lighter pixel, this is another colorrect object that is placed at the x == 0 position of the grayish colorrect. And now you see, that the yellow pattern is on the left of the supposed x ==0 value of the colorrect.
Scene:
Script part where it draws:
func _draw():
if preview:
var rect = get_rect()
var rectSize = rect.size
var previewLen = preview.get_length() #audio length in seconds
for i in range(0, rectSize.x):
var ofs = (0+i) * previewLen / rectSize.x
var ofs_n = (0+(i+1)) * previewLen / rectSize.x
var max_v = preview.get_max(ofs, ofs_n) * 0.5 + 0.5
var min_v = preview.get_min(ofs, ofs_n) * 0.5 + 0.5
draw_line(Vector2(i, min_v * rectSize.y),
Vector2(i, max_v * rectSize.y), Color(1, 1, 0, 1), 1, false) # Yellow waveform
How can i mitigate this?
EDIT:
The 0+i thing i added recently so ignore that.. i was testing to see if the offset would help but it does not