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 ¶
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 ¶
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 ¶
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 ¶
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" />