On Sun, May 24, 2020 at 7:03 AM Ivo Fokkema <[email protected]> wrote:
> Thanks for your reply, Claudio!
>
> I couldn't access the links from your original message from 2013, so
> unfortunately I don't know if that information applies here.
>
It probably was the same as
https://groups.google.com/d/msg/pyglet-users/dke1e97EUjU/TOpZ18ttF7sJ
https://groups.google.com/d/msg/pyglet-users/OTuYVlJwXb8/72NnxqQ6mTEJ
> If I were more fluent in Python, it would've been easier for me to set up
> some virtual environments to try different versions of everything.
>
A starting point can be to experiment with the suggestions made in those
thread.
I attached a script that can be a starting point for that; you need to edit
the params to suit your case (read the comments there please)
--
claudio
>
>>
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/cocos-discuss/CAP3BN9WV7DnsGPSroS8UoQ6OiG4CPOt0TrtuHq6bwGP0bnonzg%40mail.gmail.com.
import pyglet
from pyglet.sprite import Sprite
from pyglet.gl import GL_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, glClearColor
##References:
## https://groups.google.com/d/msg/pyglet-users/dke1e97EUjU/TOpZ18ttF7sJ
## https://groups.google.com/d/msg/pyglet-users/OTuYVlJwXb8/72NnxqQ6mTEJ
##
https://www.tartley.com/use-light-opacity-rgba-to-fix-halo-artifacts-along-edges-of-textures
# params; notice that when changing from 'default' to 'alt_1' you need to
# change the img to one which have been converted to premultiplied alpha.
# this can help with that:
#
https://stackoverflow.com/questions/6591361/method-for-converting-pngs-to-premultiplied-alph
img_name = 'grossini.png'
repeats = 500
bg_color_u4 = (255, 255, 255, 255)
blend_mode = "default"
##############################
blend_modes = {
"default": {"blend_src": GL_SRC_ALPHA, "blend_dest": GL_ONE_MINUS_SRC_ALPHA
},
"alt_1": {"blend_src": GL_ONE, "blend_dest": GL_ONE_MINUS_SRC_ALPHA },
}
window = pyglet.window.Window(640, 480)
img = pyglet.resource.image(img_name)
w, h = window.width, window.height
x = (w - img.width) // 2; y = (h - img.height) // 2
sps = [Sprite(img, x=x, y=y, **blend_modes[blend_mode]) for i in range(repeats)]
glClearColor(*bg_color_u4)
@window.event
def on_draw():
window.clear()
for b in sps:
b.draw()
def update(dt):
pass
if __name__ == '__main__':
pyglet.clock.schedule_interval(update, 1 / 30.)
pyglet.app.run()