draw glowing lines with Kivy?

瀏覽次數:331 次
跳到第一則未讀訊息

Bill Janssen

未讀,
2015年6月23日 下午6:15:422015/6/23
收件者: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

未讀,
2015年6月23日 下午6:18:202015/6/23
收件者: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

未讀,
2015年6月23日 晚上7:06:552015/6/23
收件者:kivy-...@googlegroups.com
Thanks for the pointers, I'll check out the EffectWidget.

Bill

Bill Janssen

未讀,
2015年6月23日 晚上7:18:122015/6/23
收件者: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

未讀,
2015年6月23日 晚上7:22:302015/6/23
收件者: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

未讀,
2015年6月24日 下午6:36:182015/6/24
收件者: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

未讀,
2015年6月25日 晚上9:29:282015/6/25
收件者:kivy-...@googlegroups.com
I've got the effect that I wanted (see attached).  Thanks for the help.

Bill
app.py

ZenCODE

未讀,
2015年6月26日 凌晨2:08:232015/6/26
收件者:kivy-...@googlegroups.com
@Bill Janssen. Thanks for posting the solution. Will add that to the docs shortly...;-)

Milos Bulatovic

未讀,
2015年6月26日 凌晨3:32:052015/6/26
收件者:kivy-...@googlegroups.com
Thanks for this!

Bill Janssen

未讀,
2015年6月26日 中午12:57:392015/6/26
收件者: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

未讀,
2015年6月28日 凌晨4:14:422015/6/28
收件者: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

未讀,
2015年6月28日 清晨6:12:302015/6/28
收件者: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

未讀,
2015年6月28日 下午3:39:342015/6/28
收件者: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

未讀,
2015年6月28日 下午3:44:022015/6/28
收件者: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

未讀,
2015年7月11日 下午5:10:122015/7/11
收件者: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
回覆所有人
回覆作者
轉寄
0 則新訊息