0

I'm trying to make two lines across a circle, like an X. Since it's an X, to find the (x,y) I just multiplied sqrt(2)/2 by the radius and then added or subtracted it from the (x,y) origin depending on what corner of the circle it was in. However I keep getting a TypeError 'The error was: 2nd arg can't be coerced to int' This is what I have:

#starting/ending points of the line
a1 = z - ((sqrt(2) / 2)*(r1))
b1 = w - ((sqrt(2) / 2)*(r1))
a2 = z + ((sqrt(2) / 2)*(r1))
b2 = w + ((sqrt(2) / 2)*(r1))
c1 = z - ((sqrt(2) / 2)*(r1))
d1 = w + ((sqrt(2) / 2)*(r1))
c2 = z + ((sqrt(2) / 2)*(r1))
d2 = w - ((sqrt(2) / 2)*(r1))
pic.addLine(black, a1, b1, a2, b2)
pic.addLine(black, c1, d1, c2, d2)

...where z is the x origin, w is the y origin, and r1 is the radius. What am I doing wrong here? This what I'm getting :

enter image description here

Reimeus
  • 158,255
  • 15
  • 216
  • 276

1 Answers1

2

By using sqrt() you end up with floating point values, but the method you are calling wants integers only. Call int() on the values before passing them to pic.addLine():

pic.addLine(black, int(a1), int(b1), int(a2), int(b2))
pic.addLine(black, int(c1), int(d1), int(c2), int(d2))
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343