Documentation
¶
Index ¶
- Constants
- Variables
- func Encode(w io.Writer, img image.Image, opts EncodeOptions) error
- func EncodeBytes(img image.Image, opts EncodeOptions) ([]byte, error)
- func EncodeDataURL(img image.Image, opts EncodeOptions) (string, error)
- func MIMEType(format Format) (string, error)
- type AssetError
- type AvatarSizeAxis
- type ConversationMessage
- type ConversationOptions
- type ConversationTheme
- type EncodeOptions
- type Engine
- func (e *Engine) RenderConversation(ctx context.Context, messages []ConversationMessage, ...) (*image.NRGBA, error)
- func (e *Engine) RenderQuote(ctx context.Context, quote Quote, opts RenderOptions) (*image.NRGBA, error)
- func (e *Engine) WriteConversation(ctx context.Context, w io.Writer, messages []ConversationMessage, ...) error
- func (e *Engine) WriteQuote(ctx context.Context, w io.Writer, quote Quote, opts RenderOptions, ...) error
- type EngineOptions
- type FieldError
- type FontFace
- type Format
- type ImageSource
- type MissingAssetBehavior
- type MisskeyOptions
- type Quote
- type RenderOptions
Constants ¶
const ( MaxTextLength = 4000 MaxNameLength = 128 MaxWatermarkLength = 64 MaxScale = 8 )
Variables ¶
Functions ¶
func EncodeBytes ¶
func EncodeBytes(img image.Image, opts EncodeOptions) ([]byte, error)
func EncodeDataURL ¶
func EncodeDataURL(img image.Image, opts EncodeOptions) (string, error)
Types ¶
type AssetError ¶
AssetError adds source information to an image or other asset failure.
func (*AssetError) Error ¶
func (e *AssetError) Error() string
func (*AssetError) Unwrap ¶
func (e *AssetError) Unwrap() error
type AvatarSizeAxis ¶
type AvatarSizeAxis string
const ( AvatarNativeWidth AvatarSizeAxis = "width" AvatarNativeHeight AvatarSizeAxis = "height" )
type ConversationMessage ¶
type ConversationMessage struct {
Text string
Username string
DisplayName string
Avatar ImageSource
}
type ConversationOptions ¶
type ConversationOptions struct {
Theme ConversationTheme
Width int
Misskey MisskeyOptions
OnAssetError MissingAssetBehavior
}
type ConversationTheme ¶
type ConversationTheme string
const ( ConversationDark ConversationTheme = "dark" ConversationLight ConversationTheme = "light" )
type EncodeOptions ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine owns shared rendering, network, font, and emoji policy and is safe for concurrent render calls.
func NewEngine ¶
func NewEngine(opts EngineOptions) (*Engine, error)
func (*Engine) RenderConversation ¶
func (e *Engine) RenderConversation(ctx context.Context, messages []ConversationMessage, options ConversationOptions) (*image.NRGBA, error)
func (*Engine) RenderQuote ¶
func (*Engine) WriteConversation ¶
func (e *Engine) WriteConversation(ctx context.Context, w io.Writer, messages []ConversationMessage, options ConversationOptions, encode EncodeOptions) error
func (*Engine) WriteQuote ¶
func (e *Engine) WriteQuote( ctx context.Context, w io.Writer, quote Quote, opts RenderOptions, enc EncodeOptions, ) error
type EngineOptions ¶
type EngineOptions struct {
HTTPClient *http.Client
Offline bool
MaxAssetBytes int64
Fonts []FontFace
FontCacheDir string
DisableAutoFont bool
StrictFonts bool
TwemojiCacheDir string
AllowPrivateNetwork bool
MaxImagePixels int64
ImageCacheEntries int
ImageCacheTTL time.Duration
ImageFailureTTL time.Duration
DisableImageCache bool
}
EngineOptions controls shared I/O policy. More cache and font options will be added behind Engine without changing RenderQuote's signature.
type FieldError ¶
FieldError reports which public input failed validation.
func (*FieldError) Error ¶
func (e *FieldError) Error() string
func (*FieldError) Unwrap ¶
func (e *FieldError) Unwrap() error
type FontFace ¶
FontFace registers one regular font face under Family for the lifetime of an Engine. Data is copied by NewEngine.
type ImageSource ¶
type ImageSource interface {
// contains filtered or unexported methods
}
ImageSource deliberately distinguishes URLs, files, bytes and already decoded images. A string is never guessed to be both a path and a URL.
func ImageBytes ¶
func ImageBytes(b []byte) ImageSource
ImageBytes copies b so a render cannot race with a caller mutating it.
func ImageFile ¶
func ImageFile(path string) ImageSource
func ImageURL ¶
func ImageURL(value *url.URL) ImageSource
func ImageValue ¶
func ImageValue(value image.Image) ImageSource
type MissingAssetBehavior ¶
type MissingAssetBehavior string
const ( AssetAsText MissingAssetBehavior = "text" AssetIgnore MissingAssetBehavior = "ignore" AssetThrow MissingAssetBehavior = "throw" )
type MisskeyOptions ¶
type Quote ¶
type Quote struct {
Text string
Avatar ImageSource
Username string
DisplayName string
Watermark string
}
Quote is the normalized input for one Make it a Quote image.
type RenderOptions ¶
type RenderOptions struct {
Theme theme.Input
Scale float64
Misskey MisskeyOptions
OnAssetError MissingAssetBehavior
BackgroundImage ImageSource
BackgroundFit theme.Fit
BackgroundOpacity *float64
SizeToAvatar AvatarSizeAxis
}
Directories
¶
| Path | Synopsis |
|---|---|
|
adapter
|
|
|
discord
Package discord adapts Discord messages into makeitaquote inputs.
|
Package discord adapts Discord messages into makeitaquote inputs. |
|
misskey
Package misskey adapts Misskey notes into makeitaquote inputs.
|
Package misskey adapts Misskey notes into makeitaquote inputs. |
|
twitter
Package twitter adapts X/Twitter post representations into makeitaquote inputs.
|
Package twitter adapts X/Twitter post representations into makeitaquote inputs. |
|
api
|
|
|
voids
Package voids provides a client for the third-party Voids quote API.
|
Package voids provides a client for the third-party Voids quote API. |
|
Package asset manages persistent fonts and Twemoji used by the renderer.
|
Package asset manages persistent fonts and Twemoji used by the renderer. |
|
cmd
|
|
|
miq
command
|
|
|
miq-gallery
command
Command miq-gallery renders and optionally compares the Go visual gallery.
|
Command miq-gallery renders and optionally compares the Go visual gallery. |
|
examples
|
|
|
go-basic
command
|
|
|
go-conversation
command
|
|
|
go-discord
command
|
|
|
go-theme
command
|
|
|
go-voids
command
|
|
|
internal
|
|
|
gallery
Package gallery generates and compares the repository's visual gallery.
|
Package gallery generates and compares the repository's visual gallery. |
|
testfixture
Package testfixture provides deterministic, non-personal image fixtures.
|
Package testfixture provides deterministic, non-personal image fixtures. |
|
markup
|
|
|
mfm
Package mfm converts Misskey-flavoured markup to the text visible to a user.
|
Package mfm converts Misskey-flavoured markup to the text visible to a user. |