[Qgis-developer] Transparency/Opacity (was: Outline/border -> stroke? )

Nyall Dawson nyall.dawson at gmail.com
Mon Feb 27 21:34:25 PST 2017


On 21 February 2017 at 00:31, Matthias Kuhn <matthias at opengis.ch> wrote:
> I'd say in the API we should be closer to the data and hence use 0-255, in the slider we convert it to 0-100%.
> We could possibly have a slider that allows for 255 positions but prints numbers from 0%-100%?
>
> Are you aware of systems where there are more values than 8 bits for the alpha channel (for which we should prepare)?
> It wouldn't be a much bigger deal to go this road, but I think it shouldn't be purely prophylactic without real needs in mind.


Here's the tricky bit - using 0-255 and storing as an int doesn't
translate well to displaying in a slider with values from 0-100. You
need to allow 0.1 steps in the slider to avoid loss of precision, but
then you get the confusing behaviour for users where they set the
slider to 91.2, and reopen to find it's changed to 91.3 (made up
numbers).

I'd like to avoid that, so I think in api we should always use a
double with range 0-1 for storing opacity. This can be exposed to
users on a 0-100 scale, but also converted to a 0-255 int for
rendering/etc without issue.

Nyall


>
> Matthias
>
> On 02/20/2017 03:19 PM, John Hawkinson wrote:
>> > An outstanding question is what range we should allow? Behind the
>> > scenes it's generally going to be converted to a 0-255 value, but for
>> > users a 0-100% may be more explanatory. Opinions?
>>
>> The tools I use again express opacity in 0-100%, and I think that's
>> the correct thing for the user interface. Why should users presume
>> the internals are going to be 8-bit unsigned? Why shouldn't it be
>> 0-65536? Or floating point?
>>
>> > The API is ALL OVER THE PLACE here, and should also be fixed. We have
>> > a mix of transparency/opacity/alpha and ranges of 0-1, 0-100, 0-255.
>> > It's confusing for developers too!
>>
>> So, I imagine at some point in the future someone is going to
>> decide 8-bit alpha channels are too limiting. The API should
>> probably be forward-looking with respect to that. I'm not
>> sure exactly what that means, but to me it suggests
>> not 0-255. Maybe 0-1 floating point. But I dunno.
>>
>> --jhawk
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>


More information about the Qgis-developer mailing list