+ 1
Can't generate Rectangle in canvas using map values
I successfully generated two random values and insert them in a map named "m" and then I try to create a canvas rectangle based on those values. The first x and y values work but the second one always goes wherever it wants? I'll put the code below and the part for where the values and rectangle are generated can be found below the circle class. https://code.sololearn.com/Wa24A14a3A11
1 Resposta
+ 2
canvas_context.rect method expect (x,y,width,height) as arguments, but you provide (x1,y1,x2,y2)... simple fix:
k.rect(m.get("x1"),m.get("y1"),m.get("x2")-m.get("x1"),m.get("y2")-m.get("y1"));