[FUNC] LinearGradient

Post your working scripts, libraries and tools
just me
Posts: 8699
Joined: 02 Oct 2013, 08:51
Location: Germany

[FUNC] LinearGradient

22 May 2014, 03:11

This thread remembered me of a script I published in the other forum at /board/topic/73038-func-lineargradient-create-your-own-gradients/ in 2011. So I've moved it.
This is a variation of an older script. You may use the function to fill a GUI Picture control with a linear gradient bitmap. At the best all you have to do is:
  1. Create a Picture control and get it's HWND (e.g. with the option hwndOutputVarHwnd).
  2. Create an array of (at least two) integer RGB color values in left/right respectively top/bottom order.
  3. Call the function passing the control's HWND and the color array.
  4. Get a horizontal linear gradient as shown in the image.
Optional parameters:
  • oPositions:
    By default colors are evenly distributed from left to right / top to bottom. If you want to set the positions manually, pass an array containing the position of each color as a floating-point value starting with 0.0 (left/top) for the first color and ending with 1.0 (right/bottom) for the last color.
  • D (Direction):
    By default (0) the function creates a horizontal gradient. For other options look at the inline documentation, please.
  • GC (Gamma Correction):
    By default (0) gamma correction is turned off. You can pass 1 to turn it on.
  • BW / BH:
    By default the line gradient brush has the same size as the control's client area. You may play around with smaller values for the width (BW) and/or the height (BH) to get some "special effects".
Look at GitHub.
Download from GitHub.
User avatar
Posts: 694
Joined: 29 Sep 2013, 17:34

Re: [FUNC] LinearGradient

13 Oct 2018, 09:07

Looks useful for a for-fun project that I'm working on. Thanks for sharing.

Sorry for the necro bump. This post is very old.
User avatar
Posts: 354
Joined: 26 Oct 2018, 08:14

Re: [FUNC] LinearGradient

06 Apr 2021, 07:22

This is great! Thank you very much! It's very useful!


Return to “Scripts and Functions”

Who is online

Users browsing this forum: imkira3 and 27 guests