geomerative 0.2.0-java → 0.3.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +8 -0
- data/.mvn/wrapper/maven-wrapper.properties +1 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +4 -0
- data/COPYING.md +17 -0
- data/Gemfile +8 -1
- data/README.md +5 -1
- data/examples/README.md +1 -7
- data/examples/Rakefile +30 -0
- data/examples/data/ruby.svg +16 -0
- data/examples/f_agent.rb +30 -0
- data/examples/font_agent.rb +24 -0
- data/examples/hello_polygonize.rb +1 -1
- data/examples/hello_svg_to_pdf.rb +2 -2
- data/examples/hello_world.rb +1 -1
- data/examples/jruby_merge.rb +94 -0
- data/examples/physics_type.rb +1 -1
- data/examples/rotate_first_letter.rb +3 -4
- data/examples/typo_deform.rb +68 -0
- data/examples/typo_extra_bright.rb +62 -0
- data/examples/typo_merge.rb +94 -0
- data/geomerative.gemspec +2 -3
- data/lib/geomerative/version.rb +1 -1
- data/pom.rb +47 -0
- data/pom.xml +35 -65
- data/src/geomerative/FastRClip.java +1 -1
- data/src/geomerative/RCommand.java +1877 -1741
- data/src/geomerative/RContour.java +8 -1
- data/src/geomerative/RFont.java +8 -5
- data/src/geomerative/RG.java +8 -3
- data/src/geomerative/RGeomElem.java +8 -9
- data/src/geomerative/RGroup.java +50 -28
- data/src/geomerative/RMatrix.java +53 -57
- data/src/geomerative/RMesh.java +8 -3
- data/src/geomerative/RPath.java +34 -29
- data/src/geomerative/RPoint.java +408 -408
- data/src/geomerative/RPolygon.java +7 -3
- data/src/geomerative/RSVG.java +13 -10
- data/src/geomerative/RShape.java +18 -11
- data/src/geomerative/RStrip.java +5 -1
- data/src/geomerative/RStyle.java +15 -11
- metadata +17 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6353da05bef67751824bdc155879f27eca421e53
|
4
|
+
data.tar.gz: 6d59be0cb425986803458f9c822d0c3812992ba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ff68a2494517080fa8d409399c5e5a84c28aad7ed3b9c826da8e76513a1250f5a653d1c5f68ab281fccb8079d8af58bf401fc7890ef2e91dd2212a1d51ce333
|
7
|
+
data.tar.gz: eb9a90c121ec20573ef2fbac2ecb2a690461903bcf629ddc16d436df9e464cec78ae3674491e23fd81261808574c6d3494ac704896a78ed94bd2ace37bbacb0d
|
data/.mvn/extensions.xml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
### version-0.3.1
|
2
|
+
Submit for travis build
|
3
|
+
### version-0.3
|
4
|
+
Further mods to java code, mainly in this case removing PConstants indirection, which is probably harmful (downside if people expect to use the RG prefix it won't work). Still need to run with --nojruby flag, generally a permissions thing.
|
data/COPYING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
### Copyright
|
2
|
+
The original processing library was developed by Ricard Marxer
|
3
|
+
|
4
|
+
https://github.com/rikrd/geomerative
|
5
|
+
|
6
|
+
Copyright 2006-2008 Ricard Marxer <email@ricardmarxer.com>
|
7
|
+
|
8
|
+
This product includes software developed by the Solution Engineering, Inc. (http://www.seisw.com/).
|
9
|
+
|
10
|
+
This product includes software developed by the The Apache Software Foundation (http://www.apache.org/).
|
11
|
+
|
12
|
+
Modifications and variations thereof to be compatible with (take advantage of new syntax etc) jdk8, processing-3.0 and thence JRubyArt
|
13
|
+
Copyright (c) 2015-2016 Martin Prout
|
14
|
+
|
15
|
+
I have not further polluted the headers of the original code so it may not clear that such code has been modified, but if you care you should check the [original][]
|
16
|
+
|
17
|
+
[original]://github.com/rikrd/geomerative
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# geomerative gem
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/geomerative.svg)](https://badge.fury.io/rb/geomerative)
|
4
|
+
![travis status](https://travis-ci.org/ruby-processing/geomerativegem.svg)
|
4
5
|
|
5
|
-
Gem wrapper for [Ricard Marxer Geomerative library][] for processing-3.0 and JRubyArt,
|
6
|
+
Gem wrapper for [Ricard Marxer Geomerative library][] for processing-3.0 and JRubyArt, before JRubyArt-1.1 sketches needed the `--nojruby` flag to run (which is supposed not to work with gems see [README.md][] with examples). But this is no longer the case.
|
7
|
+
|
8
|
+
Read more about using the gem on the linked [web pages].
|
6
9
|
|
7
10
|
[README.md]:https://github.com/ruby-processing/geomerativegem/blob/master/examples/README.md
|
11
|
+
[web pages]:http://ruby-processing.github.io/geomerativegem
|
8
12
|
[Ricard Marxer Geomerative library]:https://github.com/rikrd/geomerative
|
data/examples/README.md
CHANGED
@@ -1,7 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
```bash
|
4
|
-
export GEM_HOME="/home/tux/.gem/ruby/2.2.0"
|
5
|
-
export GEM_PATH="/home/tux/.gem/ruby/2.2.0"
|
6
|
-
export PATH="${PATH}:${GEM_PATH}/bin"
|
7
|
-
```
|
1
|
+
Since JRubyArt-1.1 sketches in this folder should not need the `--nojruby` flag to run, indeed to run them in sequence `cd` to this directory and `rake` to run sketches in a random sequence.
|
data/examples/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Simple demo Rakefile to autorun samples in current directory
|
2
|
+
# adjust path to rp5 executable, and or opts as required
|
3
|
+
|
4
|
+
SAMPLES_DIR = './'
|
5
|
+
|
6
|
+
desc 'run demo'
|
7
|
+
task default: [:demo]
|
8
|
+
|
9
|
+
desc 'demo'
|
10
|
+
task :demo do
|
11
|
+
samples_list.shuffle.each { |sample| run_sample sample }
|
12
|
+
end
|
13
|
+
|
14
|
+
def samples_list
|
15
|
+
files = []
|
16
|
+
Dir.chdir(SAMPLES_DIR)
|
17
|
+
Dir.glob('*.rb').each do |file|
|
18
|
+
files << File.join(SAMPLES_DIR, file) unless file.end_with? 'agent.rb'
|
19
|
+
end
|
20
|
+
files
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_sample(sample_name)
|
24
|
+
puts "Running #{sample_name}...quit to run next sample"
|
25
|
+
open("|k9 run #{sample_name}", 'r') do |io|
|
26
|
+
while l = io.gets
|
27
|
+
puts(l.chop)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="5%" y="5%"
|
5
|
+
width="20%" height="20%" viewBox="0 0 100 100" style="enable-background:new 0 0 64 64;" xml:space="preserve" fill="#ff0000">
|
6
|
+
<g style = "fill: #841b2d" >
|
7
|
+
<path d="M56.161,183.028l4.452-43.162l7.904,6.584L56,185.335L56.161,183.028z M70.823,152.055l19.61,39.046l-32.951,4.116
|
8
|
+
L70.823,152.055z M92.739,195.552v0.161V195.552l0.657-0.161v0.161l93.095,3.62l-126.703,0.496L92.739,195.552z M127.997,90.604
|
9
|
+
l-30.645,34.098l-27.186,17.137l-7.743-6.584l10.874-20.435l25.872-28.842l24.711-17.297l11.371,3.138L127.997,90.604z
|
10
|
+
M90.266,182.036l-18.122-36.082l25.375-16.144L90.266,182.036z M154.693,141.181l-61.129,48.271l8.24-59.306L154.693,141.181z
|
11
|
+
M158.152,144.479l38.06,51.569l-98.532-3.795L158.152,144.479z M130.638,94.546l22.734,43.015l-51.241-11.371L130.638,94.546z
|
12
|
+
M171.004,56.332l-34.111,11.035l-6.094-1.649L171.004,56.332z M132.945,90.604l7.576-19.281l42.183,6.758L132.945,90.604z
|
13
|
+
M134.922,94.546l53.875-14.494l-30.973,57.83L134.922,94.546z M194.234,76.257l-45.146-7.897l36.082-11.706L194.234,76.257z
|
14
|
+
M200,195.391l-39.213-53.218l33.943-63.609L200,195.391z"/>
|
15
|
+
</g>
|
16
|
+
</svg>
|
data/examples/f_agent.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_literal: true
|
3
|
+
# FontAgent class handles motion and display
|
4
|
+
class FontAgent
|
5
|
+
include Processing::Proxy # gives java 'inner class like' access to App
|
6
|
+
attr_reader :loc, :offset, :increment
|
7
|
+
|
8
|
+
def initialize(loc:, increment:)
|
9
|
+
@loc = loc.copy
|
10
|
+
@offset = Vec2D.new
|
11
|
+
@increment = increment
|
12
|
+
end
|
13
|
+
|
14
|
+
def motion
|
15
|
+
@offset += increment
|
16
|
+
loc.dist(Vec2D.new(noise(offset.x) * width, noise(offset.y) * height))
|
17
|
+
end
|
18
|
+
|
19
|
+
def display(xr:, yr:, m_point:)
|
20
|
+
no_stroke
|
21
|
+
fill(255, 73)
|
22
|
+
dia = (150 / m_point) * 5
|
23
|
+
# to get weird non-deterministic behaviour of original, created by use of
|
24
|
+
# negative inputs to a random range surely not intended, use original:-
|
25
|
+
# ellipse(loc.x + random(-xr, xr), loc.y + random(-yr, yr), dia, dia)
|
26
|
+
xr *= -1 if xr < 0 # guards against an invalid hi..low range
|
27
|
+
yr *= -1 if yr < 0
|
28
|
+
ellipse(loc.x + rand(-xr..xr), loc.y + rand(-yr..yr), dia, dia)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_literal: true
|
3
|
+
# FontAgent class handles motion and display
|
4
|
+
class FontAgent
|
5
|
+
include Processing::Proxy
|
6
|
+
attr_reader :loc, :mot
|
7
|
+
|
8
|
+
def initialize(location:)
|
9
|
+
@loc = location
|
10
|
+
@mot = 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def motion
|
14
|
+
noise_scale = map1d(mouse_x, (0..width), (0.001..0.01))
|
15
|
+
noise_z = map1d(mouse_x, (0..height), (frame_count * 0.0003..frame_count * 0.02))
|
16
|
+
@mot = noise(loc.x * noise_scale * noise_z, loc.y * noise_scale * noise_z) * 53
|
17
|
+
end
|
18
|
+
|
19
|
+
def display(step:)
|
20
|
+
no_stroke
|
21
|
+
fill(255, 53)
|
22
|
+
ellipse(loc.x, loc.y, mot + step, mot + step)
|
23
|
+
end
|
24
|
+
end
|
@@ -11,14 +11,14 @@ end
|
|
11
11
|
def setup
|
12
12
|
sketch_title 'SVG to PDF sketch'
|
13
13
|
RG.init(self)
|
14
|
-
@grp = RG.load_shape('bot1.svg')
|
14
|
+
@grp = RG.load_shape(data_path('bot1.svg'))
|
15
15
|
@pdf = create_graphics(width, height, PDF, 'bot1.pdf')
|
16
16
|
end
|
17
17
|
|
18
18
|
def draw
|
19
19
|
background(255)
|
20
20
|
grp.draw
|
21
|
-
pdf.begin_draw
|
21
|
+
pdf.begin_draw
|
22
22
|
pdf.background(255)
|
23
23
|
grp.draw(pdf)
|
24
24
|
pdf.dispose
|
data/examples/hello_world.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
#######################
|
2
|
+
# --------- GEOMERATIVE EXAMPLES ---------------
|
3
|
+
#######################
|
4
|
+
# Title : TypoGeo_Merge
|
5
|
+
# Date : 31/08/2011
|
6
|
+
# Version : v0.5
|
7
|
+
#
|
8
|
+
# Merges two words in an random fashion.
|
9
|
+
# Key 'f' = freezes motion
|
10
|
+
# key 's' saves the frame in png format
|
11
|
+
#
|
12
|
+
# Code adapted from an original idea by Bertrand _fevre
|
13
|
+
# during the Générative Typos workshop in Lure 2011.
|
14
|
+
#
|
15
|
+
# Licensed under GNU General Public License (GPL) version 3.
|
16
|
+
# http://www.gnu.org/licenses/gpl.html
|
17
|
+
#
|
18
|
+
# A series of tutorials for using the Geomerative Library
|
19
|
+
# developed by Ricard Marxer.
|
20
|
+
# http://www.ricardmarxer.com/geomerative/
|
21
|
+
#
|
22
|
+
# More info on these tutorials and workshops at :
|
23
|
+
# www.freeartbureau.org/blog
|
24
|
+
#
|
25
|
+
# Adapted for JRubyArt by Martin Prout
|
26
|
+
#######################
|
27
|
+
require 'geomerative'
|
28
|
+
|
29
|
+
attr_reader :my_font, :stop, :xoff, :yoff, :x_inc, :y_inc
|
30
|
+
|
31
|
+
TEXT = %w(RubyArt Processing).freeze
|
32
|
+
|
33
|
+
def settings
|
34
|
+
size(960, 640)
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup
|
38
|
+
sketch_title TEXT.join ' '
|
39
|
+
RG.init(self)
|
40
|
+
@my_font = RFont.new(data_path('FreeSans.ttf'), 200, CENTER)
|
41
|
+
@stop = false
|
42
|
+
no_fill
|
43
|
+
stroke(255)
|
44
|
+
stroke_weight(0.5)
|
45
|
+
rect_mode(CENTER)
|
46
|
+
@xoff = 0.0
|
47
|
+
@yoff = 0.0
|
48
|
+
@x_inc = 0.01
|
49
|
+
@y_inc = 0.015
|
50
|
+
end
|
51
|
+
|
52
|
+
def draw
|
53
|
+
background(0, 50)
|
54
|
+
displace_x = noise(xoff) * width
|
55
|
+
displace_y = noise(yoff) * height
|
56
|
+
@xoff += x_inc
|
57
|
+
@yoff += y_inc
|
58
|
+
translate(width / 2, height / 1.7)
|
59
|
+
frequency = map1d(displace_x, (300..500), (3..200))
|
60
|
+
RCommand.set_segment_length(frequency)
|
61
|
+
my_points = my_font.to_group(TEXT[0]).get_points
|
62
|
+
begin_shape
|
63
|
+
my_points.each do |point|
|
64
|
+
vertex(point.x, point.y)
|
65
|
+
rotation = map1d(displace_y, (0..height), (0..TWO_PI))
|
66
|
+
push_matrix
|
67
|
+
translate(point.x, point.y)
|
68
|
+
rotate(rotation)
|
69
|
+
size = frequency / 6
|
70
|
+
rect(0, 0, size, size)
|
71
|
+
pop_matrix
|
72
|
+
end
|
73
|
+
end_shape
|
74
|
+
frequency2 = map1d(displace_x, (300..500), (200..3))
|
75
|
+
RCommand.set_segment_length(frequency2)
|
76
|
+
my_points = my_font.to_group(TEXT[1]).get_points
|
77
|
+
begin_shape
|
78
|
+
my_points.each do |point|
|
79
|
+
vertex(point.x, point.y)
|
80
|
+
size = frequency2 / 7
|
81
|
+
ellipse(point.x, point.y, size, size)
|
82
|
+
end
|
83
|
+
end_shape
|
84
|
+
end
|
85
|
+
|
86
|
+
def key_pressed
|
87
|
+
case key
|
88
|
+
when 'f', 'F'
|
89
|
+
@stop = !stop
|
90
|
+
stop ? no_loop : loop
|
91
|
+
when 's', 'S'
|
92
|
+
save_frame(data_path('000_###.png'))
|
93
|
+
end
|
94
|
+
end
|
data/examples/physics_type.rb
CHANGED
@@ -12,7 +12,7 @@ def setup
|
|
12
12
|
sketch_title 'Physics Type'
|
13
13
|
@input = 'Hello!'
|
14
14
|
RG.init(self)
|
15
|
-
fnt = RG.load_font('ReplicaBold.ttf') # file name
|
15
|
+
fnt = RG.load_font(data_path('ReplicaBold.ttf')) # file name
|
16
16
|
RG.text_font(fnt, 330) # RFont object, size
|
17
17
|
@font = RG.get_text(input) # String to RShape
|
18
18
|
RG.set_polygonizer(RCommand::UNIFORMLENGTH)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'geomerative'
|
2
2
|
|
3
|
-
# Declare the objects we are going to use, so that they are accesible from setup
|
3
|
+
# Declare the objects we are going to use, so that they are accesible from setup
|
4
|
+
# and from draw
|
4
5
|
attr_reader :grp
|
5
6
|
|
6
7
|
def settings
|
@@ -15,7 +16,7 @@ def setup
|
|
15
16
|
background(255)
|
16
17
|
fill(255, 102, 0)
|
17
18
|
stroke(0)
|
18
|
-
@grp = RG.getText('Hola Mundo!', 'FreeSans.ttf', 72, CENTER)
|
19
|
+
@grp = RG.getText('Hola Mundo!', data_path('FreeSans.ttf'), 72, CENTER)
|
19
20
|
end
|
20
21
|
|
21
22
|
def draw
|
@@ -24,5 +25,3 @@ def draw
|
|
24
25
|
grp.children[0].rotate(PI / 20, grp.children[0].get_center)
|
25
26
|
grp.draw
|
26
27
|
end
|
27
|
-
|
28
|
-
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# --------- GEOMERATIVE EXAMPLES ---------------
|
2
|
+
# //////////////////////////////////////////////
|
3
|
+
# Title : TypoGeo_Deform
|
4
|
+
# Date : 31/08/2011
|
5
|
+
# Version : v0.5
|
6
|
+
#
|
7
|
+
# This sketch deforms the text using noise as the underlying
|
8
|
+
# algorithm. mouseX & mouseY movement will change the amount
|
9
|
+
# & intensity of the noise values.
|
10
|
+
# Key 'f' = Switches animation on/off
|
11
|
+
# Key '+' & '-' = Changes the diameter of our ellipse.
|
12
|
+
#
|
13
|
+
# Licensed under GNU General Public License (GPL) version 3.
|
14
|
+
# http://www.gnu.org/licenses/gpl.html
|
15
|
+
#
|
16
|
+
# A series of tutorials for using the Geomerative Library
|
17
|
+
# developed by Ricard Marxer.
|
18
|
+
# http://www.ricardmarxer.com/geomerative/
|
19
|
+
#
|
20
|
+
# More info on these tutorials and workshops at :
|
21
|
+
# www.freeartbureau.org/blog
|
22
|
+
#
|
23
|
+
require 'geomerative'
|
24
|
+
require_relative 'font_agent'
|
25
|
+
|
26
|
+
attr_reader :my_font, :my_group, :my_points, :my_text
|
27
|
+
attr_reader :my_agents, :step, :stop_anime
|
28
|
+
|
29
|
+
def settings
|
30
|
+
size(800, 350)
|
31
|
+
smooth
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup
|
35
|
+
sketch_title 'Bubbles'
|
36
|
+
background(0)
|
37
|
+
@step = 3
|
38
|
+
@my_text = 'BUBBLES'
|
39
|
+
RG.init(self)
|
40
|
+
@my_font = RFont.new(data_path('FreeSans.ttf'), 113, CENTER)
|
41
|
+
@stop_anime = false
|
42
|
+
RCommand.setSegmentLength(10)
|
43
|
+
RCommand.setSegmentator(RCommand::UNIFORMLENGTH)
|
44
|
+
@my_points = my_font.toGroup(my_text).getPoints
|
45
|
+
@my_agents = my_points.map { |point| FontAgent.new(location: Vec2D.new(point.x, point.y)) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def draw
|
49
|
+
translate(400, 205)
|
50
|
+
background(0)
|
51
|
+
fill(255)
|
52
|
+
my_agents.each do |point|
|
53
|
+
point.display(step: step)
|
54
|
+
point.motion
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def key_pressed
|
59
|
+
case key
|
60
|
+
when 'f', 'F'
|
61
|
+
@stop_anime = !stop_anime
|
62
|
+
stop_anime ? no_loop : loop
|
63
|
+
when '+'
|
64
|
+
@step += 1
|
65
|
+
when '-'
|
66
|
+
@step -= 1
|
67
|
+
end
|
68
|
+
end
|