area

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package area provides constructors and methods for the HTML <area> element.

The <area> HTML element defines clickable regions within an image map. Image maps allow geometric areas on an image to be associated with hyperlinks, enabling interactive images with multiple destinations. This element must be used within a <map> element and supports rectangular, circular, polygonal, and default shapes for defining clickable regions.

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen = []byte("<area")

	AttrShape          = []byte(" shape=\"")
	AttrCoords         = []byte(" coords=\"")
	AttrHref           = []byte(" href=\"")
	AttrAlt            = []byte(" alt=\"")
	AttrDownload       = []byte(" download=\"")
	AttrPing           = []byte(" ping=\"")
	AttrReferrerPolicy = []byte(" referrerpolicy=\"")
	AttrRel            = []byte(" rel=\"")
	AttrTarget         = []byte(" target=\"")
)

Byte constants for HTML rendering.

Functions

func Circle

func Circle(x int, y int, radius int, href string) *element

Circle creates a circular area element with centre coordinates, radius, and href. Convenient constructor for circular clickable regions. The coordinates represent the centre (x,y) and radius of the circle. Example: area.Circle(130, 136, 60, "/products") Renders: <area shape="circle" coords="130,136,60" href="/products" />

func Default

func Default(href string) *element

Default creates a default area element that covers the entire image. Used as a fallback when no other areas match. The default shape covers the entire image and is typically used last in the area list. Example: area.Default("https://example.com") Renders: <area shape="default" href="https://example.com" />

func New

func New() *element

New creates a new area element without any initial attributes. Example: area.New() Renders: <area />

func Poly

func Poly(coords string, href string) *element

Poly creates a polygonal area element with coordinates and href. Used for irregular shapes defined by multiple coordinate pairs. Coordinates are comma-separated x,y pairs that define the polygon vertices. Example: area.Poly("74,0,113,29,98,72,52,72,38,29", "/contact") Renders: <area shape="poly" coords="74,0,113,29,98,72,52,72,38,29" href="/contact" />

func Rect

func Rect(x1 int, y1 int, x2 int, y2 int, href string) *element

Rect creates a rectangular area element with coordinates and href. Convenient constructor for rectangular clickable regions. The coordinates represent the top-left (x1,y1) and bottom-right (x2,y2) corners of the rectangle. Example: area.Rect(34, 44, 270, 350, "https://example.com") Renders: <area shape="rect" coords="34,44,270,350" href="https://example.com" />

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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