imageutil

package
v1.0.31-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL