types

package
v0.0.0-...-102030d Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScratchResolutionX  = 480
	ScratchResolutionY  = 360
	MaxBitmapResolution = 2
)

Variables

This section is empty.

Functions

func Clear

func Clear()

func GetRandomString

func GetRandomString() string

func MarshalBool

func MarshalBool(val bool) string

func MarshalInterfaceArray

func MarshalInterfaceArray(vals []interface{}) string

func MarshalStringArray

func MarshalStringArray(vals []string) string

Types

type BroadcastMessage

type BroadcastMessage struct {
	Name string
	// contains filtered or unexported fields
}

func NewScratchBroadcastMessage

func NewScratchBroadcastMessage(name, id string) *BroadcastMessage

func (*BroadcastMessage) ScratchID

func (b *BroadcastMessage) ScratchID() string

type FS

type FS interface {
	Create(string) (io.Writer, error)
}

type List

type List struct {
	Name          string
	InitialValues []interface{}

	Local bool
	// contains filtered or unexported fields
}

func (*List) ScratchID

func (l *List) ScratchID() string

func (*List) SetScratchListID

func (l *List) SetScratchListID(id string)

func (*List) SetScratchSpriteName

func (l *List) SetScratchSpriteName(name string)

func (*List) SpriteName

func (l *List) SpriteName() string

type ScratchAsset

type ScratchAsset struct {
	AssetID    string `json:"assetId"` // Name of file without extension
	Name       string `json:"name"`
	Md5Ext     string `json:"md5ext"`     // AssetID + extension
	DataFormat string `json:"dataFormat"` // `svg` if costume, `wav` if sound, `png` if image
}

type ScratchBlock

type ScratchBlock struct {
	Opcode   string                  `json:"opcode"`
	Next     *string                 `json:"next"`   // string or null, id of next
	Parent   *string                 `json:"parent"` // string or null - from scratch wiki: If the block is a stack block and is preceded, this is the ID of the preceding block. If the block is the first stack block in a C mouth, this is the ID of the C block. If the block is an input to another block, this is the ID of that other block. Otherwise it is null.
	Inputs   map[string]ScratchInput `json:"inputs"` // map[inputName]InputValue, use Shadow for constand and Obscured for block in it
	Fields   map[string]ScratchField `json:"fields"` // map[fieldName]FieldValue
	Shadow   bool                    `json:"shadow"`
	TopLevel bool                    `json:"topLevel"` // False if the block has a parent and true otherwise.
	Mutation *ScratchMutation        `json:"mutation,omitempty"`

	X       *int    `json:"x,omitempty"` // If toplevel
	Y       *int    `json:"y,omitempty"`
	Comment *string `json:"comment,omitempty"` // ID of comment if it has one
}

type ScratchComment

type ScratchComment struct {
	BlockID   string `json:"blockId"`
	X         int    `json:"x"`
	Y         int    `json:"y"`
	Width     int    `json:"width"`
	Height    int    `json:"height"`
	Minimized bool   `json:"minimized"`
	Text      string `json:"text"`
}

type ScratchCostume

type ScratchCostume struct {
	ScratchAsset

	BitmapResolution int `json:"bitmapResolution"` // Usually 1
	RotationCenterX  int `json:"rotationCenterX"`
	RotationCenterY  int `json:"rotationCenterY"`
}

type ScratchField

type ScratchField interface {
	// contains filtered or unexported methods
}

func NewScratchFieldBroadcast

func NewScratchFieldBroadcast(name, id string) ScratchField

func NewScratchFieldString

func NewScratchFieldString(val string) ScratchField

func NewScratchValueFieldVariable

func NewScratchValueFieldVariable(name, id string) ScratchField

type ScratchInput

type ScratchInput []interface{}

func NewScratchInputNoShadow

func NewScratchInputNoShadow(val string) ScratchInput

func NewScratchInputNoShadowBlock

func NewScratchInputNoShadowBlock(val ScratchValue) ScratchInput

func NewScratchInputObscured

func NewScratchInputObscured(val ScratchValue, below ScratchValue) ScratchInput

func NewScratchInputShadow

func NewScratchInputShadow(val ScratchValue) ScratchInput

func NewScratchInputStack

func NewScratchInputStack(firstId string) ScratchInput

type ScratchMetadata

type ScratchMetadata struct {
	SemVer string `json:"semver"`
	VM     string `json:"vm"`
	Agent  string `json:"agent"`
}

type ScratchMonitor

type ScratchMonitor struct {
	// Data
	ID         string            `json:"id"`         // ID of variable it shows
	Mode       string            `json:"mode"`       // Default, Large, Slider, List
	Opcode     string            `json:"opcode"`     // Seems to be `data_variable` or `data_listcontents`
	Params     map[string]string `json:"params"`     // Parameters, can have VARIABLE => variable name, LIST => list name
	SpriteName *string           `json:"spriteName"` // Name of sprite its associated to, can be null or string
	Value      interface{}       `json:"value"`      // Value on monitor

	// Characteristics
	Width   int  `json:"width"`
	Height  int  `json:"height"`
	X       int  `json:"x"`
	Y       int  `json:"y"`
	Visible bool `json:"visible"`

	// Slider
	SliderMin  *int `json:"sliderMin,omitempty"`
	SliderMax  *int `json:"sliderMax,omitempty"`
	IsDiscrete bool `json:"isDiscrete"` // Does slider allow integer values?
}

