Vendorized libs
This commit is contained in:
27
vendor/golang.org/x/image/LICENSE
generated
vendored
Normal file
27
vendor/golang.org/x/image/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
22
vendor/golang.org/x/image/PATENTS
generated
vendored
Normal file
22
vendor/golang.org/x/image/PATENTS
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Additional IP Rights Grant (Patents)
|
||||
|
||||
"This implementation" means the copyrightable works distributed by
|
||||
Google as part of the Go project.
|
||||
|
||||
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||
patent license to make, have made, use, offer to sell, sell, import,
|
||||
transfer and otherwise run, modify and propagate the contents of this
|
||||
implementation of Go, where such license applies only to those patent
|
||||
claims, both currently owned or controlled by Google and acquired in
|
||||
the future, licensable by Google that are necessarily infringed by this
|
||||
implementation of Go. This grant does not include claims that would be
|
||||
infringed only as a consequence of further modification of this
|
||||
implementation. If you or your agent or exclusive licensee institute or
|
||||
order or agree to the institution of patent litigation against any
|
||||
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||
that this implementation of Go or any code incorporated within this
|
||||
implementation of Go constitutes direct or contributory patent
|
||||
infringement, or inducement of patent infringement, then any patent
|
||||
rights granted to you under this License for this implementation of Go
|
||||
shall terminate as of the date such litigation is filed.
|
||||
230
vendor/golang.org/x/image/font/font.go
generated
vendored
Normal file
230
vendor/golang.org/x/image/font/font.go
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package font defines an interface for font faces, for drawing text on an
|
||||
// image.
|
||||
//
|
||||
// Other packages provide font face implementations. For example, a truetype
|
||||
// package would provide one based on .ttf font files.
|
||||
package font
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/draw"
|
||||
"io"
|
||||
|
||||
"golang.org/x/image/math/fixed"
|
||||
)
|
||||
|
||||
// TODO: who is responsible for caches (glyph images, glyph indices, kerns)?
|
||||
// The Drawer or the Face?
|
||||
|
||||
// Face is a font face. Its glyphs are often derived from a font file, such as
|
||||
// "Comic_Sans_MS.ttf", but a face has a specific size, style, weight and
|
||||
// hinting. For example, the 12pt and 18pt versions of Comic Sans are two
|
||||
// different faces, even if derived from the same font file.
|
||||
//
|
||||
// A Face is not safe for concurrent use by multiple goroutines, as its methods
|
||||
// may re-use implementation-specific caches and mask image buffers.
|
||||
//
|
||||
// To create a Face, look to other packages that implement specific font file
|
||||
// formats.
|
||||
type Face interface {
|
||||
io.Closer
|
||||
|
||||
// Glyph returns the draw.DrawMask parameters (dr, mask, maskp) to draw r's
|
||||
// glyph at the sub-pixel destination location dot, and that glyph's
|
||||
// advance width.
|
||||
//
|
||||
// It returns !ok if the face does not contain a glyph for r.
|
||||
//
|
||||
// The contents of the mask image returned by one Glyph call may change
|
||||
// after the next Glyph call. Callers that want to cache the mask must make
|
||||
// a copy.
|
||||
Glyph(dot fixed.Point26_6, r rune) (
|
||||
dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool)
|
||||
|
||||
// GlyphBounds returns the bounding box of r's glyph, drawn at a dot equal
|
||||
// to the origin, and that glyph's advance width.
|
||||
//
|
||||
// It returns !ok if the face does not contain a glyph for r.
|
||||
//
|
||||
// The glyph's ascent and descent equal -bounds.Min.Y and +bounds.Max.Y. A
|
||||
// visual depiction of what these metrics are is at
|
||||
// https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png
|
||||
GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool)
|
||||
|
||||
// GlyphAdvance returns the advance width of r's glyph.
|
||||
//
|
||||
// It returns !ok if the face does not contain a glyph for r.
|
||||
GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool)
|
||||
|
||||
// Kern returns the horizontal adjustment for the kerning pair (r0, r1). A
|
||||
// positive kern means to move the glyphs further apart.
|
||||
Kern(r0, r1 rune) fixed.Int26_6
|
||||
|
||||
// Metrics returns the metrics for this Face.
|
||||
Metrics() Metrics
|
||||
|
||||
// TODO: ColoredGlyph for various emoji?
|
||||
// TODO: Ligatures? Shaping?
|
||||
}
|
||||
|
||||
// Metrics holds the metrics for a Face. A visual depiction is at
|
||||
// https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png
|
||||
type Metrics struct {
|
||||
// Height is the recommended amount of vertical space between two lines of
|
||||
// text.
|
||||
Height fixed.Int26_6
|
||||
|
||||
// Ascent is the distance from the top of a line to its baseline.
|
||||
Ascent fixed.Int26_6
|
||||
|
||||
// Descent is the distance from the bottom of a line to its baseline. The
|
||||
// value is typically positive, even though a descender goes below the
|
||||
// baseline.
|
||||
Descent fixed.Int26_6
|
||||
}
|
||||
|
||||
// TODO: Drawer.Layout or Drawer.Measure methods to measure text without
|
||||
// drawing?
|
||||
|
||||
// Drawer draws text on a destination image.
|
||||
//
|
||||
// A Drawer is not safe for concurrent use by multiple goroutines, since its
|
||||
// Face is not.
|
||||
type Drawer struct {
|
||||
// Dst is the destination image.
|
||||
Dst draw.Image
|
||||
// Src is the source image.
|
||||
Src image.Image
|
||||
// Face provides the glyph mask images.
|
||||
Face Face
|
||||
// Dot is the baseline location to draw the next glyph. The majority of the
|
||||
// affected pixels will be above and to the right of the dot, but some may
|
||||
// be below or to the left. For example, drawing a 'j' in an italic face
|
||||
// may affect pixels below and to the left of the dot.
|
||||
Dot fixed.Point26_6
|
||||
|
||||
// TODO: Clip image.Image?
|
||||
// TODO: SrcP image.Point for Src images other than *image.Uniform? How
|
||||
// does it get updated during DrawString?
|
||||
}
|
||||
|
||||
// TODO: should DrawString return the last rune drawn, so the next DrawString
|
||||
// call can kern beforehand? Or should that be the responsibility of the caller
|
||||
// if they really want to do that, since they have to explicitly shift d.Dot
|
||||
// anyway?
|
||||
//
|
||||
// In general, we'd have a DrawBytes([]byte) and DrawRuneReader(io.RuneReader)
|
||||
// and the last case can't assume that you can rewind the stream.
|
||||
//
|
||||
// TODO: how does this work with line breaking: drawing text up until a
|
||||
// vertical line? Should DrawString return the number of runes drawn?
|
||||
|
||||
// DrawString draws s at the dot and advances the dot's location.
|
||||
func (d *Drawer) DrawString(s string) {
|
||||
var prevC rune
|
||||
for i, c := range s {
|
||||
if i != 0 {
|
||||
d.Dot.X += d.Face.Kern(prevC, c)
|
||||
}
|
||||
dr, mask, maskp, advance, ok := d.Face.Glyph(d.Dot, c)
|
||||
if !ok {
|
||||
// TODO: is falling back on the U+FFFD glyph the responsibility of
|
||||
// the Drawer or the Face?
|
||||
// TODO: set prevC = '\ufffd'?
|
||||
continue
|
||||
}
|
||||
draw.DrawMask(d.Dst, dr, d.Src, image.Point{}, mask, maskp, draw.Over)
|
||||
d.Dot.X += advance
|
||||
prevC = c
|
||||
}
|
||||
}
|
||||
|
||||
// MeasureString returns how far dot would advance by drawing s.
|
||||
func (d *Drawer) MeasureString(s string) (advance fixed.Int26_6) {
|
||||
return MeasureString(d.Face, s)
|
||||
}
|
||||
|
||||
// MeasureString returns how far dot would advance by drawing s with f.
|
||||
func MeasureString(f Face, s string) (advance fixed.Int26_6) {
|
||||
var prevC rune
|
||||
for i, c := range s {
|
||||
if i != 0 {
|
||||
advance += f.Kern(prevC, c)
|
||||
}
|
||||
a, ok := f.GlyphAdvance(c)
|
||||
if !ok {
|
||||
// TODO: is falling back on the U+FFFD glyph the responsibility of
|
||||
// the Drawer or the Face?
|
||||
// TODO: set prevC = '\ufffd'?
|
||||
continue
|
||||
}
|
||||
advance += a
|
||||
prevC = c
|
||||
}
|
||||
return advance
|
||||
}
|
||||
|
||||
// Hinting selects how to quantize a vector font's glyph nodes.
|
||||
//
|
||||
// Not all fonts support hinting.
|
||||
type Hinting int
|
||||
|
||||
const (
|
||||
HintingNone Hinting = iota
|
||||
HintingVertical
|
||||
HintingFull
|
||||
)
|
||||
|
||||
// Stretch selects a normal, condensed, or expanded face.
|
||||
//
|
||||
// Not all fonts support stretches.
|
||||
type Stretch int
|
||||
|
||||
const (
|
||||
StretchUltraCondensed Stretch = -4
|
||||
StretchExtraCondensed Stretch = -3
|
||||
StretchCondensed Stretch = -2
|
||||
StretchSemiCondensed Stretch = -1
|
||||
StretchNormal Stretch = +0
|
||||
StretchSemiExpanded Stretch = +1
|
||||
StretchExpanded Stretch = +2
|
||||
StretchExtraExpanded Stretch = +3
|
||||
StretchUltraExpanded Stretch = +4
|
||||
)
|
||||
|
||||
// Style selects a normal, italic, or oblique face.
|
||||
//
|
||||
// Not all fonts support styles.
|
||||
type Style int
|
||||
|
||||
const (
|
||||
StyleNormal Style = iota
|
||||
StyleItalic
|
||||
StyleOblique
|
||||
)
|
||||
|
||||
// Weight selects a normal, light or bold face.
|
||||
//
|
||||
// Not all fonts support weights.
|
||||
//
|
||||
// The named Weight constants (e.g. WeightBold) correspond to CSS' common
|
||||
// weight names (e.g. "Bold"), but the numerical values differ, so that in Go,
|
||||
// the zero value means to use a normal weight. For the CSS names and values,
|
||||
// see https://developer.mozilla.org/en/docs/Web/CSS/font-weight
|
||||
type Weight int
|
||||
|
||||
const (
|
||||
WeightThin Weight = -3 // CSS font-weight value 100.
|
||||
WeightExtraLight Weight = -2 // CSS font-weight value 200.
|
||||
WeightLight Weight = -1 // CSS font-weight value 300.
|
||||
WeightNormal Weight = +0 // CSS font-weight value 400.
|
||||
WeightMedium Weight = +1 // CSS font-weight value 500.
|
||||
WeightSemiBold Weight = +2 // CSS font-weight value 600.
|
||||
WeightBold Weight = +3 // CSS font-weight value 700.
|
||||
WeightExtraBold Weight = +4 // CSS font-weight value 800.
|
||||
WeightBlack Weight = +5 // CSS font-weight value 900.
|
||||
)
|
||||
202
vendor/golang.org/x/image/math/fixed/fixed.go
generated
vendored
Normal file
202
vendor/golang.org/x/image/math/fixed/fixed.go
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package fixed implements fixed-point integer types.
|
||||
package fixed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// TODO: implement fmt.Formatter for %f and %g.
|
||||
|
||||
// I returns the integer value i as an Int26_6.
|
||||
//
|
||||
// For example, passing the integer value 2 yields Int26_6(128).
|
||||
func I(i int) Int26_6 {
|
||||
return Int26_6(i << 6)
|
||||
}
|
||||
|
||||
// Int26_6 is a signed 26.6 fixed-point number.
|
||||
//
|
||||
// The integer part ranges from -33554432 to 33554431, inclusive. The
|
||||
// fractional part has 6 bits of precision.
|
||||
//
|
||||
// For example, the number one-and-a-quarter is Int26_6(1<<6 + 1<<4).
|
||||
type Int26_6 int32
|
||||
|
||||
// String returns a human-readable representation of a 26.6 fixed-point number.
|
||||
//
|
||||
// For example, the number one-and-a-quarter becomes "1:16".
|
||||
func (x Int26_6) String() string {
|
||||
const shift, mask = 6, 1<<6 - 1
|
||||
if x >= 0 {
|
||||
return fmt.Sprintf("%d:%02d", int32(x>>shift), int32(x&mask))
|
||||
}
|
||||
x = -x
|
||||
if x >= 0 {
|
||||
return fmt.Sprintf("-%d:%02d", int32(x>>shift), int32(x&mask))
|
||||
}
|
||||
return "-33554432:00" // The minimum value is -(1<<25).
|
||||
}
|
||||
|
||||
// Floor returns the greatest integer value less than or equal to x.
|
||||
//
|
||||
// Its return type is int, not Int26_6.
|
||||
func (x Int26_6) Floor() int { return int((x + 0x00) >> 6) }
|
||||
|
||||
// Round returns the nearest integer value to x. Ties are rounded up.
|
||||
//
|
||||
// Its return type is int, not Int26_6.
|
||||
func (x Int26_6) Round() int { return int((x + 0x20) >> 6) }
|
||||
|
||||
// Ceil returns the least integer value greater than or equal to x.
|
||||
//
|
||||
// Its return type is int, not Int26_6.
|
||||
func (x Int26_6) Ceil() int { return int((x + 0x3f) >> 6) }
|
||||
|
||||
// Int52_12 is a signed 52.12 fixed-point number.
|
||||
//
|
||||
// The integer part ranges from -2251799813685248 to 2251799813685247,
|
||||
// inclusive. The fractional part has 12 bits of precision.
|
||||
//
|
||||
// For example, the number one-and-a-quarter is Int52_12(1<<12 + 1<<10).
|
||||
type Int52_12 int64
|
||||
|
||||
// String returns a human-readable representation of a 52.12 fixed-point
|
||||
// number.
|
||||
//
|
||||
// For example, the number one-and-a-quarter becomes "1:1024".
|
||||
func (x Int52_12) String() string {
|
||||
const shift, mask = 12, 1<<12 - 1
|
||||
if x >= 0 {
|
||||
return fmt.Sprintf("%d:%04d", int64(x>>shift), int64(x&mask))
|
||||
}
|
||||
x = -x
|
||||
if x >= 0 {
|
||||
return fmt.Sprintf("-%d:%04d", int64(x>>shift), int64(x&mask))
|
||||
}
|
||||
return "-2251799813685248:0000" // The minimum value is -(1<<51).
|
||||
}
|
||||
|
||||
// Floor returns the greatest integer value less than or equal to x.
|
||||
//
|
||||
// Its return type is int, not Int52_12.
|
||||
func (x Int52_12) Floor() int { return int((x + 0x000) >> 12) }
|
||||
|
||||
// Round returns the nearest integer value to x. Ties are rounded up.
|
||||
//
|
||||
// Its return type is int, not Int52_12.
|
||||
func (x Int52_12) Round() int { return int((x + 0x800) >> 12) }
|
||||
|
||||
// Ceil returns the least integer value greater than or equal to x.
|
||||
//
|
||||
// Its return type is int, not Int52_12.
|
||||
func (x Int52_12) Ceil() int { return int((x + 0xfff) >> 12) }
|
||||
|
||||
// P returns the integer values x and y as a Point26_6.
|
||||
//
|
||||
// For example, passing the integer values (2, -3) yields Point26_6{128, -192}.
|
||||
func P(x, y int) Point26_6 {
|
||||
return Point26_6{Int26_6(x << 6), Int26_6(y << 6)}
|
||||
}
|
||||
|
||||
// Point26_6 is a 26.6 fixed-point coordinate pair.
|
||||
//
|
||||
// It is analogous to the image.Point type in the standard library.
|
||||
type Point26_6 struct {
|
||||
X, Y Int26_6
|
||||
}
|
||||
|
||||
// Add returns the vector p+q.
|
||||
func (p Point26_6) Add(q Point26_6) Point26_6 {
|
||||
return Point26_6{p.X + q.X, p.Y + q.Y}
|
||||
}
|
||||
|
||||
// Sub returns the vector p-q.
|
||||
func (p Point26_6) Sub(q Point26_6) Point26_6 {
|
||||
return Point26_6{p.X - q.X, p.Y - q.Y}
|
||||
}
|
||||
|
||||
// Mul returns the vector p*k.
|
||||
func (p Point26_6) Mul(k Int26_6) Point26_6 {
|
||||
return Point26_6{p.X * k / 64, p.Y * k / 64}
|
||||
}
|
||||
|
||||
// Div returns the vector p/k.
|
||||
func (p Point26_6) Div(k Int26_6) Point26_6 {
|
||||
return Point26_6{p.X * 64 / k, p.Y * 64 / k}
|
||||
}
|
||||
|
||||
// Point52_12 is a 52.12 fixed-point coordinate pair.
|
||||
//
|
||||
// It is analogous to the image.Point type in the standard library.
|
||||
type Point52_12 struct {
|
||||
X, Y Int52_12
|
||||
}
|
||||
|
||||
// Add returns the vector p+q.
|
||||
func (p Point52_12) Add(q Point52_12) Point52_12 {
|
||||
return Point52_12{p.X + q.X, p.Y + q.Y}
|
||||
}
|
||||
|
||||
// Sub returns the vector p-q.
|
||||
func (p Point52_12) Sub(q Point52_12) Point52_12 {
|
||||
return Point52_12{p.X - q.X, p.Y - q.Y}
|
||||
}
|
||||
|
||||
// Mul returns the vector p*k.
|
||||
func (p Point52_12) Mul(k Int52_12) Point52_12 {
|
||||
return Point52_12{p.X * k / 4096, p.Y * k / 4096}
|
||||
}
|
||||
|
||||
// Div returns the vector p/k.
|
||||
func (p Point52_12) Div(k Int52_12) Point52_12 {
|
||||
return Point52_12{p.X * 4096 / k, p.Y * 4096 / k}
|
||||
}
|
||||
|
||||
// R returns the integer values minX, minY, maxX, maxY as a Rectangle26_6.
|
||||
//
|
||||
// For example, passing the integer values (0, 1, 2, 3) yields
|
||||
// Rectangle26_6{Point26_6{0, 64}, Point26_6{128, 192}}.
|
||||
//
|
||||
// Like the image.Rect function in the standard library, the returned rectangle
|
||||
// has minimum and maximum coordinates swapped if necessary so that it is
|
||||
// well-formed.
|
||||
func R(minX, minY, maxX, maxY int) Rectangle26_6 {
|
||||
if minX > maxX {
|
||||
minX, maxX = maxX, minX
|
||||
}
|
||||
if minY > maxY {
|
||||
minY, maxY = maxY, minY
|
||||
}
|
||||
return Rectangle26_6{
|
||||
Point26_6{
|
||||
Int26_6(minX << 6),
|
||||
Int26_6(minY << 6),
|
||||
},
|
||||
Point26_6{
|
||||
Int26_6(maxX << 6),
|
||||
Int26_6(maxY << 6),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Rectangle26_6 is a 26.6 fixed-point coordinate rectangle. The Min bound is
|
||||
// inclusive and the Max bound is exclusive. It is well-formed if Min.X <=
|
||||
// Max.X and likewise for Y.
|
||||
//
|
||||
// It is analogous to the image.Rectangle type in the standard library.
|
||||
type Rectangle26_6 struct {
|
||||
Min, Max Point26_6
|
||||
}
|
||||
|
||||
// Rectangle52_12 is a 52.12 fixed-point coordinate rectangle. The Min bound is
|
||||
// inclusive and the Max bound is exclusive. It is well-formed if Min.X <=
|
||||
// Max.X and likewise for Y.
|
||||
//
|
||||
// It is analogous to the image.Rectangle type in the standard library.
|
||||
type Rectangle52_12 struct {
|
||||
Min, Max Point52_12
|
||||
}
|
||||
Reference in New Issue
Block a user