label gradient

51 views
Skip to first unread message

Peter Varo

unread,
Oct 12, 2013, 10:24:54 AM10/12/13
to pyglet...@googlegroups.com
Hello everyone,

I'm looking for a solution to create a linear gradient label in pyglet.
AFAIK the glyphs are textured GL_QUADS, so theoretically all I have to do is add 4 colors to the 4 vertices:

    # V0 and V1 are the bottom, and V2 and V3 are the top
    ('c4B', (0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255))


Although pyglet.text.Label only has a single color attribute, that can only handle a single quadlet-tuple of a color.
What is the proper way of doing this?

Thanks in advance!

Akuji FooBar

unread,
Oct 15, 2013, 8:00:47 AM10/15/13
to pyglet...@googlegroups.com
I think the easiest way to render the label is to use an image editing program, like gimp.

Peter Varo

unread,
Oct 19, 2013, 8:53:15 PM10/19/13
to pyglet...@googlegroups.com
And how exactly GIMP is related to Pyglet and pyglet.text.Label?

Akuji

unread,
Oct 20, 2013, 2:22:59 PM10/20/13
to pyglet...@googlegroups.com
It is not. My suggestion was simply to draw the label with an image editing program, save it as a texture or an image and load it into your program.


On Sat, Oct 19, 2013 at 9:53 PM, Peter Varo <hecs...@gmail.com> wrote:
And how exactly GIMP is related to Pyglet and pyglet.text.Label?

--
You received this message because you are subscribed to a topic in the Google Groups "pyglet-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyglet-users/j2HCtvQ-BIg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyglet-users...@googlegroups.com.
To post to this group, send email to pyglet...@googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Richard Jones

unread,
Oct 20, 2013, 6:26:16 PM10/20/13
to pyglet-users
I can think of three ways to achieve the goal, off the top of my head, no code written:

1. manually construct a texture using the rendered text textures generated by pyglet as the alpha channel in a texture with the gradient in the colour components. Hard.
2. use a fragment shader to combine two textures - the text render and a gradient texture. Easier.
3. use a fragment shader to generate the gradient colour to render on the fly when rendering the text texture, modulated by the colour from the text texture. Easiest.


    Richard



--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users...@googlegroups.com.

"Juan J. Martínez"

unread,
Oct 21, 2013, 3:27:51 AM10/21/13
to pyglet...@googlegroups.com
On 20/10/13 23:26, Richard Jones wrote:
> I can think of three ways to achieve the goal, off the top of my head,
> no code written:
>
> 1. manually construct a texture using the rendered text textures
> generated by pyglet as the alpha channel in a texture with the gradient
> in the colour components. Hard.
> 2. use a fragment shader to combine two textures - the text render and a
> gradient texture. Easier.
> 3. use a fragment shader to generate the gradient colour to render on
> the fly when rendering the text texture, modulated by the colour from
> the text texture. Easiest.

Bonus! if you want to play with shaders, I've found this class from
Cocos2D very useful:

http://los-cocos.googlecode.com/svn/trunk/cocos/shader.py

Regards,

Juan

Reply all
Reply to author
Forward
0 new messages