media

package
v0.0.0-...-0aa954c Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package media provides utilities for wasm media.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OnKey

func OnKey(ev KeyEvent, f func(key string))

OnKey ...

Types

type Canvas

type Canvas struct {
	Value js.Value
	// contains filtered or unexported fields
}

Canvas represents an HTML5 canvas.

func GetCanvas

func GetCanvas(id string) Canvas

GetCanvas gets the canvas with given id from HTML5.

func (Canvas) ClearRect

func (c Canvas) ClearRect(r Rect)

ClearRect clears rectangle r.

func (Canvas) ClientH

func (c Canvas) ClientH() int

ClientH returns the client height.

func (Canvas) ClientW

func (c Canvas) ClientW() int

ClientW returns the client width.

func (Canvas) DrawImage

func (c Canvas) DrawImage(img Image, r Rect)

DrawImage draws an image into the canvas.

func (Canvas) DrawImageFlipHorizontal

func (c Canvas) DrawImageFlipHorizontal(img Image, r Rect)

DrawImageFlipHorizontal ...

func (Canvas) DrawText

func (c Canvas) DrawText(s string, x, y int)

DrawText ...

func (Canvas) OnMouse

func (c Canvas) OnMouse(mapTouch bool, f func(click MouseClick, x, y int))

OnMouse ...

func (Canvas) SetFont

func (c Canvas) SetFont(name, style string)

SetFont ...

type Image

type Image struct {
	Value js.Value
}

Image represents a js image.

func NewImage

func NewImage(uri, alt string) (Image, error)

NewImage creates and initializes an Image detached from the DOM.

func NewImageSet

func NewImageSet(uriprefix string) ([]Image, error)

NewImageSet ...

func (Image) H

func (img Image) H() int

H returns the image height.

func (Image) W

func (img Image) W() int

W returns the image width.

type KeyEvent

type KeyEvent string

KeyEvent ...

const (
	KeyPress KeyEvent = "keypress"
	KeyUp    KeyEvent = "keyup"
	KeyDown  KeyEvent = "keydown"
)

Key events ...

type MouseClick

type MouseClick int8

MouseClick ...

const (
	MouseUp MouseClick = iota
	MouseDown
)

Mouse clicks ...

func (MouseClick) String

func (m MouseClick) String() string

type Rect

type Rect struct {
	X, Y,
	W, H int
}

Rect represents a rectangle.

Jump to

Keyboard shortcuts

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