[Gambas-user] gb3: assigning a color to a variable of Color datatype
Caveat
Gambas at ...1950...
Thu Jun 23 03:20:04 CEST 2011
Morning Kevin
Color.RGB returns an Integer, not an object of type Color
See http://gambasdoc.org/help/comp/gb.qt/color/rgb
So I think your SolarCurrent needs to be an integer (Color is a static
class mainly for convenience really)
Regards,
Caveat
On Wed, 2011-06-22 at 20:59 -0400, Kevin Fishburne wrote:
> The code:
>
> SolarCurrent = Color.RGB(Convert.Range(HourCurrent, 0, 0.125,
> sol_midnightr, sol_dawnr), Convert.Range(HourCurrent, 0, 0.125,
> sol_midnightg, sol_dawng), Convert.Range(HourCurrent, 0, 0.125,
> sol_midnightb, sol_dawnb), Convert.Range(HourCurrent, 0, 0.125,
> sol_midnighta, sol_dawna))
>
> Type mismatch: wanted Color got Integer instead
>
> Color.RGB(Convert.Range(HourCurrent, 0, 0.125, sol_midnightr,
> sol_dawnr), Convert.Range(HourCurrent, 0, 0.125, sol_midnightg,
> sol_dawng), Convert.Range(HourCurrent, 0, 0.125, sol_midnightb,
> sol_dawnb), Convert.Range(HourCurrent, 0, 0.125, sol_midnighta, sol_dawna))
>
> by itself returns 520093711, so everything after the = works fine. The
> function Convert.Range returns a single, so basically the logic is:
>
> SolarCurrent = Color.RGB(singleR, singleG, singleB, singleA)
>
> SolarCurrent is fined as a color:
>
> Dim SolarCurrent As Color ' Current color of sunlight.
>
> Any idea what's happening here? Seems like it should just work, so I
> must be missing something.
>
> Just in case it matters, the Convert.Range function looks like this:
>
> Public Function Range(Range1Value As Single, Range1Minimum As Single,
> Range1Maximum As Single, Range2Minimum As Single, Range2Maximum As
> Single) As Single
>
> ' Convert value in range 1 to number in range 2.
>
> ' Convert and return the value.
> Return (((Range1Value - Range1Minimum) * (Range2Maximum -
> Range2Minimum)) / (Range1Maximum - Range1Minimum)) + Range2Minimum
>
> End
>
>
More information about the User
mailing list