Skip to content

Commit 737a292

Browse files
author
spiralofhope
committed
Ruby syntax highlighting.
1 parent 5f3f4cb commit 737a292

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ The braces { and } are a kind of container. The button is "in" the app.
2929

3030
We can place a few buttons in a stack.
3131

32+
```ruby
3233
Shoes.app {
3334
stack {
3435
button "A bed of clams"
3536
button "A coalition of cheetahs"
3637
button "A gulp of swallows"
3738
}
3839
}
40+
```
3941

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

@@ -46,6 +48,7 @@ Stacks are essential! The most important two elements in Shoes are *stacks and f
4648

4749
Okay, let's give the stack a bit of a margin. Scoot it out from the edge.
4850

51+
```ruby
4952
Shoes.app {
5053
background white
5154
stack(:margin => 8) {
@@ -54,6 +57,7 @@ Okay, let's give the stack a bit of a margin. Scoot it out from the edge.
5457
button "A gulp of swallows"
5558
}
5659
}
60+
```
5761

5862
Also painted the background white. Did you see that?
5963

@@ -63,10 +67,12 @@ Also painted the background white. Did you see that?
6367

6468
Time for something new. Artwork. Drawing.
6569

70+
```ruby
6671
Shoes.app {
6772
oval :left => 10, :top => 10,
6873
:radius => 40
6974
}
75+
```
7076

7177
The Shoes brush always starts out black.
7278

@@ -78,24 +84,27 @@ Notice that while buttons just dropped into the window, we drew the circle at a
7884

7985
Now, a rectangle and an arrow.
8086

87+
```ruby
8188
Shoes.app {
8289
fill red
8390
rect :left => 10, :top => 10,
8491
:width => 40
8592
arrow :left => 30, :top => 60,
8693
:width => 40
8794
}
88-
95+
```
8996

9097
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.
9198

9299
----------------------
93100

94101
Of course, you can always design your app with images. Even images from the web!
95102

103+
```ruby
96104
Shoes.app {
97105
image "http://shoooes.net/images/nks-kidnap.png"
98106
}
107+
```
99108

100109
![006.jpg](https://github.com/ashbb/shoes_tutorial_walkthrough/raw/master/imgs/006.jpg)
101110

@@ -105,24 +114,27 @@ Shoes even caches images in memory and on disk, like browsers do. Images are loa
105114

106115
Now, a very important element: the para. As in: paragraph. Probably the third most important element (after stacks and flows.)
107116

117+
```ruby
108118
Shoes.app {
109119
para strong("Q."), " Are you beginning to grasp hold of Shoes?"
110120
}
121+
```
111122

112123
![007.jpg](https://github.com/ashbb/shoes_tutorial_walkthrough/raw/master/imgs/007.jpg)
113124

114125
----------------------
115126

116127
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.
117128

118-
129+
```ruby
119130
Shoes.app {
120131
stack(:margin => 6) {
121132
title "A Question"
122133
para strong("Q."), " Are you beginning to grasp hold of Shoes?"
123134
para em(strong("A."), " Quit pestering me, I'm hacking here.")
124135
}
125136
}
137+
```
126138

127139
![008.jpg](https://github.com/ashbb/shoes_tutorial_walkthrough/raw/master/imgs/008.jpg)
128140

@@ -132,17 +144,20 @@ Beyond para, you've got title and subtitle, which are bigger fonts. You can add
132144

133145
Keep track of stuff by naming them as variables.
134146

147+
```ruby
135148
Shoes.app {
136149
@push = button "Push me"
137150
@note = para "Nothing pushed so far"
138151
}
152+
```
139153

140154
----------------------
141155

142156
![010.jpg](https://github.com/ashbb/shoes_tutorial_walkthrough/raw/master/imgs/010.jpg)
143157

144158
You can then put the variables into action. When the button is clicked, the @node changes to the message shown in the picture.
145159

160+
```ruby
146161
Shoes.app {
147162
@push = button "Push me"
148163
@note = para "Nothing pushed so far"
@@ -151,20 +166,23 @@ You can then put the variables into action. When the button is clicked, the @nod
151166
@note.replace "Aha! Click!"
152167
}
153168
}
169+
```
154170

155171
----------------------
156172

157173
![011.jpg](https://github.com/ashbb/shoes_tutorial_walkthrough/raw/master/imgs/011.jpg)
158174

159175
See if you can figure out this one. How does the gradient work? How are the letters styled?
160176

177+
```ruby
161178
Shoes.app do
162179
background "#F3F".."#F90"
163180
title "Shoooes", :top => 60,
164181
:align => "center",
165182
:font => "Trebuchet MS",
166183
:stroke => white
167184
end
185+
```
168186

169187
In this example, I used do and end rather than the braces. Same meaning.
170188

@@ -174,6 +192,7 @@ In this example, I used do and end rather than the braces. Same meaning.
174192

175193
Aha, here's a flow. It keeps the text box and the button side-by-side.
176194

195+
```ruby
177196
Shoes.app do
178197
background "#EFC"
179198
border "#BE8", :strokewidth => 6
@@ -185,24 +204,28 @@ Aha, here's a flow. It keeps the text box and the button side-by-side.
185204
end
186205
end
187206
end
207+
```
188208

189209
----------------------
190210

191211
![013.jpg](https://github.com/ashbb/shoes_tutorial_walkthrough/raw/master/imgs/013.jpg)
192212

193213
In this one, we make a five-point star. And it follows the mouse around as you move.
194214

215+
```ruby
195216
Shoes.app do
196217
@shape = star :points => 5
197218
motion do |left, top|
198219
@shape.move left, top
199220
end
200221
end
222+
```
201223

202224
----------------------
203225

204226
On to a taste of animation. The Shoes icon moves randomly a bunch of times each second.
205227

228+
```ruby
206229
Shoes.app do
207230
@shoes = image "http://shoooes.net/shoes.png",
208231
:top => 100, :left => 100
@@ -211,7 +234,7 @@ On to a taste of animation. The Shoes icon moves randomly a bunch of times each
211234
@shoes.left += (-20..20).rand
212235
end
213236
end
214-
237+
```
215238

216239
![014.jpg](https://github.com/ashbb/shoes_tutorial_walkthrough/raw/master/imgs/014.jpg)
217240

@@ -221,6 +244,7 @@ On to a taste of animation. The Shoes icon moves randomly a bunch of times each
221244

222245
Remember a few examples ago when we handled a button click? How about doing the same with a link?
223246

247+
```ruby
224248
Shoes.app {
225249
@poem = stack {
226250
para "
@@ -238,6 +262,7 @@ Remember a few examples ago when we handled a button click? How about doing the
238262
para(link("Clear").
239263
click { @poem.clear })
240264
}
265+
```
241266

242267
So, when the link gets clicked, the stack gets emptied. The poem will disappear.
243268

@@ -247,6 +272,7 @@ So, when the link gets clicked, the stack gets emptied. The poem will disappear.
247272

248273
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.
249274

275+
```ruby
250276
Shoes.app(:width => 300,
251277
:height => 400) {
252278
fill rgb(0, 0.6, 0.9, 0.1)
@@ -258,6 +284,7 @@ Okay, last one for now. Let's generate a hundred random circles. This example al
258284
:radius => (25..50).rand
259285
}
260286
}
287+
```
261288

262289
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?
263290

0 commit comments

Comments
 (0)