pygame

convert a pygame surface into an image?

会有一股神秘感。 提交于 2020-08-25 02:37:18
问题 is there a way to convert a pygame surface into a png image? rgb_content = pygame.surfarray.array2d(canvas) cv2.imwrite(file, rgb_content, [cv2.IMWRITE_PNG_COMPRESSION, 0]) I've tried this but it doesn't work, because it flips the image sideways. Makes it grayscale and doesn't actually save it. 回答1: Use the save function of the image modul: pygame.image.save() save an image to disk save(Surface, filename) -> None This will save your Surface as either a BMP, TGA, PNG, or JPEG image. If the

convert a pygame surface into an image?

試著忘記壹切 提交于 2020-08-25 02:33:07
问题 is there a way to convert a pygame surface into a png image? rgb_content = pygame.surfarray.array2d(canvas) cv2.imwrite(file, rgb_content, [cv2.IMWRITE_PNG_COMPRESSION, 0]) I've tried this but it doesn't work, because it flips the image sideways. Makes it grayscale and doesn't actually save it. 回答1: Use the save function of the image modul: pygame.image.save() save an image to disk save(Surface, filename) -> None This will save your Surface as either a BMP, TGA, PNG, or JPEG image. If the

Generating a Voronoi Diagram around 2D Polygons

久未见 提交于 2020-08-24 04:50:59
问题 I'm trying to create a Voronoi diagram around 2D holes (preferably in PyGame or scipy, but not necessary) and save the edges. It should look something like this: I have been able to use scipy's Voronoi to generate a diagram around points, but I'm not sure how to proceed with 2D obstacles. My code for working with points is: self.vor = Voronoi(POINTS) # iterate over voronoi graph and save edges for vpair in self.vor.ridge_vertices: if vpair[0] >= 0 and vpair[1] >= 0: # vertices v0 = self.vor

Generating a Voronoi Diagram around 2D Polygons

穿精又带淫゛_ 提交于 2020-08-24 04:50:19
问题 I'm trying to create a Voronoi diagram around 2D holes (preferably in PyGame or scipy, but not necessary) and save the edges. It should look something like this: I have been able to use scipy's Voronoi to generate a diagram around points, but I'm not sure how to proceed with 2D obstacles. My code for working with points is: self.vor = Voronoi(POINTS) # iterate over voronoi graph and save edges for vpair in self.vor.ridge_vertices: if vpair[0] >= 0 and vpair[1] >= 0: # vertices v0 = self.vor

Displaying unicode symbols using pygame

有些话、适合烂在心里 提交于 2020-08-20 07:07:19
问题 I've checked other answers, but cant see why my code incorrectly displays ♔. This is what I currently see Here is the relevant code about the text rendering. font = pygame.font.SysFont('Tahoma', 80, False, False) queenblack = "♔" queenblacktext = font.render(queenblack, True, BLACK) screen.blit(queenblacktext, [80, 80]) pygame.display.flip() All help us appreciated, thanks. Im using python 3.8, and using Pycharm. 回答1: The unicode character is not provided by the "Tahoma" font. Use the

学会Python除了不能生孩子,其他的都能做。

£可爱£侵袭症+ 提交于 2020-08-20 06:15:19
随着人工智能的迅猛发展,相信大家对于it行业最熟悉的词莫过于 Python。 那么,Python究竟可以做些什么呢? 一个资深程序员说:“学会Python除了不能生孩子,其他的都能做。” 加入313782132,即可领取测试学习资料、面试技巧、内推机会。 1、Web应用程序 你可以简单理解成一个网站,例如豆瓣网站就是用Python写的。 Python拥有很多Web开发框架,如:Django和Pyramid、Flask等。 它们号称可以用更少的代码更快的帮你搭建完成Web应用程序。 2、桌面GUI程序 简单来讲就是可视化的程序。例如我们电脑桌面上的图标等都是GUI程序,它的专业名词是Graphical User Interface,即图形用户界面。 3、爬虫 这玩意的重要性不用我多说了吧。大数据挖掘与分析的基本技能点。在生活中的应用方方面面。最简单的如我写个爬虫爬取某音用户爱好的数据,可以轻松帮助我开号定位。如果你对Python爬虫感兴趣的话,可以下方留言扣1,后续我会出个简单的爬虫入门教程。 4、 数据处理与可视化 Python被广泛应用于数值与科学计算。它提供的pandas对于处理数据来说非常方便。matplotlib库可以帮助你快速将数据可视化成图形。例如我们日常使用到的地图: 5、机器学习 Python有很多第三方库能让你更快进行搜索引擎开发、面部识别技术等