Blocks are pieces of puzzle-shapes to code in Snap!. They connect vertically. Each block type (Commands, Reporters, Predicates, Hats, Caps) has its own shapes. There are block categories as well, namely Motion, Looks, Sound, Pen, Control, Sensing, Operators, Variables, Lists, and Others.

Blocks

Motion

move (10) steps

turn cw (15) degrees

turn ccw (15) degrees

point in direction (90 v)

point towards [mouse-pointer V]

go to x: (0) y: (0)

go to [random position V]

glide (1) secs to x: (0) y: (0)

change x by (10)

set x to (0)

change y by (10)

set y to (0)

if on edge, bounce

(position)

(x position)

(y position)

(direction)

Looks

switch to costume [ V]

next costume

(costume #)

say [Hello!] for (2) secs

say [Hello!]

think [Hmm...] for (2) secs

think [Hmm...]

([width V] of costume [current V])

(stretch [current V] x: (100) y: (50) %)

(new costume @list width ( v) height ( v))

change [ghost V] effect by (25)

set [ghost V] effect to (0)

clear graphic effects

([ghost V] effect)

change size by (10)

set size to (100) %

(size)

show

hide

<shown?>

go to [front V] layer

go back (1) layers

Sound

play sound [ V]

play sound [ V] until done

stop all sounds

play sound [ V] at (44100 v) Hz

([duration V] of sound [ V])

(new sound @list rate (44100 v) Hz)

rest for (0.2) beats

play note (60 v) for (0.5) beats

set instrument to (1 v)

change tempo by (20)

set tempo to (60) bpm

(tempo)

change volume by (10)

set volume to (100) %

(volume)

change balance by (10)

set balance to (0)

(balance)

play frequency (440) Hz

stop frequency

Pen

clear

pen down

pen up

<pen down?>

set pen color to [#911a44]

change pen [hue V] by (10)

set pen [hue V] to (50)

(pen [hue V])

change pen size by (1)

set pen size to (1)

stamp

fill

write [Hello] size (12)

(pen trails)

paste on [ V]

cut from [ V]

Control

when green flag clicked

when [space V] key pressed

when I am [clicked V]

when <>

when I receive [ V] @addInput

broadcast [ V] @addInput

broadcast [ V] @addInput and wait

warp { }

wait (1) secs

wait until <>

forever { }

repeat (10) { }

repeat until <> { }

for ((i)) = (1) to (10) { }

if <> { } @addInput

if <> { } else { }

(if <> then [] else [])

report []

stop [all V]

run ({} @addInput) @verticalEllipsis @addInput

launch ({} @addInput) @verticalEllipsis @addInput

(call (() @addInput) @verticalEllipsis @addInput

(pipe [] @arrowRight (() @addInput) @delInput @verticalEllipsis @addInput)

tell [ V] to ({} @addInput) @verticalEllipsis @addInput

(ask [ V] for (() @addInput) @verticalEllipsis @addInput

when I start as a clone

create a clone of [myself V] :: control

(a new clone of [myself V])

delete this clone

pause all @pause

switch to scene [ V] @addInput

when [ V] is edited @addInput

define ((block)) [] (() @addInput)

delete block (() @addInput)

set [label V] of block (() @addInput) to []

([definition V] of block (() @addInput))

(this [script V])

Sensing

<touching [mouse-pointer V] ?>

<touching [#911a44] ?>

<color [#911a44] is touching [#911a44] ?>

ask [what’s your name?] and wait

(answer)

(mouse position)

(mouse x)

(mouse y)

<mouse down?>

<key [space V] pressed?>

([distance V] to [mouse-pointer V])

([hue V] at [mouse-pointer V])

reset timer

(timer)

(current [date V])

([costume # V] of [ V])

(my [neighbors V])

(object [myself V])

(url [snap.berkeley.edu])

(microphone [volume V])

(video [motion V] on [myself V])

set video transparency to (50)

<is [turbo mode V] on?>

set [video capture V] to <>

Operators

({} @addInput) (() @addInput) (<> @addInput)

(() + () @delInput @verticalEllipsis @addInput)

(() - ())

(() x () @delInput @verticalEllipsis @addInput)

(() / ())

(() ^ ())

(() mod ())

(() min () @delInput @verticalEllipsis @addInput)

(() max () @delInput @verticalEllipsis @addInput)

(round ())

([sqrt V] of (10))

(atan2 () / ())

(pick random (1) to (10))

<[] < [] @delInput @verticalEllipsis @addInput>

<[] = [] @delInput @verticalEllipsis @addInput>

<[] > [] @delInput @verticalEllipsis @addInput>

<<> and <> @delInput @verticalEllipsis @addInput>

<<> or <> @delInput @verticalEllipsis @addInput>

<not <>>

<<true (:: grey) :: operators> :: operators >

(join [hello ][world] @delInput @verticalEllipsis @addInput)

(split [hello world] by [ v])

(letter (1 v) of [world])

([length V] of text [hello world])

(unicode of [a])

(unicode (65) as letter)

<is [5] a [number V] ?>

<is [] identical to [] @delInput @verticalEllipsis @addInput ?>

(Javascript function \( [] @delInput @verticalEllipsis @addInput \) \{ [] \})

Variables

(variable)

set [ V] to [0]

change [ V] by [1]

show variable [ V]

hide variable [ V]

script variables ((a)) @addInput

inherit [ V]

Lists

(list [] @delInput @addInput)

(numbers from (1) to (10))

([] in front of @list)

(item [1 v] of @list)

(all but first of @list)

([length V] of @list)

(index of [thing] in @list)

<@list contains [things]>

<is @list empty?>

(map (() @addInput) over @list)

(keep items (<> @addInput) from @list)

(find first item (<> @addInput) in @list)

(combine @list using (() @addInput)

for each ((item)) in @list { }

add [thing] to @list

delete (1 v) of @list

insert [thing] at (1 v) of @list

replace item (1 v) of @list with [thing]

(append @list @list @delInput @verticalEllipsis @addInput)

(reshape [] to (4) (3) @delInput @addInput)

(combinations @list @list @delInput @verticalEllipsis @addInput)