clean Api
This commit is contained in:
parent
0345095002
commit
383fef0d7d
1 changed files with 66 additions and 8 deletions
74
graphics.go
74
graphics.go
|
@ -78,26 +78,84 @@ type SolidFillStyle struct {
|
||||||
FillRule FillRule
|
FillRule FillRule
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerticalAlign int
|
// Vertical Alignment of the text
|
||||||
|
type Valign int
|
||||||
|
|
||||||
type HorizontalAlign int
|
const (
|
||||||
|
ValignTop Valign = iota
|
||||||
|
ValignTopCenter
|
||||||
|
ValignTopBottom
|
||||||
|
ValignTopBaseline
|
||||||
|
)
|
||||||
|
|
||||||
|
// Horizontal Alignment of the text
|
||||||
|
type Halign int
|
||||||
|
|
||||||
|
const (
|
||||||
|
HalignLeft = iota
|
||||||
|
HalignCenter
|
||||||
|
HalignRight
|
||||||
|
)
|
||||||
|
|
||||||
|
type ScalingPolicy int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ScalingNone no scaling applied
|
||||||
|
ScalingNone = iota
|
||||||
|
// ScalingStretch the image is stretched so that its width and height are exactly the given width and height
|
||||||
|
ScalingStretch
|
||||||
|
// ScalingWidth the image is scaled so that its width is exactly the given width
|
||||||
|
ScalingWidth
|
||||||
|
// ScalingHeight the image is scaled so that its height is exactly the given height
|
||||||
|
ScalingHeight
|
||||||
|
// ScalingFit the image is scaled to the largest scale that allow the image to fit within a rectangle width x height
|
||||||
|
ScalingFit
|
||||||
|
// ScalingSameArea the image is scaled so that its area is exactly the area of the given rectangle width x height
|
||||||
|
ScalingSameArea
|
||||||
|
// ScalingFill the image is scaled to the smallest scale that allow the image to fully cover a rectangle width x height
|
||||||
|
ScalingFill
|
||||||
|
)
|
||||||
|
|
||||||
// TextStyle
|
// TextStyle
|
||||||
type TextStyle struct {
|
type TextStyle struct {
|
||||||
// Color defines the color of text
|
// Color defines the color of text
|
||||||
Color color.Color
|
Color color.Color
|
||||||
|
// Size font size
|
||||||
|
Size float64
|
||||||
// The font to use
|
// The font to use
|
||||||
Font FontData
|
Font FontData
|
||||||
// Horizontal Alignment of the text
|
// Horizontal Alignment of the text
|
||||||
HorizontalAlign HorizontalAlign
|
Halign Halign
|
||||||
// Vertical Alignment of the text
|
// Vertical Alignment of the text
|
||||||
VerticalAlign VerticalAlign
|
Valign Valign
|
||||||
|
}
|
||||||
|
|
||||||
|
// ImageStyle style attributes used to display the image
|
||||||
|
type ImageStyle struct {
|
||||||
|
// Horizontal Alignment of the image
|
||||||
|
Halign Halign
|
||||||
|
// Vertical Alignment of the image
|
||||||
|
Valign Valign
|
||||||
|
// Width Height used by scaling policy
|
||||||
|
Width, Height float64
|
||||||
|
// ScalingPolicy defines the scaling policy to applied to the image
|
||||||
|
ScalingPolicy ScalingPolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
// Style defines properties that
|
||||||
|
type Style struct {
|
||||||
|
MatrixTransform MatrixTransform
|
||||||
|
StrokeStyle StrokeStyle
|
||||||
|
FillStyle FillStyle
|
||||||
|
TextStyle TextStyle
|
||||||
|
ImageStyle TextStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawer can fill and stroke a path
|
// Drawer can fill and stroke a path
|
||||||
type Drawer interface {
|
type Drawer interface {
|
||||||
setMatrix(MatrixTransform)
|
Style() *Style
|
||||||
Fill(FillStyle, Path)
|
Fill(Path)
|
||||||
Stroke(StrokeStyle, Path)
|
Stroke(Path)
|
||||||
Text(TextStyle, text string, x, y float64)
|
Text(text string, x, y float64)
|
||||||
|
Image(image image.Image, x, y float64)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue