如何在 PyGame 中编辑图像的亮度? [英] How can you edit the brightness of images in PyGame?
问题描述
我正在尝试在 python/pygame 中制作 OpenGL,但我不知道如何添加阴影.我不想为我的游戏制作很多较暗的图像.有人可以帮我吗?
I'm trying to make an OpenGL in python/pygame but I don't know how to add shadow. I don't want to make a lot of darker images for my game. Can someone help me?
推荐答案
我不是 Python 专家,但你可以试试:
I am no expert in Python but you could try:
将图像的颜色乘以0.1、0.2、0.3(小于1的任何值)
之类的值,这将为您提供非常暗的纹理.这将是最简单的方法,因为它只涉及减少该纹理的颜色值.
Multiply the color of the image by a value like 0.1, 0.2, 0.3 (anything less that 1)
which will give you a very dark texture. This would be the easiest method as it involves just reducing the color values of that texture.
或者您可以尝试更复杂的方法,例如在原始图像上绘制一个透明的黑色四边形,使其看起来像是在阴影中.
Or you could try a more complex method such as drawing a transparent black quad over the original image to give it the illusion of being in a shadow.
这篇关于如何在 PyGame 中编辑图像的亮度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!