Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePictureFromField(fs http.FileSystem, field string) (pixel.Picture, error)
- func CreatePictureFromSVG(svg *oksvg.SvgIcon, scale ScaleOption, w, h float64) pixel.Picture
- func LoadPicture(fs http.FileSystem, path string) (pixel.Picture, error)
- func LoadSVG(fs http.FileSystem, path string, color color.RGBA) (*oksvg.SvgIcon, error)
- func ParseColor(str string) (color.RGBA, error)
- type AbsoluteQuantity
- type GravSide
- type Gravity
- type Orientation
- type Ratio
- type RelativeQuantity
- type RelativeSize
- type ScaleOption
- type Unit
Constants ¶
const ( // Const for the middle of a gravity axis GravCenter = GravSide(0) // Const for the negative end of // a gravity axis (left, top, etc.) GravNeg = GravSide(-1) // Const for the positive end of // a gravity axis (right, bottom, etc.) GravPos = GravSide(1) )
const DefaultOrientation = VerticalOrientation
Const of the default orientation
const DefaultScaleOption = ScaleToFit
Const for the default scale option
const HorizontalOrientation = Orientation("horizontal")
Const of a horizontal orientation
const NoScale = ScaleOption("none")
Const for not scaling an image
const Percent = Unit("%")
Const for a percentage "unit"
const Pixels = Unit("px")
Const for a unit of pixels
const ScaleToFill = ScaleOption("fill")
Const for image scaling to fill
const ScaleToFit = ScaleOption("fit")
Const for image scaling to fit
const Stretch = ScaleOption("stretch")
Const for stretching an image
const Tiled = ScaleOption("tiled")
Const for tiling an image
const VerticalOrientation = Orientation("vertical")
Const of a vertical orientation
const ZeroScaleOption = ScaleOption("")
A "zero" scale option, as in one where it is a zero value
Variables ¶
var DefaultAbsoluteQuantity = AbsoluteQuantity{Quantity: 0, Unit: Pixels}
The default absolute quantity
var DefaultGravity = GravityTypes["top-left"]
The default gravity
var DefaultRelativeQuantity = RelativeQuantity{Quantity: 0, Unit: Pixels}
The default relative quantity
var DefaultRelativeSize = RelativeSize{RelativeQuantity: DefaultRelativeQuantity}
The default relative quantity
var GravityTypes = map[string]Gravity{ "center": {GravCenter, GravCenter}, "top": {GravCenter, GravNeg}, "bottom": {GravCenter, GravPos}, "left": {GravNeg, GravCenter}, "right": {GravPos, GravCenter}, "top-left": {GravNeg, GravNeg}, "top-right": {GravPos, GravNeg}, "bottom-left": {GravNeg, GravPos}, "bottom-right": {GravPos, GravPos}, }
The possible gravity types as a map
var ZeroAbsoluteQuantity = AbsoluteQuantity{}
A "zero" absolute quantity, as in one where all the fields are zero values
var ZeroRelativeQuantity = RelativeQuantity{}
A "zero" relative quantity, as in one where all the fields are zero values
var ZeroRelativeSize = RelativeSize{}
A "zero" relative quantity, as in one where all the fields are zero values
Functions ¶
func CreatePictureFromField ¶
Function to create a picture from an XML string
func CreatePictureFromSVG ¶
Function to create a pixel.Picture from a given SVG
func LoadPicture ¶
Function to load an image and convert it to a pixel.Picture
Types ¶
type AbsoluteQuantity ¶
type AbsoluteQuantity struct { // The quantity itself Quantity int32 // The unit. Only absolute units // are allowed (For example, // Pixel is allowed, Percent // isn't) Unit Unit }
Type for the absolute size of something
func ParseAbsoluteQuantity ¶
func ParseAbsoluteQuantity(str string) (size AbsoluteQuantity, err error)
Function to parse a string and convert it to an AbsoluteQuantity
type Gravity ¶
type Gravity struct { // The horizontal gravity. Either // GravNeg (left), GravCenter // (center), GravPos (right) HorizGravity GravSide // The vertical gravity. Either // GravNeg (top), GravCenter // (center), GravPos (bottom) VertGravity GravSide }
Type for the gravity of something
func ParseGravity ¶
Function to parse a string into a gravity type. If value is not a valid gravity, the function returns an error. If the value is an empty string, the default gravity 'def' is used instead
type Orientation ¶
type Orientation string
Type for the orientation of something
func ParseOrientation ¶
func ParseOrientation(value string, def Orientation) (Orientation, error)
Function to parse a string into an orientation type. If value is not a valid orientation, the function returns an error. If the value is an empty string, the default orientation 'def' is used instead
type Ratio ¶
type Ratio struct { // The left part of the ratio Left int // The right part of the ratio Right int }
Type for a ratio (such as for an aspect ratio)
func ParseRatio ¶
Function to parse a string into a ratio type. If value is not a valid ratio, the function returns an error
type RelativeQuantity ¶
type RelativeQuantity struct { // The quantity itself. Zero if // MatchParent or MatchContent // are non-zero Quantity int32 // The quantity's unit. Zero if // MatchParent or MatchContent // are non-zero Unit Unit }
Type for a relative quantity
func ParseRelativeQuantity ¶
func ParseRelativeQuantity(str string) (size RelativeQuantity, err error)
Function to parse a string and convert it to a RelativeQuantity
type RelativeSize ¶
type RelativeSize struct { // Whether the quantity is the // same as the parent element MatchParent bool // Whether the quantity is the // same as the element's content MatchContent bool // Whether the quantity is the // same as the bounds from the // parent MatchBounds bool // The quantity itself. Zero if // MatchParent or MatchContent // are non-zero RelativeQuantity }
Type for the relative size (usually width or height) of an element, which can match its parent, content or have a relative quantity
func ParseRelativeSize ¶
func ParseRelativeSize(str string) (size RelativeSize, err error)
Function to parse a string and convert it to a RelativeSize
type ScaleOption ¶
type ScaleOption string
Type for the scale option of something (usually an image)
func ParseScaleOption ¶
func ParseScaleOption(value string) (ScaleOption, error)
Function to parse a string into a scale option type. If value is not a valid scale option, the function returns an error
type Unit ¶
type Unit string
Type for a size unit
func ParseAbsoluteUnit ¶
Function to parse a string and convert it to an absolute unit