canvas

package
v0.0.0-...-376d78b Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArialUnicodeMS *truetype.Font
View Source
var ArialUnicodeMSRaw []byte
View Source
var Module = &starlarkstruct.Module{
	Name: "canvas",
	Members: starlark.StringDict{
		"Context": starlark.NewBuiltin("Context", func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (_ starlark.Value, err error) {
			var width, height starlark.Int
			err = starlark.UnpackArgs(fn.Name(), args, kwargs, "width", &width, "height", &height)
			if err != nil {
				return nil, err
			}
			return NewContext(width, height)
		}),
	},
}

Functions

func GetFace

func GetFace(size float64) font.Face

func GoFloatToStarlarkInt

func GoFloatToStarlarkInt(val any) (_ starlark.Float, ok bool)

func GoIntToStarlarkInt

func GoIntToStarlarkInt(val any) (_ starlark.Int, ok bool)

func GoValueToStarlarkValue

func GoValueToStarlarkValue(val any) (_ starlark.Value, ok bool)

support int*、float*、string、bool

func PackMethodResults

func PackMethodResults(method reflect.Value, results []reflect.Value) (starlark.Value, error)

多个参数则返回 starlark.Tuple

func UnpackMethodArgs

func UnpackMethodArgs(name string, args starlark.Tuple, kwargs []starlark.Tuple, method reflect.Value) ([]reflect.Value, error)

func ValueToGoFloat

func ValueToGoFloat[T ~float32 | float64](val starlark.Value) (_ T, ok bool)

接受 int、float

func ValueToGoInt

func ValueToGoInt[T ~int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64](val starlark.Value) (_ T, ok bool)

func ValueToGoString

func ValueToGoString(val starlark.Value) (_ string, ok bool)

Types

type DrawContext

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

func NewContext

func NewContext(width, height starlark.Int) (_ *DrawContext, err error)

func (*DrawContext) Attr

func (d *DrawContext) Attr(name string) (starlark.Value, error)

Attr implements starlark.HasAttrs.

func (*DrawContext) AttrNames

func (d *DrawContext) AttrNames() []string

AttrNames implements starlark.HasAttrs.

func (*DrawContext) Freeze

func (d *DrawContext) Freeze()

Freeze implements starlark.Value.

func (*DrawContext) GetBase64

func (d *DrawContext) GetBase64(format string, quality int) (_ starlark.String, err error)

format is png or jpeg. quality only working for jpeg

func (*DrawContext) GetDataURI

func (d *DrawContext) GetDataURI(format string, quality int) (_ starlark.String, err error)

func (*DrawContext) Hash

func (d *DrawContext) Hash() (uint32, error)

Hash implements starlark.Value.

func (*DrawContext) String

func (d *DrawContext) String() string

String implements starlark.Value.

func (*DrawContext) Truth

func (d *DrawContext) Truth() starlark.Bool

Truth implements starlark.Value.

func (*DrawContext) Type

func (d *DrawContext) Type() string

Type implements starlark.Value.

Jump to

Keyboard shortcuts

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