当前位置: 首页>>代码示例>>Python>>正文


Python Canvas.unset方法代码示例

本文整理汇总了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)
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py

示例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)
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py

示例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())
开发者ID:chrisrammy,项目名称:drawille,代码行数:7,代码来源:tests.py

示例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}})
开发者ID:chrisrammy,项目名称:drawille,代码行数:8,代码来源:tests.py

示例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)
开发者ID:knolax,项目名称:dotfiles,代码行数:33,代码来源:imagetobraile.py


注:本文中的drawille.Canvas.unset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。