Ruby · creative coding · v0.1.0
asobi
Play with pictures in Ruby. Hold them, copy them, arrange them.
gem install asobigem install asobi, then type asobi in a terminal. A sketch opens in your browser.
require "asobi"
flower = petal(40, 16).repeat(10).in_fan.colored(from: :hotpink, to: :gold, around: true)
comet = circle(4).colored(:white).orbit(62, every: 6).trail(12)
sky = flower.animate(2) { |f, t| f.rotate(t * 36) } + comet
show sky.glowing, on: :black, grain: true
Now playing: asobi.rb
require "asobi"
flower = petal(40, 16).repeat(10).in_fan.colored(from: :hotpink, to: :gold, around: true)
comet = circle(4).colored(:white).orbit(62, every: 6).trail(12)
sky = flower.animate(2) { |f, t| f.rotate(t * 36) } + comet
show sky.glowing, on: :black, grain: true
require "asobi"
petals = petal(50, 18).repeat(8).in_fan.colored(:deeppink, :cyan)
spinning = petals.animate(2) { |flower, t| flower.rotate(t * 90) }
show spinning.trail(4).glowing.blended(:screen), on: :black, grain: true
require "asobi"
ribbon = wave(240, 30, 2).outlined(:springgreen, width: 14)
bands = ribbon.repeat(3).change_each { |w, t, i| w.move(down: i * 14).colored(hsl(150 + i * 50)) }
show bands.drift(right: 40, every: 6).blurred(4).blended(:screen), on: :midnightblue, grain: true
require "asobi"
stripes = rect(10, 90).repeat(12).in_row(gap: 4).colored(from: :crimson, to: :gold, angle: 90)
show stripes.spin(every: 6).clipped_by(heart(70)), on: :navy
require "asobi"
stars = star(radius: 4).repeat(40).change_each { |s, t| s.grow(to: 0.6 + t) }
sky = stars.colored(:gold).scattered(over: [320, 180]).glowing.fade(every: 3, to: 0.4).one_by_one
show sky + moon(size: 40).colored(:ivory).glowing(8).move(right: 110, up: 50), on: :midnightblue
01 / What asobi believes
What asobi believes
- 01
Treat objects as pictures, and pictures as objects.
- 02
What matters is that it is fun to write, easy to follow, and instantly playable.
- 03
A picture is like a sticker: make it, copy it, arrange it, and you still have one picture.
02 / step
One word at a time
Every step is a whole sketch. Add one word, and the picture answers.
-
01
petal
A shape.
Open in playgroundshow petal -
02
repeat
Eight of them, all in one place.
Open in playgroundshow petal.repeat(8) -
03
in_fan
Arranged in a fan.
Open in playgroundshow petal.repeat(8).in_fan -
04
colored
Two colours take turns.
Open in playgroundshow petal.repeat(8).in_fan.colored(:deeppink, :cyan) -
05
glowing
It glows, on black.
Open in playgroundshow petal.repeat(8).in_fan.colored(:deeppink, :cyan).glowing, on: :black -
06
spin
And it moves.
Open in playgroundshow petal.repeat(8).in_fan.colored(:deeppink, :cyan).glowing.spin(every: 8), on: :black
03 / Examples
From the gallery
04 / Reference
Every word, one page
71 words in 9 groups. Each one with a picture that runs.
22 words