*: update vendor

This commit is contained in:
Gyu-Ho Lee 2016-12-28 15:44:02 -08:00
parent 62c7f5994a
commit 46fdf548f3
No known key found for this signature in database
GPG Key ID: 1DDD39C7EB70C24C
4 changed files with 95 additions and 17 deletions

10
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: d4a1ceef843a6f16e969081a50aeb9117cdca088ddee1f652b847f1bf322a03d
updated: 2016-12-20T12:42:08.836209288-08:00
hash: 7850f7d4bf167faa9184167415a18cd1fef5a02be107f31c4721bcc90b2bc5b7
updated: 2016-12-28T15:43:23.865399282-08:00
imports:
- name: bitbucket.org/zombiezen/gopdf
version: 1c63dc69751bc45441c2ce1f56b631c55294b4d5
@ -25,7 +25,7 @@ imports:
- name: github.com/cheggaaa/pb
version: 6e9d17711bb763b26b68b3931d47f24c1323abab
- name: github.com/coreos/etcd
version: d62ce55584a064968c11b309f1d57a9c1872bc40
version: 1643ed56679abba9b0305bfa5490941fd68e3233
subpackages:
- auth/authpb
- client
@ -71,7 +71,7 @@ imports:
subpackages:
- asm
- name: github.com/gonum/plot
version: 9cd91e61771cdd73e563fa54f1fdc3b1071af62d
version: 235bd2a77303194e06d44c3ae432ac676bf041d0
subpackages:
- palette
- plotter
@ -153,7 +153,7 @@ imports:
subpackages:
- codec
- name: golang.org/x/image
version: f1b1ff53e10e288d0ab6f161067c0a69b72cee28
version: 3ba119400e6fd98bf5100d1c17303c377b6521e9
subpackages:
- draw
- font

View File

@ -9,7 +9,7 @@ import:
- package: github.com/cheggaaa/pb
version: 6e9d17711bb763b26b68b3931d47f24c1323abab
- package: github.com/coreos/etcd
version: d62ce55584a064968c11b309f1d57a9c1872bc40
version: 1643ed56679abba9b0305bfa5490941fd68e3233
subpackages:
- auth/authpb
- client
@ -38,7 +38,7 @@ import:
- jsonpb
- proto
- package: github.com/gonum/plot
version: 9cd91e61771cdd73e563fa54f1fdc3b1071af62d
version: 235bd2a77303194e06d44c3ae432ac676bf041d0
subpackages:
- palette
- plotter

View File

@ -10,6 +10,7 @@
package palette
import (
"errors"
"image/color"
"math"
)
@ -31,6 +32,56 @@ type DivergingPalette interface {
CriticalIndex() (low, high int)
}
// A ColorMap maps scalar values to colors.
type ColorMap interface {
// At returns the color associated with the given value.
// If the value is not between Max() and Min(), an error is returned.
At(float64) (color.Color, error)
// Max returns the current maximum value of the ColorMap.
Max() float64
// SetMax sets the maximum value of the ColorMap.
SetMax(float64)
// Min returns the current minimum value of the ColorMap.
Min() float64
// SetMin sets the minimum value of the ColorMap.
SetMin(float64)
// Alpha returns the opacity value of the ColorMap.
Alpha() float64
// SetAlpha sets the opacity value of the ColorMap. Zero is transparent
// and one is completely opaque. The default value of alpha should be
// expected to be one. The function should be expected to panic
// if alpha is not between zero and one.
SetAlpha(float64)
// Palette creates a Palette with the specified number of colors
// from the ColorMap.
Palette(colors int) Palette
}
// DivergingColorMap maps scalar values to colors that diverge
// from a central value.
type DivergingColorMap interface {
ColorMap
// SetConvergePoint sets the value where the diverging colors
// should meet. The default value should be expected to be
// (Min() + Max()) / 2. It should be expected that calling either
// SetMax() or SetMin() will set a new default value, so for a
// custom convergence point this function should be called after
// SetMax() and SetMin(). The function should be expected to panic
// if the value is not between Min() and Max().
SetConvergePoint(float64)
// ConvergePoint returns the value where the diverging colors meet.
ConvergePoint() float64
}
// Hue represents a hue in HSV color space. Valid Hues are within [0, 1].
type Hue float64
@ -43,6 +94,20 @@ const (
Magenta
)
var (
// ErrOverflow is the error returned by ColorMaps when the specified
// value is greater than the maximum value.
ErrOverflow = errors.New("palette: specified value > maximum")
// ErrUnderflow is the error returned by ColorMaps when the specified
// value is less than the minimum value.
ErrUnderflow = errors.New("palette: specified value < minimum")
// ErrNaN is the error returned by ColorMaps when the specified
// value is NaN.
ErrNaN = errors.New("palette: specified value == NaN")
)
// Complement returns the complementary hue of a Hue.
func (h Hue) Complement() Hue { return Hue(math.Mod(float64(h+0.5), 1)) }

View File

@ -220,7 +220,9 @@ func BoundBytes(f Face, s []byte) (bounds fixed.Rectangle26_6, advance fixed.Int
// TODO: set prevC = '\ufffd'?
continue
}
bounds = grow(bounds, b, advance)
b.Min.X += advance
b.Max.X += advance
bounds = grow(bounds, b)
advance += a
prevC = c
}
@ -242,25 +244,36 @@ func BoundString(f Face, s string) (bounds fixed.Rectangle26_6, advance fixed.In
// TODO: set prevC = '\ufffd'?
continue
}
bounds = grow(bounds, b, advance)
b.Min.X += advance
b.Max.X += advance
bounds = grow(bounds, b)
advance += a
prevC = c
}
return
}
// grow returns the smallest rectangle containing both b and b2+shift.
func grow(b, b2 fixed.Rectangle26_6, shift fixed.Int26_6) fixed.Rectangle26_6 {
x := b2.Min.X + shift
if b.Min.X > x {
b.Min.X = x
func empty(r fixed.Rectangle26_6) bool {
return r.Min.X >= r.Max.X || r.Min.Y >= r.Max.Y
}
// grow returns the smallest rectangle containing both b and b2.
func grow(b, b2 fixed.Rectangle26_6) fixed.Rectangle26_6 {
if empty(b) {
return b2
}
if empty(b2) {
return b
}
if b.Min.X > b2.Min.X {
b.Min.X = b2.Min.X
}
if b.Min.Y > b2.Min.Y {
b.Min.Y = b2.Min.Y
}
x = b2.Max.X + shift
if b.Max.X < x {
b.Max.X = x
if b.Max.X < b2.Max.X {
b.Max.X = b2.Max.X
}
if b.Max.Y < b2.Max.Y {
b.Max.Y = b2.Max.Y