当我 运行 我的代码时,为什么 ellipse/circle 没有出现
when i run my code, why does the ellipse/circle not show up
from math import sin
from processing import *
X = 30
Y = 30
delay = 16
radius = 30
def setup():
strokeWeight(10)
frameRate(20)
size(500,500)
def sircle():
global X, Y, radius
background(100)
fill(0,121,184)
stroke(255)
fc = environment.frameCount
X += (mouse.x-X)/delay;
Y += (mouse.y-Y)/delay;
radius = radius + sin(fc / 4)
draw = sircle
run()
出于某种原因 run()
仅创建背景。
有人知道如何调用 sircle()
的函数吗?
您需要 运行 sircle()
和 setup()
带括号。
这些是函数而不是变量,它们需要括号。在您的代码中 draw
变量存储 sircle()
函数的内存地址。
我认为 OP 指的是 this code
draw
被赋值给函数变量 sircle
似乎是正确的。此外,它不像 sircle()
返回任何可以分配给 draw
的东西
查看我上面分享的 link 中的示例代码,您需要一行
ellipse(X,Y,radius,radius)
在您的 sircle
函数结束时
from math import sin
from processing import *
X = 30
Y = 30
delay = 16
radius = 30
def setup():
strokeWeight(10)
frameRate(20)
size(500,500)
def sircle():
global X, Y, radius
background(100)
fill(0,121,184)
stroke(255)
fc = environment.frameCount
X += (mouse.x-X)/delay;
Y += (mouse.y-Y)/delay;
radius = radius + sin(fc / 4)
draw = sircle
run()
出于某种原因 run()
仅创建背景。
有人知道如何调用 sircle()
的函数吗?
您需要 运行 sircle()
和 setup()
带括号。
这些是函数而不是变量,它们需要括号。在您的代码中 draw
变量存储 sircle()
函数的内存地址。
我认为 OP 指的是 this code
draw
被赋值给函数变量 sircle
似乎是正确的。此外,它不像 sircle()
返回任何可以分配给 draw
查看我上面分享的 link 中的示例代码,您需要一行
ellipse(X,Y,radius,radius)
在您的 sircle
函数结束时