basic HTTP api and uistate.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package color
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/lucasb-eyer/go-colorful"
|
||||
"math"
|
||||
@@ -15,6 +16,21 @@ type Color struct {
|
||||
XY *XY `json:"xy,omitempty"`
|
||||
}
|
||||
|
||||
func (col *Color) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(col.String())
|
||||
}
|
||||
|
||||
func (col *Color) UnmarshalJSON(bytes []byte) error {
|
||||
var s string
|
||||
err := json.Unmarshal(bytes, &s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*col, err = Parse(s)
|
||||
return err
|
||||
}
|
||||
|
||||
func (col *Color) IsHueSat() bool {
|
||||
return col.HS != nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user