draw glowing lines with Kivy?

331 views
Skip to first unread message

Bill Janssen

unread,
Jun 23, 2015, 6:15:42 PM6/23/15
to kivy-...@googlegroups.com
I'm trying to figure out how to draw lines with a glowing or neon effect, a solid line with a fuzzy border.  Should be able to do this in OpenGL, but I haven't been able to figure it out.  Any graphics hackers out there know how to do this?

Thanks.

Bill

Alexander Taylor

unread,
Jun 23, 2015, 6:18:20 PM6/23/15
to kivy-...@googlegroups.com
I'm not sure exactly what kind of fuzziness is called for, but have you tried the SmoothLine canvas instruction (experimental but if the edges look right you can start there)? You could also try putting normal lines in an EffectWidget with a BlurEffect, or potentially your own shader effect.

Bill Janssen

unread,
Jun 23, 2015, 7:06:55 PM6/23/15
to kivy-...@googlegroups.com
Thanks for the pointers, I'll check out the EffectWidget.

Bill

Bill Janssen

unread,
Jun 23, 2015, 7:18:12 PM6/23/15
to kivy-...@googlegroups.com
Hmmm, I can't seem to add an EffectWidget to my RelativeLayout ("object has no attribute '_trigger_layout'"), nor can I mix the class in with RelativeLayout ("object has no attribute 'fbo'")

I don't think this widget is quite ready yet.

Bill

On Tuesday, June 23, 2015 at 3:18:20 PM UTC-7, Alexander Taylor wrote:

Alexander Taylor

unread,
Jun 23, 2015, 7:22:30 PM6/23/15
to kivy-...@googlegroups.com
EffectWidget actually is itself a RelativeLayout, so you could just
replace your RelativeLayout with an EffectWidget.

We don't support mixing widget classes by inheriting from both, but
adding the EffectWidget to a RelativeLayout should work. I just did a
quick test and it did. Are you able to share an example where it fails?
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/CJLk0ggIy5A/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


signature.asc

Bill Janssen

unread,
Jun 24, 2015, 6:36:18 PM6/24/15
to kivy-...@googlegroups.com
Hi, Alexander.

I have other children of my relative layout that I didn't want affected.  I really just want a writing surface, so perhaps an EffectWidget with a blank Widget on top, and draw on the blank widget.  I'll put together a simple example.

Bill

Bill Janssen

unread,
Jun 25, 2015, 9:29:28 PM6/25/15
to kivy-...@googlegroups.com
I've got the effect that I wanted (see attached).  Thanks for the help.

Bill
app.py

ZenCODE

unread,
Jun 26, 2015, 2:08:23 AM6/26/15
to kivy-...@googlegroups.com
@Bill Janssen. Thanks for posting the solution. Will add that to the docs shortly...;-)

Milos Bulatovic

unread,
Jun 26, 2015, 3:32:05 AM6/26/15
to kivy-...@googlegroups.com
Thanks for this!

Bill Janssen

unread,
Jun 26, 2015, 12:57:39 PM6/26/15
to kivy-...@googlegroups.com
It would be nice if I could draw directly on the EffectWidget, instead of having to create an extra widget just to draw on.  But that doesn't seem to work.

Bill

ZenCODE

unread,
Jun 28, 2015, 4:14:42 AM6/28/15
to kivy-...@googlegroups.com
@Bill Jansen. Well, the EffectWidget is just a supercharged RelativeLayout. so you can draw on it, add widgets to it etc. just like any other RelativeLayout?

Alexander Taylor

unread,
Jun 28, 2015, 6:12:30 AM6/28/15
to kivy-...@googlegroups.com
ZenCode: The issue is that canvas instructions added directly to the
EffectWidget are not subject to effects, only its child widgets (and
their own trees of instructions) are.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Kivy users support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/kivy-users/CJLk0ggIy5A/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> kivy-users+...@googlegroups.com
> <mailto:kivy-users+...@googlegroups.com>.
signature.asc

ZenCODE

unread,
Jun 28, 2015, 3:39:34 PM6/28/15
to kivy-...@googlegroups.com
 @Alexander Taylor

Ah, thanks, now it get. It's easy enough to just use a nested child, but Bill pointed that out already :-). I wonder, is that is 'by design'? Is there is a reason for that? I see you did work on this widget...

Either way, that is worth noting in the docs. Will do that shortly. Tx

Alexander Taylor

unread,
Jun 28, 2015, 3:44:02 PM6/28/15
to kivy-...@googlegroups.com
The reason is that effects are applied by drawing things to an Fbo, made
automatic by overriding add_widget. However, it can't just override all
drawing because the widget has to draw a Rectangle (and maybe other
stuff) that actually display the result from applying the effects, so
the canvas acts as normal and doesn't have effects applied.

It would probably be possible to make this work, but it would be
necessary to capture some (not all) canvas drawing and redirect it,
while keeping the normal canvas as a child of the parent class. I
couldn't think of a nice way to do it.
signature.asc

Bill Janssen

unread,
Jul 11, 2015, 5:10:12 PM7/11/15
to kivy-...@googlegroups.com
So, can we bump this up a notch?  I'd now like to build coruscating glowing lines, a la Star Wars light sabers, in honor of the upcoming next Star Wars segment.  But it looks like animation can only be done on certain Kivy properties of widgets, not arbitrarily.  So how would we make the glowing lines flicker?  I could see doing a Clock callback over and over, changing the graphics slightly each time.  But there must be a better way!

Bill
Reply all
Reply to author
Forward
0 new messages