Documentation
¶
Overview ¶
Package imageutil renders plain images with fit modes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImageElement ¶
type ImageElement struct {
// Contextual gives it a context menu (Context).
elements.Contextual
kit.HoverTracker
// contains filtered or unexported fields
}
ImageElement renders an image scaled into its box. Chain OnHover to add hover styles.
func New ¶
func New(img image.Image, st ...styles.Styles) *ImageElement
New renders img as a stateless element. Width and Height fix the box size (the natural size is used when unset) and Fit controls the scaling: none, contain, cover or stretch. Chain OnHover to add hover styles (Opacity and BorderRadius).
func (*ImageElement) Layout ¶
func (i *ImageElement) Layout(gtx layout.Context) layout.Dimensions
Layout renders the image.
func (*ImageElement) OnHover ¶
func (i *ImageElement) OnHover(st styles.Styles) *ImageElement
OnHover sets styles applied while the pointer is over the image, merged on top of its base styles - Opacity and BorderRadius are the properties Image paints. Hover state lives in the element, so create it once and reuse it every frame; rebuilding it in the view function resets the hover on each frame.