Page 1 of 2

Ruby Dropshadow Tool

PostPosted: Sat Mar 06, 2021 1:54 pm
by adamszabo
Here is a tool for creating dropshadows for your shapes, instead of using photoshop. You can dynamically change it any way you like. I used it in my projects, I thought I'd share it with you all. Feel free to improve it ;)

Re: Ruby Dropshadow Tool

PostPosted: Sat Mar 06, 2021 4:31 pm
by Spogg
Very impressive Adam! :shock:

Thank you for sharing!

Re: Ruby Dropshadow Tool

PostPosted: Sat Mar 06, 2021 6:24 pm
by RJHollins
Nice !

Thank you for sharing Adam 8-)

Re: Ruby Dropshadow Tool

PostPosted: Sat Mar 06, 2021 8:53 pm
by tulamide
I feel like a father seeing his son going to college! I even have a tear in my eyes.

There are other ways to do it, and probably ways that are quicker, but this is a solid approach to the topic and I just love seeing it done by Adam! Good job!

Re: Ruby Dropshadow Tool

PostPosted: Sun Mar 07, 2021 5:26 pm
by adamszabo
Thanks guys, Im glad you like it ;)

tulamide wrote:There are other ways to do it, and probably ways that are quicker


I would love to see a faster way for learning purposes :ugeek:

Re: Ruby Dropshadow Tool

PostPosted: Tue Mar 09, 2021 2:15 pm
by kortezzzz
Thank you a lot, Adam. that's a great share 8-)

Am I wrong or this method can be used not only with Ruby own drawn shapes but also with png images?...

Re: Ruby Dropshadow Tool

PostPosted: Tue Mar 09, 2021 2:19 pm
by adamszabo
kortezzzz wrote:Thank you a lot, Adam. that's a great share 8-)

Am I wrong or this method can be used not only with Ruby own drawn shapes but also with png images?...


hmm I am not sure, I havent tried it, but I guess it could be possible to draw png images over each other and it can change its opacity to create the shadow effect.

Re: Ruby Dropshadow Tool

PostPosted: Tue Mar 09, 2021 4:10 pm
by kortezzzz
adamszabo wrote:I guess it could be possible to draw png images over each other and it can change its opacity to create the shadow effect.


Interesting idea :idea:
So what's actually needed is a Ruby command that may darken the second duplicated image. Guess maybe one of our experts here knows if something like that is achieveable?

Re: Ruby Dropshadow Tool

PostPosted: Tue Mar 09, 2021 8:57 pm
by tulamide
kortezzzz wrote:
adamszabo wrote:I guess it could be possible to draw png images over each other and it can change its opacity to create the shadow effect.


Interesting idea :idea:
So what's actually needed is a Ruby command that may darken the second duplicated image. Guess maybe one of our experts here knows if something like that is achieveable?

No. But you can pre-edit your images to a darkened version and use that.

Re: Ruby Dropshadow Tool

PostPosted: Tue Mar 09, 2021 9:04 pm
by tulamide
adamszabo wrote:I would love to see a faster way for learning purposes :ugeek:

Here you are. Note, that it is just a prototype. Lots of knobs to play with and lots of code to explore (mostly helper methods). The core is using GDI+ to calculate everything, so it's as fast as it gets. One exception is the shadow_transform() method. Unfortunately Flowstone doesn't provide access to the results of matrix manipulations (like translate) and so I had to do all the calculations manually to have access to the results. It's not much though (but if there are any takers to optimize my rather straight-forward math, go for it).