Documentation
¶
Index ¶
- func MasterCSS() string
- type BackgroundAttachment
- type BackgroundLayer
- type BackgroundRepeat
- type Border
- type BorderRadiuses
- type BorderStyle
- type Borders
- type ColorPoint
- type ConicGradient
- type Document
- func (d *Document) Close()
- func (d *Document) Draw(hdc uintptr, x, y float32, clip *Position)
- func (d *Document) Height() float32
- func (d *Document) OnLButtonDown(x, y, clientX, clientY float32) (bool, []Position)
- func (d *Document) OnLButtonUp(x, y, clientX, clientY float32) (bool, []Position)
- func (d *Document) OnMouseLeave() (bool, []Position)
- func (d *Document) OnMouseOver(x, y, clientX, clientY float32) (bool, []Position)
- func (d *Document) Render(maxWidth float32) float32
- func (d *Document) Width() float32
- type DocumentContainer
- type FontDescription
- type FontMetrics
- type FontStyle
- type LinearGradient
- type ListMarker
- type ListStyleType
- type MediaFeatures
- type MediaType
- type MouseEvent
- type PointF
- type Position
- type RadialGradient
- type Size
- type TextDecorationStyle
- type TextTransform
- type WebColor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BackgroundAttachment ¶
type BackgroundAttachment int
BackgroundAttachment mirrors litehtml::background_attachment.
const ( BackgroundAttachmentScroll BackgroundAttachment = iota BackgroundAttachmentFixed )
type BackgroundLayer ¶
type BackgroundLayer struct {
BorderBox Position
BorderRadius BorderRadiuses
ClipBox Position
OriginBox Position
Attachment BackgroundAttachment
Repeat BackgroundRepeat
IsRoot bool
}
BackgroundLayer holds geometry for a background draw call.
type BackgroundRepeat ¶
type BackgroundRepeat int
BackgroundRepeat mirrors litehtml::background_repeat.
const ( BackgroundRepeatRepeat BackgroundRepeat = iota BackgroundRepeatRepeatX BackgroundRepeatRepeatY BackgroundRepeatNoRepeat )
type Border ¶
type Border struct {
Width float32
Style BorderStyle
Color WebColor
}
Border describes one side of a border.
type BorderRadiuses ¶
type BorderRadiuses struct {
TopLeftX, TopLeftY float32
TopRightX, TopRightY float32
BottomRightX, BottomRightY float32
BottomLeftX, BottomLeftY float32
}
BorderRadiuses holds the 4-corner border radius values.
type BorderStyle ¶
type BorderStyle int
BorderStyle mirrors litehtml::border_style.
const ( BorderStyleNone BorderStyle = iota BorderStyleHidden BorderStyleDotted BorderStyleDashed BorderStyleSolid BorderStyleDouble BorderStyleGroove BorderStyleRidge BorderStyleInset BorderStyleOutset )
type Borders ¶
type Borders struct {
Left, Top, Right, Bottom Border
Radius BorderRadiuses
}
Borders holds all four border sides plus radiuses.
type ColorPoint ¶
ColorPoint is a single color stop in a gradient.
type ConicGradient ¶
type ConicGradient struct {
Position PointF
Angle float32
Radius float32
ColorPoints []ColorPoint
}
ConicGradient holds data for a conic gradient draw call.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document represents a parsed and renderable HTML document.
func NewDocument ¶
func NewDocument(html string, container DocumentContainer, masterCSS, userCSS string) (*Document, error)
NewDocument parses an HTML string and creates a Document. The container provides callbacks for fonts, drawing, and resources. Pass empty strings for masterCSS/userCSS to use litehtml defaults.
func (*Document) Close ¶
func (d *Document) Close()
Close releases the C++ resources. Safe to call multiple times.
func (*Document) Draw ¶
Draw draws the document at position (x, y). Pass nil for clip to draw everything.
func (*Document) OnLButtonDown ¶
OnLButtonDown handles a left mouse button press.
func (*Document) OnLButtonUp ¶
OnLButtonUp handles a left mouse button release.
func (*Document) OnMouseLeave ¶
OnMouseLeave handles the mouse leaving the document area.
func (*Document) OnMouseOver ¶
OnMouseOver handles a mouse move event. Returns whether any elements changed and the list of boxes to redraw.
type DocumentContainer ¶
type DocumentContainer interface {
CreateFont(descr FontDescription) (uintptr, FontMetrics)
DeleteFont(hFont uintptr)
TextWidth(text string, hFont uintptr) float32
DrawText(hdc uintptr, text string, hFont uintptr, color WebColor, pos Position)
PtToPx(pt float32) float32
GetDefaultFontSize() float32
GetDefaultFontName() string
DrawListMarker(hdc uintptr, marker ListMarker)
LoadImage(src, baseurl string, redrawOnReady bool)
GetImageSize(src, baseurl string) Size
DrawImage(hdc uintptr, layer BackgroundLayer, url, baseURL string)
DrawSolidFill(hdc uintptr, layer BackgroundLayer, color WebColor)
DrawLinearGradient(hdc uintptr, layer BackgroundLayer, gradient LinearGradient)
DrawRadialGradient(hdc uintptr, layer BackgroundLayer, gradient RadialGradient)
DrawConicGradient(hdc uintptr, layer BackgroundLayer, gradient ConicGradient)
DrawBorders(hdc uintptr, borders Borders, drawPos Position, root bool)
SetCaption(caption string)
SetBaseURL(baseURL string)
Link(href, rel, mediaType string)
OnAnchorClick(url string)
OnMouseEvent(event MouseEvent)
SetCursor(cursor string)
TransformText(text string, tt TextTransform) string
ImportCSS(url, baseurl string) (text string, newBaseURL string)
SetClip(pos Position, bdrRadius BorderRadiuses)
DelClip()
GetViewport() Position
CreateElement(tagName string, attributes map[string]string) uintptr
GetMediaFeatures() MediaFeatures
GetLanguage() (language, culture string)
}
DocumentContainer is the callback interface that consumers implement to provide font, drawing, and resource loading services to litehtml.
type FontDescription ¶
type FontDescription struct {
Family string
Size float32
Style FontStyle
Weight int
DecorationLine int
DecorationThickness float32
DecorationStyle TextDecorationStyle
DecorationColor WebColor
EmphasisStyle string
EmphasisColor WebColor
EmphasisPosition int
}
FontDescription describes a font request from the layout engine.
type FontMetrics ¶
type FontMetrics struct {
FontSize float32
Height float32
Ascent float32
Descent float32
XHeight float32
ChWidth float32
DrawSpaces bool
SubShift float32
SuperShift float32
}
FontMetrics holds font measurement data returned by CreateFont.
type LinearGradient ¶
type LinearGradient struct {
Start, End PointF
ColorPoints []ColorPoint
}
LinearGradient holds data for a linear gradient draw call.
type ListMarker ¶
type ListMarker struct {
Image string
BaseURL string
MarkerType ListStyleType
Color WebColor
Pos Position
Index int
Font uintptr
}
ListMarker holds data for a list marker draw call.
type ListStyleType ¶
type ListStyleType int
ListStyleType mirrors litehtml::list_style_type.
const ( ListStyleTypeNone ListStyleType = iota ListStyleTypeCircle ListStyleTypeDisc ListStyleTypeSquare ListStyleTypeArmenian ListStyleTypeCjkIdeographic ListStyleTypeDecimal ListStyleTypeDecimalLeadingZero ListStyleTypeGeorgian ListStyleTypeHebrew ListStyleTypeHiragana ListStyleTypeHiraganaIroha ListStyleTypeKatakana ListStyleTypeKatakanaIroha ListStyleTypeLowerAlpha ListStyleTypeLowerGreek ListStyleTypeLowerLatin ListStyleTypeLowerRoman ListStyleTypeUpperAlpha ListStyleTypeUpperLatin ListStyleTypeUpperRoman )
type MediaFeatures ¶
type MediaFeatures struct {
Type MediaType
Width float32
Height float32
DeviceWidth float32
DeviceHeight float32
Color int
ColorIndex int
Monochrome int
Resolution float32
}
MediaFeatures describes the media environment.
type MouseEvent ¶
type MouseEvent int
MouseEvent mirrors litehtml::mouse_event.
const ( MouseEventEnter MouseEvent = iota MouseEventLeave )
type Position ¶
type Position struct {
X, Y, Width, Height float32
}
Position represents a rectangle with x, y, width, height.
type RadialGradient ¶
type RadialGradient struct {
Position PointF
Radius PointF
ColorPoints []ColorPoint
}
RadialGradient holds data for a radial gradient draw call.
type TextDecorationStyle ¶
type TextDecorationStyle int
TextDecorationStyle mirrors litehtml::text_decoration_style.
const ( TextDecorationStyleSolid TextDecorationStyle = iota TextDecorationStyleDouble TextDecorationStyleDotted TextDecorationStyleDashed TextDecorationStyleWavy )
type TextTransform ¶
type TextTransform int
TextTransform mirrors litehtml::text_transform.
const ( TextTransformNone TextTransform = iota TextTransformCapitalize TextTransformUppercase TextTransformLowercase )
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
Example: render HTML to a PNG image using litehtml-go
|
Example: render HTML to a PNG image using litehtml-go |
|
dump
command
Example: dump all litehtml container callbacks
|
Example: dump all litehtml container callbacks |
|
rich
command
Example: render a rich HTML page to PNG using litehtml-go
|
Example: render a rich HTML page to PNG using litehtml-go |