Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1450 from shoes/packing-samples
Changelog: improvement First cut at better packaging samples
- Loading branch information
Showing
11 changed files
with
233 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 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "activesupport" | ||
gem "shoes" |
12 changes: 12 additions & 0 deletions
12
samples/packaging/actively_supported/actively_supported.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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_support' | ||
require 'active_support/core_ext' | ||
|
||
Shoes.app do | ||
if "".blank? | ||
button "it was blank" do | ||
alert "meh, that's useless" | ||
end | ||
end | ||
end |
File renamed without changes.
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 @@ | ||
#! /usr/bin/env sh | ||
|
||
find . -name pkg -exec rm -rf {} \; | ||
|
||
shoes package --jar --linux --mac --windows basic/package_me.rb | ||
shoes package --jar --linux --mac --windows star_wars | ||
shoes package --jar --linux --mac --windows imagine/imagine.rb | ||
|
||
# https://github.com/shoes/shoes4/issues/1452 | ||
cd ./actively_supported | ||
shoes package --jar --linux --mac --windows actively_supported.rb |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
# frozen_string_literal: true | ||
Shoes.app width: 300, height: 550 do | ||
image "hubble.jpg", width: 300 | ||
rect 0, 350, 300, 200, fill: white, strokewidth: 50, stroke: "hubble.jpg" | ||
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,33 @@ | ||
# frozen_string_literal: true | ||
# | ||
# Original code paired on by Coraline and Jason Clark, 2014 | ||
# https://youtu.be/jAnSsNga5Nk | ||
# | ||
require 'characters/vader' | ||
require 'characters/yoda' | ||
require 'characters/leia' | ||
|
||
Shoes.app width: 800 do | ||
background white | ||
|
||
@vader = Vader.new(self) | ||
@yoda = Yoda.new(self) | ||
@leia = Leia.new(self) | ||
|
||
keypress do |key| | ||
case key | ||
when "d" | ||
@vader.saber_right | ||
when "D" | ||
@vader.saber_left | ||
when "y" | ||
@yoda.ears_down | ||
when "Y" | ||
@yoda.ears_up | ||
when "l" | ||
@leia.open_saber | ||
when "L" | ||
@leia.close_saber | ||
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,5 @@ | ||
name: Star Wars | ||
shortname: star_wars | ||
ignore: | ||
- 'pkg' | ||
run: app.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,57 @@ | ||
# frozen_string_literal: true | ||
class Leia < SimpleDelegator | ||
def initialize(app) | ||
super(app) | ||
|
||
oval 550, 100, 70, 80, fill: antiquewhite | ||
oval 530, 120, 30, 40, fill: saddlebrown | ||
oval 610, 120, 30, 40, fill: chocolate | ||
|
||
oval 570, 130, 6, 3, fill: blue, stroke: blue | ||
oval 590, 130, 6, 3, fill: blue, stroke: blue | ||
para "^", left: 575, top: 135 | ||
|
||
line 562, 170, 540, 400 | ||
line 602, 171, 658, 400 | ||
line 540, 400, 658, 400 | ||
|
||
@leia_saber1 = line 495, 235, 495, 235, displace_left: 0, strokewidth: 10, stroke: fuchsia, cap: :curve | ||
@leia_saber2 = line 495, 245, 495, 245, displace_left: 0, strokewidth: 5, stroke: darkmagenta, cap: :curve | ||
|
||
line 494, 232, 561, 184 | ||
line 494, 232, 555, 235 | ||
oval 484, 230, 20, 20, fill: peachpuff | ||
|
||
line 605, 182, 691, 218 | ||
line 620, 235, 690, 226 | ||
oval 688, 212, 20, 20, fill: bisque | ||
|
||
rect 560, 400, 20, 30 | ||
rect 620, 400, 20, 30 | ||
end | ||
|
||
def open_saber | ||
move_leia_saber(20) | ||
end | ||
|
||
def close_saber | ||
move_leia_saber(-20) | ||
end | ||
|
||
def move_leia_saber(value) | ||
return if @animate_leia | ||
|
||
@animate_leia = animate do | ||
if (@leia_saber1.height > 150 && value > 0) || (@leia_saber1.height < 1 && value < 0) | ||
@animate_leia.stop | ||
@animate_leia = nil | ||
else | ||
@leia_saber1.top -= value | ||
@leia_saber1.height += value | ||
|
||
@leia_saber2.top -= value | ||
@leia_saber2.height += value | ||
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,51 @@ | ||
# frozen_string_literal: true | ||
class Vader < SimpleDelegator | ||
def initialize(app) | ||
super(app) | ||
|
||
arc 50, 50, 100, 100, Shoes::PI, 0 | ||
oval 104, 80, 10, 6, fill: aliceblue | ||
oval 80, 80, 10, 6, fill: aliceblue | ||
line 80, 90, 80, 100, stroke: white | ||
line 90, 90, 90, 100, stroke: white | ||
line 100, 90, 100, 100, stroke: white | ||
line 110, 90, 110, 100, stroke: white | ||
rect 80, 100, 40, 20 | ||
rect 25, 120, 150, 250 | ||
line 45, 120, 35, 400, stroke: white | ||
line 145, 120, 160, 400, stroke: white | ||
|
||
rect 45, 370, 30, 40 | ||
rect 125, 370, 30, 40 | ||
@saber1 = line 60, 220, 60, 100, displace_left: 0, strokewidth: 10, stroke: darkred, cap: :curve | ||
@saber2 = line 60, 220, 60, 102, displace_left: 0, strokewidth: 5, stroke: red, cap: :curve | ||
@fist = oval 40, 220, 35, 30, fill: darkgray | ||
end | ||
|
||
def saber_right | ||
move_saber(10) | ||
end | ||
|
||
def saber_left | ||
move_saber(-10) | ||
end | ||
|
||
def move_saber(value) | ||
return if @animate_saber | ||
|
||
@animate_saber = animate do | ||
if (@saber1.left <= 30 && value < 0) || (@saber1.left > 180 && value > 0) | ||
@animate_saber.stop | ||
@animate_saber = nil | ||
else | ||
@saber1.left += value | ||
@saber1.right += value | ||
|
||
@saber2.left += value | ||
@saber2.right += value | ||
|
||
@fist.left += value | ||
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,53 @@ | ||
# frozen_string_literal: true | ||
class Yoda < SimpleDelegator | ||
def initialize(app) | ||
super(app) | ||
|
||
@ears = [] | ||
@ears << line(260, 150, 320, 235, strokewidth: 10, stroke: red) | ||
@ears << line(260, 150, 320, 220, strokewidth: 10, stroke: limegreen, cap: :curve) | ||
@ears << line(260, 150, 320, 250, strokewidth: 10, stroke: limegreen, cap: :curve) | ||
|
||
@ears << line(440, 150, 380, 235, strokewidth: 10, stroke: red) | ||
@ears << line(440, 150, 380, 220, strokewidth: 10, stroke: limegreen, cap: :curve) | ||
@ears << line(440, 150, 380, 250, strokewidth: 10, stroke: limegreen, cap: :curve) | ||
|
||
oval 300, 200, 100, 100, fill: limegreen, stroke: limegreen | ||
oval 320, 250, 10, 10 | ||
oval 380, 250, 10, 10 | ||
line 340, 220, 360, 220, stroke: aliceblue | ||
line 335, 230, 365, 230, stroke: aliceblue | ||
line 330, 240, 370, 240, stroke: aliceblue | ||
|
||
rect 300, 300, 100, 100, fill: brown, stroke: brown | ||
rect 340, 300, 20, 30, fill: black | ||
|
||
oval 290, 330, 20, 20, fill: limegreen, stroke: limegreen | ||
oval 400, 330, 20, 20, fill: limegreen, stroke: limegreen | ||
|
||
rect 310, 400, 20, 20, fill: limegreen, stroke: limegreen | ||
rect 370, 400, 20, 20, fill: limegreen, stroke: limegreen | ||
end | ||
|
||
def ears_down | ||
move_ears(10) | ||
end | ||
|
||
def ears_up | ||
move_ears(-10) | ||
end | ||
|
||
def move_ears(value) | ||
return if @animate_ears | ||
@animate_ears = animate do | ||
if (@ears.first.top > 220 && value > 0) || (@ears.first.top <= 150 && value < 0) | ||
@animate_ears.stop | ||
@animate_ears = nil | ||
else | ||
@ears.each do |ear| | ||
ear.top += value | ||
end | ||
end | ||
end | ||
end | ||
end |