本文整理汇总了Python中drawille.Canvas.unset方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.unset方法的具体用法?Python Canvas.unset怎么用?Python Canvas.unset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类drawille.Canvas
的用法示例。
在下文中一共展示了Canvas.unset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unset_nonempty
# 需要导入模块: from drawille import Canvas [as 别名]
# 或者: from drawille.Canvas import unset [as 别名]
def test_unset_nonempty(self):
c = Canvas()
c.set(0, 0)
c.set(0, 1)
c.unset(0, 1)
self.assertEqual(c.chars[0][0], 1)
示例2: test_unset_empty
# 需要导入模块: from drawille import Canvas [as 别名]
# 或者: from drawille.Canvas import unset [as 别名]
def test_unset_empty(self):
c = Canvas()
c.set(1, 1)
c.unset(1, 1)
self.assertEqual(len(c.chars), 0)
示例3: test_unset_empty
# 需要导入模块: from drawille import Canvas [as 别名]
# 或者: from drawille.Canvas import unset [as 别名]
def test_unset_empty(self):
c = Canvas()
c.set(1, 1)
c.unset(1, 1)
self.assertEqual(c.pixels, dict())
示例4: test_unset_nonempty
# 需要导入模块: from drawille import Canvas [as 别名]
# 或者: from drawille.Canvas import unset [as 别名]
def test_unset_nonempty(self):
c = Canvas()
c.set(1, 1)
c.set(2, 1)
c.unset(1, 1)
self.assertEqual(c.pixels, {1:{2: 2}})
示例5: print
# 需要导入模块: from drawille import Canvas [as 别名]
# 或者: from drawille.Canvas import unset [as 别名]
except:
print("could not read pixel")
#totals that rgb per ppd x ppd area
tr = tr + r
tg = tg + g
tb = tb + b
#averages
tr = tr / ( ppd * ppd )
tg = tg / ( ppd * ppd )
tb = tb / ( ppd * ppd )
sum = (tr + tg + tb) / 3
#python doesn't have bools, it's like see where 0 is false and anything else is true
if (dither or trippy) :
#because you can't divide by zero
if (sum == 0) :
canvo.unset(x,y)
else:
#the RGB scale is exponential , so the ratio of light from 255 to 80 would be 255^2/80^2
# however since the image is 3 dimensional, then the dither turns on in 1/mod * 1/mod
# so mod should be 255/80 instead
mod = int(255 / sum)
# the ratio here is (2x-1)/x^2 where x is 255/sum
if (trippy) :
if (((x % mod) == 0) or ((y % mod) == 0)) :
canvo.set(x,y)
else:
canvo.unset(x,y)
#ratio is 1/x^2
elif (dither) :
if (((x % mod) == 0) and ((y % mod) == 0)) :
canvo.set(x,y)