- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想画一个填充的星星,比如:
到目前为止我有这段代码:
def draw_star(size,color):
count = 0
angle = 144
while count <= 5:
turtle.forward(size)
turtle.right(angle)
count += 1
return
draw_star(100,"purple")
我想用函数传递的任何颜色填充星号。我该怎么做?
最佳答案
要获得 5 角星,您应该在每一侧画 2 条线。角度需要加起来为 72 (360/5)
import turtle
def draw_star(size, color):
angle = 120
turtle.fillcolor(color)
turtle.begin_fill()
for side in range(5):
turtle.forward(size)
turtle.right(angle)
turtle.forward(size)
turtle.right(72 - angle)
turtle.end_fill()
return
draw_star(100, "purple")
尝试不同的angle
值以获得你想要的形状
关于python - turtle graphics ,画个星星?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26356543/
在 ggplot 中,我想用星号 ('*') 标记一些误差条以指示显着性水平。该图在 y 轴上排列有类别标签,因此它们很容易辨认。这意味着误差条是水平的,* 需要与它们垂直对齐。但是,符号“*”并未在
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我正在研究在图像上模拟星星。该图像是按正态分布(均值、标准差)生成的灰度矩阵。现在,给定像素坐标和恒星 SNR,我必须将其作为点源种植在图像之上。有什么建议我如何实现它以使其成为有用的模拟?你能建议代
我正在尝试自定义 RatingBar 的每颗星,使其看起来不同。 当我查看它的源代码时 RatingBar或其父类(super class) AbsSeekBar/ProgressBar ,我无法识别
我想给 RatingBar 中的星星添加阴影。我也想用半星,所以我不能直接在星图上添加阴影。这有可能实现还是我必须创建自定义 RatingBar? 我使用以下可绘制对象使未填充的星星透明:
我正在尝试绘制一些随机点作为窗口中的星星,但积分没有显示。但其他对象显示正确。 我的源代码: #include #include #include // For math routine
GitHub API 提供了获取按创建日期排序的加星标项目的功能。但是,我找不到获得这个日期的可能性。 响应中仅存在三个日期类型字段: created_at: '2013-06-13T21:10:36
我制作了一些闪烁的随机星星粒子,由于某种原因它无法在 Firefox 上运行,我可以渲染出我的图像,但星星没有渲染。我也没有错误消息。 我把它发送给一个 friend ,由于某种原因,它在他的 chr
我是一名优秀的程序员,十分优秀!