clean Api

This commit is contained in:
Laurent Le Goff 2015-04-30 12:20:22 +02:00
parent 0345095002
commit 383fef0d7d
1 changed files with 66 additions and 8 deletions

View File

@ -78,26 +78,84 @@ type SolidFillStyle struct {
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
type TextStyle struct {
// Color defines the color of text
Color color.Color
// Size font size
Size float64
// The font to use
Font FontData
// Horizontal Alignment of the text
HorizontalAlign HorizontalAlign
Halign Halign
// 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
type Drawer interface {
setMatrix(MatrixTransform)
Fill(FillStyle, Path)
Stroke(StrokeStyle, Path)
Text(TextStyle, text string, x, y float64)
Style() *Style
Fill(Path)
Stroke(Path)
Text(text string, x, y float64)
Image(image image.Image, x, y float64)
}