Exemple #1
0
    def test_set_rgba(self):
        img1 = ImagePRGBA(200, 200)
        code = """
set_rgba(img, 25, 25, (0.1, 0.2, 0.3, 0.4))
        """
        props = {'img': img1}
        bs = BasicShader(code, props)
        runtime = Runtime()
        bs.prepare([runtime])
        #print (bs.shader._code)

        bs.execute()

        val = img1.get_pixel(25, 25)
        self.assertAlmostEqual(val[0], 0.1, places=5)
        self.assertAlmostEqual(val[1], 0.2, places=5)
        self.assertAlmostEqual(val[2], 0.3, places=5)
        self.assertAlmostEqual(val[3], 0.4, places=5)
Exemple #2
0
    def test_set_rgba(self):
        img1 = ImagePRGBA(200, 200)
        code = """
set_rgba(img, 25, 25, (0.1, 0.2, 0.3, 0.4))
        """
        props = {'img': img1}
        bs = BasicShader(code, props)
        runtime = Runtime()
        bs.prepare([runtime])
        #print (bs.shader._code)

        bs.execute()

        val = img1.get_pixel(25, 25)
        self.assertAlmostEqual(val[0], 0.1, places=5)
        self.assertAlmostEqual(val[1], 0.2, places=5)
        self.assertAlmostEqual(val[2], 0.3, places=5)
        self.assertAlmostEqual(val[3], 0.4, places=5)
Exemple #3
0
from tdasm import Runtime
from renmas3.base import ImagePRGBA, arg_map, create_shader, Vec3

arg_map1 = arg_map([('image1', ImagePRGBA), ('value', Vec3)])

img1 = ImagePRGBA(1024, 768)

img1.set_pixel(10, 10, 0.4, 0.3, 0.2)
code = """
value = get_rgb(image1, 10, 10)

color = (0.1, 0.5, 0.6)
set_rgb(image1, 20, 20, color)
"""

shader = create_shader("test", code, arg_map1)
runtimes = [Runtime()]
shader.prepare(runtimes)
shader.set_value('image1', img1)
shader.execute()

print(shader.get_value('value'))
print(img1.get_pixel(20, 20))


Exemple #4
0
from renmas3.base import GraphicsRGBA, RGBSpectrum, ImagePRGBA, ImageRGBA
from renmas3.utils import blt_prgba_to_rgba, blt_rgba_to_prgba
from renmas3.win32 import show_image_in_window

img = ImageRGBA(400, 400)
gr = GraphicsRGBA()
gr.draw_rect(img, 20, 20, 80, 50, RGBSpectrum(0.6, 0.2, 0.4))

width, height = img.size()
img2 = ImagePRGBA(width, height)
blt_rgba_to_prgba(img, img2)

img3 = ImageRGBA(width, height)
blt_prgba_to_rgba(img2, img3)

print (img.get_pixel(25,25))
print (img2.get_pixel(25,25))
print (img3.get_pixel(25,25))
show_image_in_window(img3)