[Gambas-user] gb3: assigning a color to a variable of Color datatype
Kevin Fishburne
kevinfishburne at ...1887...
Thu Jun 23 03:31:09 CEST 2011
On 06/22/2011 09:20 PM, Caveat wrote:
> 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
>
Awesome, it works. Thank you. :) That is a bit counterintuitive, but
good to know.
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
More information about the User
mailing list