Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Draw a portion of a gradient?

For general discussion related FlowStone

Draw a portion of a gradient?

Postby Perfect Human Interface » Sun Aug 31, 2014 4:15 pm

Hi all. I'm working on some GUI elements currently, and I know often with things like bar meters and slider controls it's common to have gradients on them. However if you simply draw a gradient in FS to the dimensions of the bar, the full range of the gradient is always scaled to the height of the bar (meaning even if the bar is at 25% it scales 100% of the gradient within that area) and it looks funny.

One possible solution to this is to draw the gradient full-scale, then draw a "background" color on top of the gradient to be the negative space in the bar/meter. This works perfectly fine, however, it doesn't allow for proper transparency if you wanted something other than a solid drawn color as the background.

Seeking another solution to this, I thought I could use Float to Area with the Redraw Area primitive to simply draw a portion of the gradient in the view. I tried this, but I realized (if I'm not mistaken) that even if it's only "redrawing" that area, the rest of the area in the view is still "drawn" and doesn't just un-draw itself (I think that's how it works).

So what I'm seeking is a way to draw this gradient bar without scaling the gradient and while achieving proper transparency. Any input is welcome and appreciated.

Edit: I believe I could use the method I attempted before if I also redraw a background element before redrawing the gradient area, but I would much prefer to maintain "true" transparency without having to specify a background, such that anything I place this over will show through.

I think I may be able to fake it by drawing the full gradient scaled, but adjusting the 2nd color closer to the first as it's drawn smaller. Since the gradient is linear, I think that will work? I'm not sure how to blend colors given just RGB/HSV but I think I can look that up.
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Draw a portion of a gradient?

Postby TheOm » Sun Aug 31, 2014 5:00 pm

I think you might be looking for the clip primitive.
Attachments
clip.fsm
(7.41 KiB) Downloaded 828 times
TheOm
 
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: Draw a portion of a gradient?

Postby Perfect Human Interface » Sun Aug 31, 2014 5:38 pm

Works beautifully. Thanks so much. :)
Perfect Human Interface
 
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Draw a portion of a gradient?

Postby Nubeat7 » Sun Aug 31, 2014 5:51 pm

in ruby you can define an area for the gradient brush (whole size) and an area to draw (value)
Attachments
schematic1.fsm
(7.33 KiB) Downloaded 785 times
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: Draw a portion of a gradient?

Postby tulamide » Mon Sep 01, 2014 3:24 pm

Just one week in hospital and already so much to read! You're first :P

Perfect Human Interface wrote:I'm not sure how to blend colors given just RGB/HSV but I think I can look that up.
You already got the help you needed, but since the following is a more general question I thought I'd point to my linear color interpolation module, which does exactly that. Since it's "green" you should be able to follow its logic.
Linear Color Interpolation
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany


Return to General

Who is online

Users browsing this forum: No registered users and 64 guests