Documentation ¶
Index ¶
- Variables
- type Parameters
- func (p *Parameters) Background() image.Image
- func (p *Parameters) FontFaceSubtitle() *truetype.Font
- func (p *Parameters) FontFaceTitle() *truetype.Font
- func (p *Parameters) Icon() image.Image
- func (p *Parameters) SetBackground(background image.Image) *Parameters
- func (p *Parameters) SetFontFaceSubtitle(fontFaceSubtitle *truetype.Font) *Parameters
- func (p *Parameters) SetFontFaceTitle(fontFaceTitle *truetype.Font) *Parameters
- func (p *Parameters) SetIcon(icon image.Image) *Parameters
- func (p *Parameters) SetSubtitle(subtitle string) *Parameters
- func (p *Parameters) SetTitle(title string) *Parameters
- func (p *Parameters) Subtitle() string
- func (p *Parameters) Title() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrParametersInvalid = bridge.NewJSTypeError("ParameterError", "Invalid parameters") ErrParametersInvalidField = bridge.NewJSTypeError("ParameterError", "Invalid parameters field") ErrInvalidCloudflareEnv = bridge.NewJSTypeError("EnvError", "Invalid cloudflare env") ErrBucketNotFound = bridge.NewJSTypeError("EnvError", "Bucket not found") )
View Source
var JsDraw = js.FuncOf(func(this js.Value, args []js.Value) any { rawParameters := args[0] bucket := args[1] quality := args[2] return js.Global().Get("Promise").New(js.FuncOf(func(this js.Value, args []js.Value) any { resolve := args[0] reject := args[1] q, err := parseQuality(quality) if err != nil { reject.Invoke(bridge.ToJsError(err)) return nil } go func() { parameters, err := LoadParameters(rawParameters, bucket) if err != nil { reject.Invoke(bridge.ToJsError(err)) return } result, err := draw.Draw(parameters) if err != nil { reject.Invoke(bridge.ToJsError(err)) return } pr, pw := io.Pipe() go func() { err = jpeg.Encode(pw, result, &jpeg.Options{ Quality: q, }) defer pw.Close() if err != nil { reject.Invoke(bridge.ToJsError(err)) return } }() resolve.Invoke(reader.NewReadableStreamFrom(pr, 2048)) }() return nil })) })
signature: function draw(parameters: payload, bucketName: string, env: any): Promise<ReadableStream>
Functions ¶
This section is empty.
Types ¶
type Parameters ¶
type Parameters struct { R2PathIcon string R2PathBackground string FontTitle string FontSubtitle string // contains filtered or unexported fields }
func LoadParameters ¶
func (*Parameters) Background ¶
func (p *Parameters) Background() image.Image
func (*Parameters) FontFaceSubtitle ¶
func (p *Parameters) FontFaceSubtitle() *truetype.Font
func (*Parameters) FontFaceTitle ¶
func (p *Parameters) FontFaceTitle() *truetype.Font
func (*Parameters) Icon ¶
func (p *Parameters) Icon() image.Image
func (*Parameters) SetBackground ¶
func (p *Parameters) SetBackground(background image.Image) *Parameters
func (*Parameters) SetFontFaceSubtitle ¶
func (p *Parameters) SetFontFaceSubtitle(fontFaceSubtitle *truetype.Font) *Parameters
func (*Parameters) SetFontFaceTitle ¶
func (p *Parameters) SetFontFaceTitle(fontFaceTitle *truetype.Font) *Parameters
func (*Parameters) SetIcon ¶
func (p *Parameters) SetIcon(icon image.Image) *Parameters
func (*Parameters) SetSubtitle ¶
func (p *Parameters) SetSubtitle(subtitle string) *Parameters
func (*Parameters) SetTitle ¶
func (p *Parameters) SetTitle(title string) *Parameters
func (*Parameters) Subtitle ¶
func (p *Parameters) Subtitle() string
func (*Parameters) Title ¶
func (p *Parameters) Title() string
Click to show internal directories.
Click to hide internal directories.