importer

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderTemplate

func RenderTemplate(w io.Writer, packageName string, emojis []EmojiInfo) error

RenderTemplate renders the dataset template to the given io.Writer.

Types

type CDN

type CDN struct {
	// contains filtered or unexported fields
}

CDN provides an interface for a remote emoji dataset.

func NewCDN

func NewCDN() (*CDN, error)

NewCDN creates a new CDN client for emoji data.

func (*CDN) DownloadEmojiInfo

func (c *CDN) DownloadEmojiInfo(ctx context.Context) ([]EmojiInfo, error)

DownloadEmojiInfo retrieves and decodes a list of emoji metadata from the CDN.

func (*CDN) DownloadSpriteSheet

func (c *CDN) DownloadSpriteSheet(ctx context.Context, width int) (*SpriteSheet, error)

DownloadSpriteSheet downloads the sprite sheet from the CDN.

type EmojiImageData

type EmojiImageData struct {
	// A hyphen separated sequence of hex-encoded codepoints.
	// Includes zero-width-joiner character for multi code sequences.
	Unified string `json:"unified"`
	// Character is the actual emoji character consisting of one or more codepoints.
	// Not present in original input but will be populated by parser
	Character string `json:"character,omitempty"`
	// NonQualified is set if the emoji also has usage without a variation selector.
	NonQualified string `json:"non_qualified"`
	// Image is the image name as available via the CDN.
	Image string `json:"image"`
	// SheetX is the X index of the image in the sprite sheet.
	SheetX int `json:"sheet_x"`
	// SheetY is the Y index of the image in the sprite sheet.
	SheetY int `json:"sheet_y"`
	// Ignore legacy codepoint data
	// Docomo         string `json:"docomo"`
	// AU             string `json:"au"`
	// Softbank       string `json:"softbank"`
	// Google         string `json:"google"`
	AddedIn        string `json:"added_in"`
	HasImgApple    bool   `json:"has_img_apple"`
	HasImgGoogle   bool   `json:"has_img_google"`
	HasImgTwitter  bool   `json:"has_img_twitter"`
	HasImgFacebook bool   `json:"has_img_facebook"`
	Obsoletes      string `json:"obsoletes"`
	ObsoletedBy    string `json:"obsoleted_by"`
}

EmojiImageData captures standard emoji attributes. These details are shared by both top-level emojis and variations.

type EmojiInfo

type EmojiInfo struct {
	Name       string   `json:"name"`
	ShortName  string   `json:"short_name"`
	ShortNames []string `json:"short_names"`
	Text       string   `json:"text"`
	Texts      []string `json:"texts"`
	Category   string   `json:"category"`
	SortOrder  int      `json:"sort_order"`
	EmojiImageData
	SkinVariations map[string]EmojiImageData `json:"skin_variations"`
}

EmojiInfo captures standard emoji attributes for a named and tagged emoji.

func ParseEmojiData

func ParseEmojiData(r io.Reader) ([]EmojiInfo, error)

ParseEmojiData parses emoji information from a JSON reader.

type SpriteSheet

type SpriteSheet struct {
	// contains filtered or unexported fields
}

SpriteSheet represents the image data for a sprite sheet.

func NewSpriteSheet

func NewSpriteSheet(reader io.Reader, width int) (*SpriteSheet, error)

NewSpriteSheet parses a PNG sprite of fixed-width sprites

func (SpriteSheet) Get

func (s SpriteSheet) Get(x, y int) *image.NRGBA

Get retrieves an image from the sprite sheet.

Jump to

Keyboard shortcuts

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