Skip to content

Commit eb6b3e8

Browse files
author
monkstone
committed
more examples
1 parent 6ee64f1 commit eb6b3e8

File tree

6 files changed

+238
-1
lines changed

6 files changed

+238
-1
lines changed

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The `physics_type` sketch requires to be run with the `--nojruby` flag, which seems to be Catch-22, since conventionally it was thought you needed an installed jruby to use gems. However it works absolutely fine for me on my linux box, suggesting that jruby-complete-9.0.4.0 is respecting the `GEM_PATH` and or `GEM_HOME` environmental variables set in my `.bashrc` Archlinux or `.profile` Mint (Ubuntu/Debian).
1+
The sketches here seem to be require the `--nojruby` flag to run, which seems to be Catch-22, since conventionally it was thought you needed an installed jruby to use gems. However it works absolutely fine for me on my linux box, suggesting that jruby-complete-9.0.4.0 is respecting the `GEM_PATH` and or `GEM_HOME` environmental variables set in my `.bashrc` Archlinux or `.profile` Mint (Ubuntu/Debian).
22

33
```bash
44
export GEM_HOME="/home/tux/.gem/ruby/2.2.0"

examples/data/FreeSans.ttf

258 KB
Binary file not shown.

examples/data/bot1.svg

Lines changed: 160 additions & 0 deletions
Loading

examples/hello_svg_to_pdf.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load_library :pdf
2+
require 'geomerative'
3+
4+
attr_reader :grp, :pdf
5+
6+
def settings
7+
size(400, 400)
8+
smooth
9+
end
10+
11+
def setup
12+
sketch_title 'SVG to PDF sketch'
13+
RG.init(self)
14+
@grp = RG.load_shape('bot1.svg')
15+
@pdf = create_graphics(width, height, PDF, 'bot1.pdf')
16+
end
17+
18+
def draw
19+
background(255)
20+
grp.draw
21+
pdf.begin_draw
22+
pdf.background(255)
23+
grp.draw(pdf)
24+
pdf.dispose
25+
pdf.end_draw
26+
end

examples/hello_world.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'geomerative'
2+
3+
# Declare the objects we are going to use, so that they are accesible from setup() and from draw()
4+
attr_reader :grp
5+
6+
def settings
7+
size(600, 400)
8+
end
9+
10+
def setup
11+
sketch_title 'Hola Mundo'
12+
RG.init(self)
13+
background(255)
14+
fill(255, 102, 0)
15+
stroke(0)
16+
@grp = RG.getText('Hola Mundo!', 'FreeSans.ttf', 72, CENTER)
17+
end
18+
19+
def draw
20+
background(255)
21+
translate(width / 2, height / 2)
22+
grp.draw
23+
end

examples/rotate_first_letter.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'geomerative'
2+
3+
# Declare the objects we are going to use, so that they are accesible from setup() and from draw()
4+
attr_reader :grp
5+
6+
def settings
7+
size(600, 400)
8+
smooth
9+
end
10+
11+
def setup
12+
sketch_title 'Hola Mundo'
13+
frame_rate 24
14+
RG.init(self)
15+
background(255)
16+
fill(255, 102, 0)
17+
stroke(0)
18+
@grp = RG.getText('Hola Mundo!', 'FreeSans.ttf', 72, CENTER)
19+
end
20+
21+
def draw
22+
background(255)
23+
translate(width / 2, height / 2)
24+
grp.children[0].rotate(PI / 20, grp.children[0].get_center)
25+
grp.draw
26+
end
27+
28+

0 commit comments

Comments
 (0)