type ScratchMutation

type ScratchMutation struct {
	TagName          string  `json:"tagName"`                    // always "mutation"
	Children         []bool  `json:"children"`                   // seems to be just an empty array
	ProcCode         *string `json:"proccode,omitempty"`         // name of block, has parameters in it like "add %s %s label %b" where %s is string/number and %b is boolean
	ArgumentIDs      *string `json:"argumentids,omitempty"`      // []string, but marshal with JSON (use MarshalStringArray)
	ArgumentNames    *string `json:"argumentnames,omitempty"`    // []string, but marshal with JSON (use MarshalStringArray)
	ArgumentDefaults *string `json:"argumentdefaults,omitempty"` // []interface{}, but marshal each element with JSON into []string and then marshal that with JSON (use MarshalInterfaceArray)
	Warp             *string `json:"warp,omitempty"`             // run without screen refresh? (string of bool, with JSON)
	HasNext          *string `json:"hasnext,omitempty"`          // bool, marshal into JSON
}

type ScratchProject

type ScratchProject struct {
	Targets    []ScratchTarget  `json:"targets"`
	Monitors   []ScratchMonitor `json:"monitors"`
	Extensions []string         `json:"extensions"`
	Metadata   ScratchMetadata  `json:"meta"`
}

type ScratchSound

type ScratchSound struct {
	ScratchAsset

	Format      string `json:"format"`      // Not sure what this is, seems to be an empty string
	Rate        int    `json:"rate"`        // Sampling rate in hertz
	SampleCount int    `json:"sampleCount"` // Sample count of WAV
}

type ScratchSprite

type ScratchSprite struct {
	ScratchTargetBase

	LayerOrder    int    `json:"layerOrder"` // Layer on screen
	X             int    `json:"x"`
	Y             int    `json:"y"`
	Size          int    `json:"size"`      // 0-100 percent, can go past 100 to scale up
	Direction     int    `json:"direction"` // degrees
	Draggable     bool   `json:"draggable"`
	RotationStyle string `json:"rotationStyle"` // Scratch rotation style, can be `all around`, `left-right`, and `don't rotate`
	Visible       bool   `json:"visible"`
}

type ScratchStage

type ScratchStage struct {
	ScratchTargetBase

	TextToSpeechLanguage *string `json:"textToSpeechLanguage"` // string or null
	VideoState           string  `json:"videoState"`           // seems to be "on" always
}

type ScratchTarget

type ScratchTarget interface {
	// contains filtered or unexported methods
}

type ScratchTargetBase

type ScratchTargetBase struct {
	IsStage        bool                            `json:"isStage"`
	Name           string                          `json:"name"`
	Variables      map[string]ScratchVariableValue `json:"variables"`
	Lists          map[string]ScratchVariableValue `json:"lists"`
	Broadcasts     map[string]string               `json:"broadcasts"` // map[id]name, is an empty map on everything but stage
	Blocks         map[string]ScratchBlock         `json:"blocks"`     // map[id]block
	Comments       map[string]ScratchComment       `json:"comments"`   // map[id]comment
	CurrentCostume int                             `json:"currentCostume"`
	Costumes       []ScratchCostume                `json:"costumes"`
	Sounds         []ScratchSound                  `json:"sounds"`
	Volume         int                             `json:"volume"`
}

type ScratchValue

type ScratchValue interface {
	// contains filtered or unexported methods
}

func NewScratchAngle

func NewScratchAngle(val int) ScratchValue

func NewScratchBlockInput

func NewScratchBlockInput(id string) ScratchValue

func NewScratchBroadcast

func NewScratchBroadcast(name, id string) ScratchValue

func NewScratchColor

func NewScratchColor(hex string) ScratchValue

NOTE: Requires with #

func NewScratchFloat

func NewScratchFloat(val float64) ScratchValue

func NewScratchInt

func NewScratchInt(val int) ScratchValue

func NewScratchList

func NewScratchList(name, id string) ScratchValue

func NewScratchPosFloat

func NewScratchPosFloat(val float64) ScratchValue

func NewScratchPosInt

func NewScratchPosInt(val int) ScratchValue

func NewScratchString

func NewScratchString(val string) ScratchValue

func NewScratchVariable

func NewScratchVariable(name, id string) ScratchValue

type ScratchVariableValue

type ScratchVariableValue []interface{} // name (string), value (int, string, list, etc.)

type Value

type Value interface {
	Build() ScratchInput
}

type Variable

type Variable struct {
	Name         string
	InitialValue interface{}

	Local bool
	// contains filtered or unexported fields
}

func (*Variable) ScratchID

func (v *Variable) ScratchID() string

func (*Variable) SetScratchID

func (v *Variable) SetScratchID(id string)

func (*Variable) SetScratchSpriteName

func (v *Variable) SetScratchSpriteName(name string)

func (*Variable) SpriteName

func (v *Variable) SpriteName() string

Jump to

Keyboard shortcuts

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