require "asobi"
flower = petal(40, 16).repeat(8).in_fan.colored(:crimson, :navy)
bloom = flower + circle(5).colored(:gold)
show bloom.spin(every: 8)
Flower
01 · flower.rb
A petal, copied and fanned out. Two colours take turns.
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
Night sky
02 · night_sky.rb
Stars are scattered at random, glow, and twinkle one after another. Each run is different.
require "asobi"
dots = circle(6).repeat(16).in_row(gap: 6).colored(:teal)
show dots.bounce(height: 30, every: 2).one_by_one
Wave of dots
03 · dot_wave.rb
One bounce, started a little later for each dot.
require "asobi"
dots = circle(4).repeat(24).in_ring(60).colored(:crimson, :orange)
show dots.pulse(every: 2, to: 2).one_by_one
Ring of dots
04 · ring_pulse.rb
Each dot pulses around its own centre, so the ring keeps its shape.
require "asobi"
rings = ring(80, 4).repeat(10).change_each { |r, t| r.scale(1 - t * 0.9) }
show rings.colored(:navy, :skyblue).pulse(every: 2, to: 1.1).one_by_one
Concentric rings
05 · rings.rb
One ring, copied and shrunk a little more each time.
require "asobi"
fib = [1, 1, 2, 3, 5, 8, 13, 21]
show fib.to_art(as: star).colored(:gold, :orange), on: :black
A number sequence
06 · sequence.rb
The Fibonacci numbers, asked to be stars. The numbers become the sizes.
require "asobi"
letters = "asobi".chars.to_art.change_each { |c, t| c.grow(to: 1 + t * 2) }
show letters.in_row(gap: 4).colored(:crimson, :navy)
Letters
07 · typography.rb
A word split into letters. Each letter is bigger than the last.
require "asobi"
tiles = square(18).repeat(36).change_each { |s, t| s.rotate(t * 90).grow(to: 1 - t * 0.5) }
show tiles.in_grid(6, gap: 4).colored(:tomato, :navy)
Tiles
08 · tiles.rb
A grid of squares. Each one is turned and shrunk a little more.
require "asobi"
hearts = heart(20).repeat(5).in_row(gap: 6)
show hearts.shift_color(:crimson, :orchid).one_by_one.bounce(height: 24).one_by_one
Bouncing hearts
09 · hearts.rb
Colour and bounce, both one by one.
require "asobi"
class Planet
def initialize(size, distance, color, year)
@size, @distance, @color, @year = size, distance, color, year
end
def to_art
ring(@distance, 0.4).colored(:dimgray) +
circle(@size).colored(@color).orbit(@distance, every: @year)
end
end
sun = circle(10).colored(:gold)
planets = [Planet.new(3, 22, :skyblue, 3), Planet.new(5, 38, :tomato, 7), Planet.new(4, 54, :orchid, 12)]
show planets.reduce(sun) { |system, planet| system + planet }, on: :black
Solar system
10 · planets.rb
Your own class, Planet, only has to say what it looks like.
require "asobi"
seeds = circle(3).repeat(300).change_each { |d, t| d.grow(to: 0.4 + t).colored(hsl(20 + t * 40)) }
show seeds.in_spiral(5)
Sunflower spiral
11 · spiral.rb
300 seeds at the golden angle, growing and changing colour as they go out.
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
Neon flower
12 · neon_flower.rb
Two bright colours on black. Glow, screen blending and a film grain make it shine.
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
Aurora
13 · aurora.rb
Three wavy lines, blurred, with screen blending, drifting slowly.
require "asobi"
sun = circle(22).colored(:gold).move(up: 20, right: 40)
far = ellipse(240, 80).colored(:lightseagreen).move(down: 45, left: 30)
near = ellipse(220, 70).colored(:seagreen).move(down: 62, right: 40)
show [sun, far, near].map(&:shadowed).reduce(:+), on: :oldlace
Paper cut-outs
14 · paper_cutouts.rb
Flat shapes, each with a soft shadow, on a light page: they look like paper lying on paper.
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
Through a heart
15 · through_a_heart.rb
Gradient stripes spin behind a heart-shaped window.