- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我用于创建 Mandelbrot 集的程序有一个错误:每当笔改变颜色时,并且之后每隔 42 个像素变亮。巧合的是,这是一个 mandelbug(是的,我刚刚学到这个术语),因为它对于“边缘”附近的许多像素不一致(它实际上可能在它应该是的颜色和最后一个颜色之间模糊,或者接下来,像素应该是),但它始终是该像素之后的第 42 个像素,直到下一个颜色发生变化。我正在使用 OSX 10.6.8、PYTHON 2.7。当我在学校写这个程序时,它运行得很好(Windows),然后我把它发给自己,再做一些工作(主要是使样本大小,因此图像更大),然后运行它,我得到了这个漏洞。编辑:糟糕,我忘了说这只发生在我的 Mandelbrot 程序中,我家里的其他几个 turtle 程序都很好。
部分屏幕截图(这样您就不必在程序运行时永远等待以查看我在说什么):
来 self 在家的第一个版本:
从当前版本(横向):
代码如下:
import turtle
import math
turtle.speed(0)
def benoit(onelen):
turtle.left(90)
for x in range(-2*onelen, onelen):
turtle.up()
turtle.goto(x, int(-1.5*onelen)-1)
turtle.down()
for y in range(int(-1.5*onelen)-1, int(1.5*onelen)-1):
z = complex(0,0)
c = complex(x*1.0/onelen,y*1.0/onelen)
for k in range(20):
z = z*z+c
if abs(z) > 2:
g = .2 + .8*(20-k)/20
break
if k == 19:
g = 0
turtle.pencolor(0,g,0)
turtle.forward(1)
benoit(250)
x = raw_input("Press Enter to Exityadayadayada")
编辑:喜欢这个错误的 DSM 已经建议修复。然而,我没有编辑 Python 源代码的经验,所有的下划线都让我紧张。谁能具体告诉我要编辑什么和/或如何编辑?
最佳答案
哇。我认为这是我最喜欢的错误之一,不管你信不信,这个数字恰好是 42 的事实实际上是相关的!好吧,外围,无论如何..在 turtle.py 中:
def _goto(self, end):
"""Move the pen to the point end, thereby drawing a line
if pen is down. All other methodes for turtle movement depend
on this one.
[...]
###### vererbung!!!!!!!!!!!!!!!!!!!!!!
self._position = end
if self._creatingPoly:
self._poly.append(end)
if len(self.currentLine) > 42: # 42! answer to the ultimate question
# of life, the universe and everything
self._newLine()
self._update() #count=True)
所以当它决定换行时,问题就出现了,显然是出于性能原因:
def _newLine(self, usePos=True):
"""Closes current line item and starts a new one.
Remark: if current line became too long, animation
performance (via _drawline) slowed down considerably.
"""
我能够通过提高行号限制和/或在没有任何引用的地方散布 self._pencolor 引用来“修复”该错误。但无论如何,你并不疯狂,而且你所做的也不是什么。 :-)
关于python - 为什么 turtle 会照亮像素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9242241/
我正在使用 Laravel websocket written by beyoundcode . 几天后,我连接到 myDomain.com/laravel-websockets第一步解决了。 但是现
我已经在本地主机中创建了数据库 Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user
我已经配置了 php.ini 文件 (post_max_size=10240M),但它仍然抛出 PostTooLargeException。如何在 Laravel 5.5 中增加上传和下载限制? 最佳
require dirname(dirname(__DIR__)) . '/vendor/autoload.php'; require dirname(__DIR__) . '/config.php'
我正在使用 Laravel,当我尝试运行 php artisan make:migrate 时,它显示了这个错误: Illuminate\Database\QueryException : SQLST
我使用 PHP 7.0,我还在我的 Ubunutu 服务器上使用 Apache。 我已经更新了我的 php.ini cat /etc/php/7.2/fpm/php.ini
我将 Centos 7.7 与 PHP 7.2 一起使用,但是当我尝试使用 laravel 迁移 db 时会发生此错误。尝试了很多东西,但我无法解决这个问题。 Illuminate\Database\
我目前正在做一个学校项目,我的数据库遇到了这个问题,我想创建与视频和类别的关系,这是我的两个表。视频表: increments('id'); $table->string('name'
这个问题已经有答案了: Error: Tablespace for table xxx exists. Please DISCARD the tablespace before IMPORT (27
我正在尝试将在 laravel 中创建的表迁移到数据库并使用外键。但是我收到以下错误。请帮我看看哪里出错了? Illuminate\Database\QueryException : SQLSTATE
我已经在 github 上下载了一个 repo 并创建了一个数据库。我正在尝试进行迁移并收到以下错误 错误: Illuminate\Database\QueryException : SQLSTATE
我是 laravel 的新手,尝试在我的数据库中输入值时遇到了这个问题。同样的事情适用于患者的表格和表格,但不适用于医生。如果有人能指出我哪里出了问题,那将不胜感激 表格, { public
我对 artisan 和迁移有疑问。 我刚刚创建了一个新项目,使用 Laravel Schema Design 复制粘贴我的数据库,将 schemaLenght 放入我的 config/databas
我有一个问题,但我得到的答案并没有真正帮助我。 所以我一直在尝试为每个用户基本上创建一个 Profiles 表。我遵循了一对一关系的规则,但我不断收到此错误 Illuminate\Database\Q
我是一名优秀的程序员,十分优秀!