mechoverlayer

package
v0.0.0-...-a3e6692 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: CC0-1.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mechoverlayer dispenses HTML elements which overlay the scene associated with a particular shutterbug.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOverlayerHandleFunc

func NewOverlayerHandleFunc(
	ovr Overlayer,
	shutterbugs mechshutterbug.Containser,
) http.HandlerFunc

NewOverlayerHandleFunc creates a HTTP request handler which allows clients to interface with the overlayer.

The handler upgrades the HTTP request to a websocket. The websocket's first ever incoming message should be a valid shutterbug.

func XToLeft

func XToLeft(x float64) string

XToLeft maps a screen space X coordinate to a CSS percentage value of the width of the screen's HTML element starting from the left edge of the screen.

The visible screen space spans X values given in the range

(-0.5 * screen ratio) ... (0.5 * screen ratio)

func YToTop

func YToTop(y float64) string

YToTop maps a screen space Y coordinate to a CSS percentage value of the height of the screen's HTML element starting from the top edge of the screen.

The visible screen space spans Y values given in the range -0.5 ... 0.5 where 0.5 corresponds to the top edge of the screen.

Types

type Element

type Element struct {
	// The element's HTML as a string.
	InnerHTML string
	// Hash of the innerHTML.
	InnerHTMLHash string
	// Orientation of the element.
	Transform, TransformOrigin string
	// (0.5 * screen ratio) is a point at the right edge of the screen, (-0.5 *
	// screen ratio) is the left edge of the screen.
	X float64
	// 0.5 is a point at the top edge of the screen, -0.5 is the bottom edge of
	// the screen.
	Y float64
	// Perpendicular distance from the camera's Z=0 plane, used to determine the
	// element's zIndex in the HTML document.
	Z float64
	// contains filtered or unexported fields
}

An Element in a HTML document overlaying a shutterbug's pixels screen.

type Elements

type Elements struct {
	Ahead  map[string]Element
	Behind dryad.Set[string]
}

Elements accessible by element name.

func (Elements) Contains

func (els Elements) Contains(name string) bool

Contains reports whether an overlay element with the given name exists in the receiver elements.

func (Elements) Shows

func (els Elements) Shows(name string) bool

Shows reports whether the overlay element with the given name is possibly showing.

type Overlayer

type Overlayer struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

An Overlayer makes and updates HTML elements in overlays.

Each shutterbug is associated with an overlay: all clients using that shutterbug see the same overlay. In the browser the overlay's elements appear above the shutterbug's pixels screen.

func New

func New(l *log.Logger) Overlayer

New constructs a new Overlayer.

func (Overlayer) RemoveShutterbug

func (ovr Overlayer) RemoveShutterbug(shutterbug string)

RemoveShutterbug from the overlayer and close the associated HTTP request handlers using that shutterbug.

If the shutterbug does not exist in the overlayer nothing happens.

func (Overlayer) Synchronise

func (ovr Overlayer) Synchronise(
	shutterbug string,
	main Elements,
	veneer Elements,
)

Synchronise the receiver overlayer's overlay elements with the given elements for the given shutterbug.

The given elements are the source of truth, and based on that the receiver creates, deletes, updates, and hides its elements as necessary.

Jump to

Keyboard shortcuts

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