-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add all the Scarpe legacy Shoes examples, moved around a bit, still a…
…s .rb files
- Loading branch information
Showing
238 changed files
with
27,198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Legacy Shoes Applications | ||
|
||
These are Shoes examples, taken from a wide variety of sources. In general, we try not to modify them. | ||
|
||
Shoes-Spec originated with Scarpe, so no pre-Scarpe legacy applications have test code, only .rb Shoes apps. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Shoes.app(:width => 300, | ||
:height => 400) do | ||
|
||
fill rgb(0, 0.6, 0.9, 0.1) | ||
stroke rgb(0, 0.6, 0.9) | ||
strokewidth 0.25 | ||
|
||
@shoes = [] | ||
10.times { | ||
@shoes.push(oval :left => (-5..self.width).rand, | ||
:top => (-5..self.height).rand, | ||
:radius => (25..50).rand) | ||
} | ||
|
||
animate do |i| | ||
@shoes.each do |s| | ||
s.top += (-20..20).rand | ||
s.left += (-20..20).rand | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# This is from juixe "Running with Shoes - 2D Examples" | ||
# http://juixe.com/techknow/index.php/2007/10/19/running-with-shoes-2d-examples/ | ||
# | ||
# This is an animation of two concentric sets of circles moving in different | ||
# directions. As the circles move they change size and color. | ||
# | ||
|
||
degree = 0 | ||
color = 0 | ||
size = 0 | ||
|
||
Shoes.app :width => 537, :height => 500 do | ||
mx, my = (500/2).to_i, (537/2).to_i | ||
animate(24) do | ||
clear do | ||
# Manage color | ||
nostroke | ||
background rgb(1.0, 0.5, 1.0, 1.0) | ||
|
||
# Update some variables | ||
degree += 1 | ||
size += 1 | ||
degree = 0 if(degree >= 360) | ||
size = 0 if(size >= 100) | ||
color = 0.0 if(color >= 1.0) | ||
color += 0.05 if(degree % 10 == 0) | ||
|
||
# Draw inner circle | ||
fill red(color) | ||
10.times do |i| | ||
current_size = 100 + size | ||
d = to_radians(i * 60 + degree) | ||
rx = Math::cos(d) * 100 | ||
ry = Math::sin(d) * 100 | ||
center_x = -current_size/2 + rx + mx | ||
center_y = -current_size/2 + ry + my | ||
oval center_x, center_y, current_size, current_size | ||
end | ||
|
||
# Draw outer circle | ||
fill blue(color) | ||
20.times do |i| | ||
current_size = 50 + size | ||
d = to_radians(i * 30 - degree) | ||
rx = Math::cos(d) * 150 | ||
ry = Math::sin(d) * 150 | ||
center_x = -current_size/2 + rx + mx | ||
center_y = -current_size/2 + ry + my | ||
oval center_x, center_y, current_size, current_size | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Convert degrees to radians | ||
def to_radians(deg) | ||
deg * Math::PI / 180 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Example from Getting Started with Shoes on OS X blog post found here: | ||
# http://lethain.com/entry/2007/oct/15/getting-started-shoes-os-x/ | ||
# | ||
trails = [[0,0]] * 60 | ||
shape = 0 | ||
Shoes.app do | ||
keypress do |k| | ||
case k | ||
when " " | ||
shape += 1 | ||
end | ||
end | ||
nostroke | ||
fill rgb(0x30, 0xFF, 0xFF, 0.6) | ||
animate(24) do | ||
trails.shift | ||
trails << self.mouse[1,2] | ||
clear do | ||
trails.each_with_index do |(x, y), i| | ||
i += 1 | ||
case shape%2 | ||
when 0 | ||
rect :left => x, :top => y, :width => i, :height => i | ||
else | ||
oval :left => x, :top => y, :radius => i, :center => true | ||
end | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
cases/legacy_examples/contrib-animation/mice-satellites.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# From infoq: "Ruby Shoes for lightweight GUIs, graphics and animation" | ||
# http://www.infoq.com/news/2007/09/ruby-shoes | ||
# | ||
Shoes.app do | ||
radius = 20.0 | ||
vert = width - 30.0 | ||
hor = width - 30.0 | ||
o = oval(hor, vert, 10.0) | ||
animate(10) do |anim| | ||
nofill | ||
clear do | ||
oval(hor - radius, vert-radius, radius*2.0) | ||
satellites = vert /10 | ||
satellites.to_i.times {|x| | ||
h = hor + Math::sin(((6.28/satellites) * x )) * 40.0 | ||
v = vert - Math::cos(((6.28/satellites) * x ))* 40.0 | ||
fill rgb(1.0/satellites, 1.0/satellites, 0.8) | ||
oval(h, v, 5.0) | ||
} | ||
skew vert/10*Math::cos(anim) | ||
end | ||
end | ||
motion do |x,y| | ||
hor, vert = x, y | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Shoes.app do | ||
@o = oval :top => 0, :left => 0, :radius => 40 | ||
|
||
stack :margin => 40 do | ||
title "Dancing With a Circle" | ||
subtitle "How graceful and round." | ||
end | ||
|
||
motion do |x,y| | ||
@o.move width - x, height - y | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# This is from juixe "Running with Shoes - 2D Examples" | ||
# http://juixe.com/techknow/index.php/2007/10/19/running-with-shoes-2d-examples/ | ||
# | ||
# This sample application follows the mouse when it hovers around the | ||
# application window and draws growing bubbles. The bubbles have scan lines | ||
# thanks to the mask method. | ||
# | ||
# Array of x,y coordinates for bubbles | ||
bubbles = [[0, 0]] * 30 | ||
|
||
# Bubbles Shoes application | ||
Shoes.app :width => 537, :height => 500 do | ||
# 24 frames/second | ||
animate(24) do | ||
bubbles.shift | ||
bubbles << self.mouse[1, 2] | ||
clear do | ||
# Create pinkish linescan | ||
(500/5).times do |i| | ||
strokewidth 2 | ||
stroke rgb(1.0, 0.5, 1.0, 1.0) | ||
line 0, i * 5, 537, i * 5 | ||
end | ||
# Mask is expensive | ||
mask do | ||
# Create an oval bubble | ||
bubbles.each_with_index do |(x, y), i| | ||
oval x, y, 120 - (i * 5), 120 - (i * 5) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# From ashbb's shoes_hack_note #003 | ||
# http://github.com/ashbb/shoes_hack_note/blob/master/md/hack003.md | ||
# | ||
Shoes.app :width => 200, :height => 200, :title => 'Pulse!' do | ||
pulse = stack | ||
logo = image "shoes-icon-blue.png", :top => 30, :left => 30 | ||
|
||
animate 10 do |i| | ||
i %= 10 | ||
pulse.clear do | ||
fill black(0.2 - (i * 0.02)) | ||
strokewidth(3.0 - (i * 0.2)) | ||
stroke rgb(0.7, 0.7, 0.9, 1.0 - (i * 0.1)) | ||
oval(logo.left - i, logo.top - i, logo.width + (i * 2)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Example from juixe "Running with Shoes - Transform" | ||
# http://juixe.com/techknow/index.php/2007/10/23/running-with-shoes-transform/ | ||
# | ||
Shoes.app :width => 600, :height => 500 do | ||
# Move canvas to center of screen | ||
translate width/2, height/2 | ||
animate(24) do | ||
clear do | ||
# Rotate one degree at each frame | ||
rotate 1 | ||
# Scale the image up or down | ||
scale((0.8..1.2).rand) | ||
# draw triangle… | ||
star 10, 10, 7 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Shoes.app do | ||
stack do | ||
title "Downloading Google image", :size => 16 | ||
@status = para "One moment..." | ||
|
||
download "http://shoesrb.com/images/shoes-icon.png", | ||
:save => "shoes-icon.png" do | ||
@status.text = "Okay, is downloaded." | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Shoes.app do | ||
stack do | ||
title "Searching Google", :size => 16 | ||
@status = para "One moment..." | ||
|
||
download "http://www.google.com/search?q=shoes" do |goog| | ||
@status.text = "Headers: " + goog.response.body | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Shoes.app do | ||
stack do | ||
title "GET Google", :size => 16 | ||
@status = para "One moment..." | ||
|
||
download "http://www.google.com/search?q=shoes", | ||
:method => "GET" do |dump| | ||
@status.text = dump.response.body | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Shoes.app do | ||
@p = para | ||
animate do | ||
button, left, top = self.mouse | ||
@p.replace "mouse: #{button}, #{left}, #{top}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Shoes.app(:title => "White Circle", | ||
:width => 200, :height => 200, :resizable => false) { | ||
background black | ||
fill white | ||
oval :top => 20, :left => 20, :radius => 160 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# | ||
# Example from juixe "Running with Shoes - Show me more" | ||
# http://juixe.com/techknow/index.php/2007/10/24/running-with-shoes-show-me-more/ | ||
# | ||
def draw_circle(app, color, size) | ||
r = size/2 | ||
app.fill red(color) | ||
app.oval app.width/2 - r, app.height/2 - r, size, size | ||
draw_circle(app, color + 0.04, 3*size/4) if (color < 0.7) | ||
end | ||
Shoes.app :width => 600, :height => 600 do | ||
nofill | ||
draw_circle(self, 0.1, 600) | ||
mask do | ||
250.times do | ||
x = (20..580).rand | ||
y = (20..580).rand | ||
s = (20..60).rand | ||
oval x, y, s, s | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Example from juixe "Running with Shoes - Show me more" | ||
# http://juixe.com/techknow/index.php/2007/10/24/running-with-shoes-show-me-more/ | ||
# | ||
Shoes.app :width => 600, :height => 600 do | ||
nostroke | ||
|
||
def draw_circle(app, color, size) | ||
r = size/2 | ||
app.fill gray(color) | ||
app.oval app.width/2 - r, 0, size, size | ||
draw_circle(app, color - 0.04, 3*size/4) if (color > 0.4) | ||
end | ||
|
||
draw_circle(self, 0.9, 600) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Shoes.app do | ||
stroke red | ||
fill purple | ||
oval :top => 10, :left => 10, :radius => 100 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# From "Cut Holes in Shoes and Get a Mask" | ||
# http://github.com/shoes/shoes/wiki/Cut-Holes-In-Shoes-And-Get-A-Mask | ||
# | ||
Shoes.app do | ||
20.times do |i| | ||
strokewidth 4 | ||
stroke rgb((0.0..0.5).rand, (0.0..1.0).rand, (0.0..0.3).rand) | ||
line 0, i * 4, 400, i * 4 | ||
end | ||
|
||
mask do | ||
title "Shoes" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Shoes.app do | ||
stroke red | ||
strokewidth 10 | ||
fill gradient(red, purple) | ||
oval 10, 10, 150 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Shoes.app do | ||
fill gradient(red, purple) | ||
star 200, 200, 150, 50, 25 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Shoes.app :width => 280, :height => 350 do | ||
flow :width => 280, :margin => 10 do | ||
stack :width => "100%" do | ||
banner "A POEM" | ||
end | ||
|
||
stack :width => "80px" do | ||
para "Goes like:" | ||
end | ||
|
||
stack :width => "-90px" do | ||
para "the sun\n", | ||
"a lemon.\n", | ||
"the goalie.\n", | ||
"a fireplace.\n\n", | ||
"i want to write\n", | ||
"a poem for the\n", | ||
"kids who haven't\n", | ||
"even heard one yet.\n\n", | ||
"and the goalie guards\n", | ||
"the fireplace." | ||
end | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
cases/legacy_examples/contrib-basic/basic-blocks-instances.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Shoes.app do | ||
@s = stack do | ||
@p1 = para "First" | ||
@p2 = para "Second" | ||
@p3 = para "Third" | ||
end | ||
end |
Oops, something went wrong.