-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to define rectangle layers with colors and gradients
- Loading branch information
Erik Veld
committed
May 18, 2021
1 parent
4f989b1
commit 895f301
Showing
5 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package pkg | ||
|
||
import ( | ||
"fmt" | ||
"image/color" | ||
) | ||
|
||
func ParseHexColor(s string) (c color.RGBA, err error) { | ||
c.A = 0xff | ||
switch len(s) { | ||
case 7: | ||
_, err = fmt.Sscanf(s, "#%02x%02x%02x", &c.R, &c.G, &c.B) | ||
case 4: | ||
_, err = fmt.Sscanf(s, "#%1x%1x%1x", &c.R, &c.G, &c.B) | ||
// Double the hex digits: | ||
c.R *= 17 | ||
c.G *= 17 | ||
c.B *= 17 | ||
default: | ||
err = fmt.Errorf("invalid length, must be 7 or 4") | ||
|
||
} | ||
return | ||
} |