I load an img
in my setup()
. I can use its attributes like .width
but when I attempt to use them as parameters to size()
, I get NameError: global name ''img'' is not defined
. But before that line, I’m happily referring to them in the print()
statement.
def setup():
global img
img = loadImage("C:\\Users\foo\\code\\freq_plot\\image_experiment\\bal.jpg")
#all these see the variable "img"
one_pixel = img.get(40,40)
print(red(one_pixel), green(one_pixel), blue(one_pixel))
print(type(img))
print(img.height, img.width, )
#size(img.height,img.width) #NameError: global name 'img' is not defined'
size(100,100) # works fine
noLoop()
def draw():
print("done")