Draw a portion of a gradient?
Posted: 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.
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.