pkg

package
v0.0.0-...-49d6d54 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SavingMethods []SavingMethod = []SavingMethod{
	{Name: "PNG", AllowedExtensions: []string{".png"}, WritingFunction: WriteSurfaceToPNG},
	{Name: "JPEG", AllowedExtensions: []string{".jpeg", ".jpg"}, WritingFunction: WriteSurfaceToJPEG},
	{Name: "GIF", AllowedExtensions: []string{".gif"}, WritingFunction: WriteSurfaceToGIF},
	{Name: "WEBP", AllowedExtensions: []string{".webp"}, WritingFunction: WriteSurfaceToWEBP},
	{Name: "BMP", AllowedExtensions: []string{".bmp"}, WritingFunction: WriteSurfaceToBMP},
}

Functions

func Abs

func Abs[I SInteger | Float](integer I) I

func Clamp

func Clamp[N Number](min N, number N, max N) N

func CopyTexture

func CopyTexture(ren *sdl.Renderer, texture *sdl.Texture, dst *sdl.Rect, blendMode *sdl.BlendMode)

func CreateTextureFromSurface

func CreateTextureFromSurface(ren *sdl.Renderer, surface *sdl.Surface) *sdl.Texture

func DrawCircle

func DrawCircle(ren *sdl.Renderer, center *sdl.Point, radius int32, color sdl.Color)

func DrawFilledCircle

func DrawFilledCircle(ren *sdl.Renderer, center *sdl.Point, radius int32, color sdl.Color)

func DrawFilledRectangle

func DrawFilledRectangle(ren *sdl.Renderer, rect *sdl.Rect, color sdl.Color)

func DrawPoint

func DrawPoint(ren *sdl.Renderer, point *sdl.Point, color sdl.Color)

func DrawRectangle

func DrawRectangle(ren *sdl.Renderer, rect *sdl.Rect, color sdl.Color)

func DrawRoundedFilledRectangle

func DrawRoundedFilledRectangle(ren *sdl.Renderer, rect *sdl.Rect, radius int32, color sdl.Color)

func DrawThickCircle

func DrawThickCircle(ren *sdl.Renderer, center *sdl.Point, radius int32, width int32, color sdl.Color)

func DrawThickLine

func DrawThickLine(ren *sdl.Renderer, p1 *sdl.Point, p2 *sdl.Point, width int32, color sdl.Color)

func DrawThickRectangle

func DrawThickRectangle(ren *sdl.Renderer, rect *sdl.Rect, width int32, color sdl.Color)

func GetSearchURL

func GetSearchURL(imageURL string) string

func Linspace

func Linspace(start, stop float64, num int) []float64

func LoadFont

func LoadFont(fontData []byte, size int) *ttf.Font

func LoadPNGSurface

func LoadPNGSurface(pngData []byte) *sdl.Surface

func Max

func Max[N Number](first N, others ...N) N

func Min

func Min[N Number](first N, others ...N) N

func OpenUrlInBrowser

func OpenUrlInBrowser(url string)

func ReadRGBA32

func ReadRGBA32(ren *sdl.Renderer, rect *sdl.Rect) []uint8

func RectIntoSquare

func RectIntoSquare(rect *sdl.Rect)

func SizeString

func SizeString(font *ttf.Font, text string) (int, int)

func UploadImage

func UploadImage(img io.Reader) (string, error)

func WriteSurfaceToBMP

func WriteSurfaceToBMP(surface *sdl.Surface, writer io.Writer)

func WriteSurfaceToGIF

func WriteSurfaceToGIF(surface *sdl.Surface, writer io.Writer)

func WriteSurfaceToJPEG

func WriteSurfaceToJPEG(surface *sdl.Surface, writer io.Writer)

func WriteSurfaceToPNG

func WriteSurfaceToPNG(surface *sdl.Surface, writer io.Writer)

func WriteSurfaceToWEBP

func WriteSurfaceToWEBP(surface *sdl.Surface, writer io.Writer)

Types

type Animation

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

func NewLinearAnimation

func NewLinearAnimation(startValue, endValue, fps int, duration time.Duration, repeats int, isCycled bool) *Animation

func (*Animation) CurrentValue

func (animation *Animation) CurrentValue() int

func (*Animation) End

func (animation *Animation) End()

func (*Animation) IsEnded

func (animation *Animation) IsEnded() bool

func (*Animation) ReStart

func (animation *Animation) ReStart()

type Float

type Float interface {
	float32 | float64
}

type Integer

type Integer interface {
	SInteger | Uinteger
}

type Number

type Number interface {
	Integer | Float
}

type SInteger

type SInteger interface {
	int | int8 | int16 | int32 | int64
}

type SavingMethod

type SavingMethod struct {
	Name              string
	AllowedExtensions []string
	WritingFunction   func(surface *sdl.Surface, writer io.Writer)
}

type SavingOptions

type SavingOptions struct {
	Filepath string
	Method   SavingMethod
}

func RequestSavingOptions

func RequestSavingOptions(
	dialogTitle,
	dialogStartFileName string,
) (
	options *SavingOptions,
	success bool,
)

type StringTexture

type StringTexture struct {
	Texture    *sdl.Texture
	TextWidth  int32
	TextHeight int32
}

func NewStringTexture

func NewStringTexture(ren *sdl.Renderer, font *ttf.Font, text string, color sdl.Color) *StringTexture

func (*StringTexture) Destroy

func (text *StringTexture) Destroy()

func (*StringTexture) Draw

func (text *StringTexture) Draw(ren *sdl.Renderer, leftTop *sdl.Point)

type TextParagraph

type TextParagraph struct {
	Text          []rune
	StringTexture *StringTexture
	TextStart     sdl.Point
	Color         sdl.Color
	Font          *ttf.Font
	// contains filtered or unexported fields
}

func NewTextParagraph

func NewTextParagraph(
	textStart sdl.Point,
	textColor sdl.Color,
	textFont *ttf.Font,
	paragraphPadding int32,
) *TextParagraph

func (TextParagraph) ClosestLeftWordPos

func (par TextParagraph) ClosestLeftWordPos(pos int) int

func (TextParagraph) ClosestRightWordPos

func (par TextParagraph) ClosestRightWordPos(pos int) int

func (TextParagraph) GetBBox

func (par TextParagraph) GetBBox() *sdl.Rect

func (TextParagraph) GetLineNumber

func (par TextParagraph) GetLineNumber(position int) int

func (*TextParagraph) GetLinesBoundaries

func (par *TextParagraph) GetLinesBoundaries() [][2]int

func (TextParagraph) GetOffsetByPosition

func (par TextParagraph) GetOffsetByPosition(position int) (int32, int32)

func (TextParagraph) GetPaddedBBox

func (par TextParagraph) GetPaddedBBox(padding int32) *sdl.Rect

func (TextParagraph) GetPositionByOffset

func (par TextParagraph) GetPositionByOffset(xOffset int32, yOffset int32) int

func (*TextParagraph) InsertRunes

func (par *TextParagraph) InsertRunes(ren *sdl.Renderer, pos int, runes ...rune)

func (TextParagraph) LowerLinePos

func (par TextParagraph) LowerLinePos(position int) int

func (*TextParagraph) PopRunes

func (par *TextParagraph) PopRunes(ren *sdl.Renderer, startPos, endPos int)

func (*TextParagraph) SetColor

func (par *TextParagraph) SetColor(color sdl.Color)

func (TextParagraph) UpperLinePos

func (par TextParagraph) UpperLinePos(position int) int

type Uinteger

type Uinteger interface {
	uint | uint8 | uint16 | uint32 | uint64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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