Source File
color_space.go
Belonging Package
github.com/pancsta/d2/d2renderers/d2raster
package d2rasterimport// COLRv1 gradient stops use byte channels, so their sRGB decoding has only// 256 possible inputs. Decode each value once instead of evaluating the power// function for both endpoints of every painted pixel.var linearSRGBByte = func() [256]float64 {var [256]float64for := range {[] = srgbToLinear(float64() / 255)}return}()func srgbToLinear( float64) float64 {= math.Max(0, math.Min(1, ))if <= 0.04045 {return / 12.92}return math.Pow((+0.055)/1.055, 2.4)}func premultipliedSRGBByteToLinear(, uint8) float64 {if == 0 {return 0}if == 0xff {return linearSRGBByte[]}return srgbToLinear(float64() / float64())}func linearToSRGB( float64) float64 {= math.Max(0, math.Min(1, ))if <= 0.0031308 {return 12.92 *}return 1.055*math.Pow(, 1/2.4) - 0.055}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |