Documentation ¶
Overview ¶
Package tmemes defines a meme generator, putting the meme in TS.
This package defines shared data types used throughout the service.
Index ¶
Constants ¶
const MaxContextLinks = 3
MaxContextLinks is the maximum number of context links permitted on a macro.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Area ¶
type Area struct { X float64 `json:"x"` // x offset of anchor as a fraction 0..1 of width Y float64 `json:"y"` // y offset of anchor as a fraciton 0..1 of height Width float64 `json:"width,omitempty"` // width of text box as a fraction of image width // If true, adjust the effective coordinates for each frame by interpolating // the distance between the given X, Y and the X, Y of the next area in // sequence, when rendering multiple frames. // // This is ignored when rendering on a single-frame template. Tween bool `json:"tween,omitempty"` }
An Area defines a region of an image where text is placed. Each area has an anchor point, relative to the top-left of the image, and a target width and height as fractions of the image size. Text drawn within an area should be scaled so that the resulting box does not exceed those dimensions.
func (Area) ValidForCreate ¶
ValidForCreate reports whether a is valid for creation of a new macro.
type Areas ¶
type Areas []Area
Areas is a wrapper for a slice of Area values that optionally decodes from JSON as either a single Area object or an array of Area values. A length-1 Areas encodes as a plain object.
func (Areas) MarshalJSON ¶
func (*Areas) UnmarshalJSON ¶
type Color ¶
type Color [3]float64
A Color represents an RGB color encoded as hex. It supports encoding in JSON as a string, allowing "#xxxxxx" or "#xxx" format (the "#" is optional).
func MustColor ¶
MustColor constructs a color from a known color name or hex specification #xxx or #xxxxxx. It panics if s does not correspond to a valid color.
func (Color) MarshalText ¶
func (*Color) UnmarshalText ¶
type ContextLink ¶
type ContextLink struct { URL string `json:"url"` // required Text string `json:"text,omitempty"` // optional }
ContextLink is a link to explain the context of a macro.
type ContextRequest ¶
type ContextRequest struct { // Action specifies what to do with the context links on the macro. // The options are "add", "clear", and "remove". Action string `json:"action"` // Link specifies the link to add or remove. At least the URL of the link // must be specified unless Action is "clear". Link ContextLink `json:"link"` }
ContextRequest is the payload for the /api/context handler.
type Macro ¶
type Macro struct { ID int `json:"id"` TemplateID int `json:"templateID"` Creator tailcfg.UserID `json:"creator,omitempty"` // -1 for anon CreatedAt time.Time `json:"createdAt"` TextOverlay []TextLine `json:"textOverlay"` ContextLink []ContextLink `json:"contextLink,omitempty"` Upvotes int `json:"upvotes,omitempty"` Downvotes int `json:"downvotes,omitempty"` }
A Macro combines a Template with some text. Macros can be cached by their ID, or re-rendered on-demand.
func (*Macro) ValidForCreate ¶
ValidForCreate reports whether m is valid for the creation of a new macro.
type Template ¶
type Template struct { ID int `json:"id"` // assigned by the server Path string `json:"path"` // path of image file Width int `json:"width"` // image width Height int `json:"height"` // image height Name string `json:"name"` // descriptive label Creator tailcfg.UserID `json:"creator"` CreatedAt time.Time `json:"createdAt"` Areas []Area `json:"areas,omitempty"` // optional predefined areas Hidden bool `json:"hidden,omitempty"` }
A Template defines a base template for an image macro.
type TextLine ¶
type TextLine struct { Text string `json:"text"` Color Color `json:"color"` StrokeColor Color `json:"strokeColor"` // The location(s) where the text should be drawn, it must be non-empty. // For a single-frame image, only the first entry is used. // // For a multiple-frame image, the locations are applied cyclically to the // frames of the image. Each area occupies an equal fraction of the frames, // for example if there are 8 frames and 2 areas, each area is mapped to 4 // frames (Field[0] to frames 0, 1, 2, 3; Field[1] to frames 4, 5, 6, 7). Field Areas `json:"field"` // The first point in a multi-frame image where this text should be visible, // as a fraction (0..1) of the total frames of the image. For example, in an // image with 16 frames, 0.25 represents 4 frames. // // if > 0, do not show the text line before this frame fraction. // If = 0, show the text beginning at the first frame. Start float64 `json:"start,omitempty"` // 0..1 // The last point in a multi-frame image where this text should be visible, // as a fraction (0..1) of the total frames of the image. For example, in an // image with 10 frames, 0.5 represents 5 frames. // // If > Start, hide the text after this frame fraction. // Otherwise, do not hide the text after the start index. End float64 `json:"end,omitempty"` // 0..1 }
A TextLine is a single line of text with an optional alignment.
func (TextLine) ValidForCreate ¶
ValidForCreate reports whether t is valid for creation of a macro.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
tmemes
Program tmemes is an image macro server that runs as a node on a tailnet.
|
Program tmemes is an image macro server that runs as a node on a tailnet. |
Package memedraw draws text on a tempate.
|
Package memedraw draws text on a tempate. |
Package store implements a data store for memes.
|
Package store implements a data store for memes. |