Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Shoes - THE TUTORIAL WALKTHROUGH written by _why

branch: master

Merge pull request #4 from dalton/patch-1

Text said circle when it should have been rectangle.
latest commit da8ddeafe9
ashbb authored July 11, 2012
Octocat-spinner-32 imgs Restore snapshot 001 August 28, 2011
Octocat-spinner-32 Text said circle when it should have been rectangle. July 10, 2012
Octocat-spinner-32 Backup README original file. August 28, 2011


This is a copy of the original web site written by _why.

It's now gone. :(


In case you've just arrived: Shoes is a graphics toolkit for writing colorful apps using the Ruby programming language. Ruby is built into Shoes.

Shoes wants to fit in. It will change the way it looks for each person's computer. These screenshots were taken on my computer, but when you run them for yourself they will look just like your other programs. Try it!


An introduction to Shoes. Code and graphical pairs.

Okay, so, a simple Shoes program.

001.png { button "Push me" }

You can just save the program in a file called little.rb and open it with Shoes.

The braces { and } are a kind of container. The button is "in" the app.


We can place a few buttons in a stack. {
  stack {
    button "A bed of clams"
    button "A coalition of cheetahs"
    button "A gulp of swallows"

Stacks are essential! The most important two elements in Shoes are stacks and flows.


Okay, let's give the stack a bit of a margin. Scoot it out from the edge. {
  background white
  stack(:margin => 8) {
    button "A bed of clams"
    button "A coalition of cheetahs"
    button "A gulp of swallows"

We also painted the background white. Did you see that?


Time for something new, artwork! Let's draw! {
    :left => 10,
    :top => 10,
    :radius => 40

The Shoes brush always starts out black.

Notice that while buttons just dropped into the window, we drew the circle at a specific place. At 10 pixels from the left edge of the window and 10 pixels below the top edge.


Now, a rectangle and an arrow. {
  fill red
    :left => 10,
    :top => 10,
    :width => 40
    :left => 30,
    :top => 60,
    :width => 40

The fill is red on these shapes. And the stroke is black. (Because we didn't change it.) These two pens - stroke and fill - draw every shape.

Did you see how the arrow is a little overtop of the rectangle?

Of course, you can always design your app with an image. Even images from the web! {
  image ""

Aaaa.  My sweet children, I have kidnapped you!  And brought you to my secret Shoes study class!!

Shoes even caches images in memory and on disk, like browsers do. Images are loaded in background threads as well, to prevent apps from slowing down.

Now, a very important element: the para. As in: paragraph. Probably the third most important element (after stacks and flows.) {
  para strong("Q."), " Are you beginning to grasp hold of Shoes?"


Beyond para, you've got title and subtitle, which are bigger fonts. You can add a bunch of font styles as well. Look for strong and em in this bit. {
  stack(:margin => 6) {
    title "A Question"
    para strong("Q."), " Are you beginning to grasp hold of Shoes?"
    para em(strong("A."), " Quit pestering me, I'm hacking here.")



Keep track of stuff by naming them as variables. {
  @push = button "Push me"
  @note = para "Nothing pushed so far"


You can then put the variables into action. When the button is clicked, the @note changes to the message shown in the picture. {
  @push = button "Push me"
  @note = para "Nothing pushed so far" {
    @note.replace "Aha! Click!"


See if you can figure out this one. How does the gradient work? How are the letters styled? do
  background "#F3F".."#F90"
    :top => 60,
    :align => "center",
    :font => "Trebuchet MS",
    :stroke => white

In this example, I used do and end rather than the braces { and }. They have the same meaning.


Aha, here's a flow. It keeps the text box and the button side-by-side. do
  background "#EFC"
    :strokewidth => 6
  stack(:margin => 12) do
    para "Enter your name"
    flow do
      button "OK"


In this one, we make a five-point star. And it follows the mouse around as you move. do
  @shape = star(:points => 5)
  motion do |left, top|
    @shape.move left, top

On to a taste of animation. The Shoes icon moves randomly a bunch of times each second. do
  @shoes = image(
    :top => 100,
    :left => 100
  animate do |i| += (-20..20).rand
    @shoes.left += (-20..20).rand



Remember a few examples ago when we handled a button click? How about doing the same with a link? do
  @poem = stack do
    para "My eyes have blinked again
And I have just realized
This upright world 
I have been in.

My eyelids wipe
My eyes hundreds of times
Reseting and renovating
The scenery."
    link("Clear").click do

So, when the link gets clicked, the stack gets cleared. The poem will disappear.


Okay, last one for now. Let's generate a hundred random circles. This example also uses the rgb method to make colors from red, green and blue fractions. => 300, :height => 400) do
  fill rgb(0, 0.6, 0.9, 0.1)
  stroke rgb(0, 0.6, 0.9)
  strokewidth 0.25
  100.times do
      :left => (-5..self.width).rand,
      :top => (-5..self.height).rand,
      :radius => (25..50).rand

Don't worry if you haven't picked up a whole lot reading through these. To get the hang of it, you'll need to alter these yourself. Try fiddling with the numbers and colors. Experiment, you know?


Ready for more? See the manuals page for a pair of longer instructions. Particularly the guide book Nobody Knows Shoes, which teaches the ten essential commands to get going with Shoes.

Something went wrong with that request. Please try again.