geomerative 0.4.0-java → 0.4.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -5
  3. data/CHANGELOG.md +7 -0
  4. data/README.md +3 -1
  5. data/calculate_torsional_angle.rb +17 -0
  6. data/docs/.gitignore +6 -0
  7. data/docs/_config.yml +22 -0
  8. data/docs/_includes/footer.html +38 -0
  9. data/docs/_includes/head.html +15 -0
  10. data/docs/_includes/header.html +27 -0
  11. data/docs/_includes/icon-github.html +1 -0
  12. data/docs/_includes/icon-github.svg +1 -0
  13. data/docs/_includes/icon-twitter.html +1 -0
  14. data/docs/_includes/icon-twitter.svg +1 -0
  15. data/docs/_layouts/default.html +20 -0
  16. data/docs/_layouts/page.html +14 -0
  17. data/docs/_layouts/post.html +15 -0
  18. data/docs/_posts/2015-11-21-getting_started.md +66 -0
  19. data/docs/_posts/2015-11-25-bubbles.md +111 -0
  20. data/docs/_posts/2015-11-26-extra_bright.md +103 -0
  21. data/docs/_posts/2015-11-26-text_merge.md +114 -0
  22. data/docs/_posts/2016-07-06-dymo.md +99 -0
  23. data/docs/_sass/_base.scss +206 -0
  24. data/docs/_sass/_layout.scss +242 -0
  25. data/docs/_sass/_syntax-highlighting.scss +71 -0
  26. data/docs/about.md +12 -0
  27. data/docs/assets/bright.png +0 -0
  28. data/docs/assets/bubbles.png +0 -0
  29. data/docs/assets/design.png +0 -0
  30. data/docs/assets/dymo.png +0 -0
  31. data/docs/assets/favicon.ico +0 -0
  32. data/docs/assets/fred.png +0 -0
  33. data/docs/assets/merge.png +0 -0
  34. data/docs/css/main.scss +38 -0
  35. data/docs/favicon.ico +0 -0
  36. data/docs/feed.xml +30 -0
  37. data/docs/index.html +38 -0
  38. data/examples/hello_svg_to_pdf.rb +1 -1
  39. data/geomerative.gemspec +2 -2
  40. data/lib/geomerative/version.rb +1 -1
  41. data/pom.rb +2 -2
  42. data/pom.xml +2 -2
  43. data/src/geomerative/RCommand.java +13 -13
  44. metadata +39 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1f9b00d8e8b548204c87563bdf4dae9ade679a8
4
- data.tar.gz: 74682d13bb0ce44a59ffd443e8b923dd55800a46
3
+ metadata.gz: d84ccf2bb081b93d067d6ef378616c123543ead2
4
+ data.tar.gz: 92e980a195d2abb7fccadd9a0533187b64d238fd
5
5
  SHA512:
6
- metadata.gz: 723c6a011d0da617a27dfdcab2db17e4d3c3eff38331be24cc897ab6284ba9b5892e6af5f9c38a9fc289212d492b41a04f4ffe12cab4c5c76381bb3fd84f6d34
7
- data.tar.gz: 7c5ef85d8334bd719b2532af5427e86101812cf8292f15e97a5553bbf650983bb39d546d38ed72773df817a20bc1e2a259547701b283f12853afda90083f6428
6
+ metadata.gz: 318305f70fc4dda910f2c420dfb13595540e4f0c989c8f6646520b68632420734d0112fe7c3c25fead2e900fcfc6b9d61ea5ed5aaeeece312c8c9416deafe5b4
7
+ data.tar.gz: 00cf5f80662adfbe7dc5156aff6283d6de2ce6af4da15e3cf1fd6c142b5471cb65e44ef0c3fd829515780d1373ca8954c19441d7510a2019230fc4685148ae35
@@ -1,12 +1,8 @@
1
1
  language: ruby
2
2
  sudo: false
3
- addons:
4
- apt:
5
- packages:
6
- -oracle-java8-installer
7
3
 
8
4
  rvm:
9
- - jruby-9.0.5.0
5
+ - jruby-9.1.6.0
10
6
  jdk:
11
7
  - oraclejdk8
12
8
  os:
@@ -1,7 +1,14 @@
1
+ ### version-0.4.2
2
+ Bump versions processing-3.3, jruby-9.1.8.0
3
+
4
+ ### version-0.4.1
5
+ No particular reason but java, jruby and processing have all been updated since last release
6
+
1
7
  ### version-0.4.0
2
8
  Somewhat arbitarily require JRubyArt-1.2+, but idea is get everyone on same page
3
9
 
4
10
  ### version-0.3.1
5
11
  Submit for travis build
12
+
6
13
  ### version-0.3
7
14
  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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/geomerative.svg)](https://badge.fury.io/rb/geomerative)
4
4
  ![travis status](https://travis-ci.org/ruby-processing/geomerativegem.svg)
5
5
 
6
- Gem wrapper for [Ricard Marxer Geomerative library][] for processing-3.1.1+ and JRubyArt-1.2.0+
6
+ Gem wrapper for [Ricard Marxer Geomerative library][] for [JRubyArt][jruby_art] and [propane][propane]
7
7
  Create amazing stuff with fonts svg etc.
8
8
 
9
9
  Read more about using the gem on the linked [web pages].
@@ -11,3 +11,5 @@ Read more about using the gem on the linked [web pages].
11
11
  [README.md]:https://github.com/ruby-processing/geomerativegem/blob/master/examples/README.md
12
12
  [web pages]:http://ruby-processing.github.io/geomerativegem
13
13
  [Ricard Marxer Geomerative library]:https://github.com/rikrd/geomerative
14
+ [jruby_art]:https://ruby-processing.github.io/JRubyArt/
15
+ [propane]:https://ruby-processing.github.io/propane/
@@ -0,0 +1,17 @@
1
+ def calculate_torsional_angle(at0, at1, at2, at3)
2
+ r01 = at0 - at1
3
+ r32 = at3 - at2
4
+ r12 = at1 - at2
5
+ p = r12.cross(r01)
6
+ q = r12.cross(r32)
7
+ r = r12.cross(q)
8
+ u = q.dot(q)
9
+ v = r.dot(r)
10
+ return 360.0 if (u <= 0.0 || v <= 0.0)
11
+ u1 = p.dot(q) # u1 = p * q
12
+ v1 = p.dot(r) # v1 = p * r
13
+ u = u1 / sqrt(u)
14
+ v = v1 / sqrt(v)
15
+ return Math.atan2(v, u).degrees if (u.abs > 0.01 || v.abs > 0.01)
16
+ 360.0
17
+ end
@@ -0,0 +1,6 @@
1
+
2
+ *~
3
+ _site
4
+ .sass-cache
5
+ .jekyll-metadata
6
+ Gemfile.lock
@@ -0,0 +1,22 @@
1
+ # Site settings
2
+ port: 4000
3
+ title: Geomerative gem for JRubyArt and propane
4
+ email: mamba2928@yahoo.co.uk
5
+ description: > # this means to ignore newlines until "baseurl:"
6
+ The geomerative gem is wrapper around the geomerative library by Ricard
7
+ Marxer, that makes it very easy to use with JRubyArt. Do fancy things with
8
+ text, like rotating words, huge font, dissolving font etc.
9
+ baseurl: "" # the subpath of your site, e.g. /blog
10
+ regenerate: true
11
+ url: "https://ruby-processing.github.io/geomerativegem"
12
+
13
+ urls:
14
+ bugs: https://github.com/ruby-processing/geomerativegem/issues
15
+ github: https://github.com/ruby-processing/geomerativegem/
16
+ twitter_username: monkstoneT
17
+ github_username: monkstone
18
+
19
+ syntax-highlighting:
20
+ enabled: true
21
+ # Build settings
22
+ markdown: kramdown
@@ -0,0 +1,38 @@
1
+ <footer class="site-footer">
2
+
3
+ <div class="wrapper">
4
+
5
+ <h2 class="footer-heading">{{ site.title }}</h2>
6
+
7
+ <div class="footer-col-wrapper">
8
+ <div class="footer-col footer-col-1">
9
+ <ul class="contact-list">
10
+ <li>{{ site.title }}</li>
11
+ <li><a href="mailto:{{ site.email }}">{{ site.email }}</a></li>
12
+ </ul>
13
+ </div>
14
+
15
+ <div class="footer-col footer-col-2">
16
+ <ul class="social-media-list">
17
+ {% if site.github_username %}
18
+ <li>
19
+ {% include icon-github.html username=site.github_username %}
20
+ </li>
21
+ {% endif %}
22
+
23
+ {% if site.twitter_username %}
24
+ <li>
25
+ {% include icon-twitter.html username=site.twitter_username %}
26
+ </li>
27
+ {% endif %}
28
+ </ul>
29
+ </div>
30
+
31
+ <div class="footer-col footer-col-3">
32
+ <p>{{ site.description }}</p>
33
+ </div>
34
+ </div>
35
+
36
+ </div>
37
+
38
+ </footer>
@@ -0,0 +1,15 @@
1
+ <head>
2
+ <meta charset="utf-8">
3
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ {% if page.keywords %}
6
+ <meta name="keywords" content="{{ page.keywords }}" />
7
+ {% else %}
8
+ <meta name="keywords" content="art, JRubyArt, code, blog, ruby" />
9
+ {% endif %}<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
10
+ <meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
11
+
12
+ <link rel="stylesheet" href="https://ruby-processing.github.io/JRubyArt/css/main.css"/>
13
+ <link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.github.url | prepend: site.url }}">
14
+ <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.github.url | prepend: site.url }}" />
15
+ </head>
@@ -0,0 +1,27 @@
1
+ <header class="site-header">
2
+
3
+ <div class="wrapper">
4
+
5
+ <a class="site-title" href="{{ site.baseurl }}/">{{ site.title }}</a>
6
+
7
+ <nav class="site-nav">
8
+ <a href="#" class="menu-icon">
9
+ <svg viewBox="0 0 18 15">
10
+ <path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/>
11
+ <path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/>
12
+ <path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
13
+ </svg>
14
+ </a>
15
+
16
+ <div class="trigger">
17
+ {% for my_page in site.pages %}
18
+ {% if my_page.title %}
19
+ <a class="page-link" href="{{ my_page.url | prepend: site.github.url }}">{{ my_page.title }}</a>
20
+ {% endif %}
21
+ {% endfor %}
22
+ </div>
23
+ </nav>
24
+
25
+ </div>
26
+
27
+ </header>
@@ -0,0 +1 @@
1
+ <a href="https://github.com/{{ include.username }}"><span class="icon icon--github">{% include icon-github.svg %}</span><span class="username">{{ include.username }}</span></a>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 16 16"><path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/></svg>
@@ -0,0 +1 @@
1
+ <a href="https://twitter.com/{{ include.username }}"><span class="icon icon--twitter">{% include icon-twitter.svg %}</span><span class="username">{{ include.username }}</span></a>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 16 16"><path fill="#828282" d="M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27 c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767 c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206 C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271 c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469 c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"/></svg>
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ {% include head.html %}
5
+
6
+ <body>
7
+
8
+ {% include header.html %}
9
+
10
+ <div class="page-content">
11
+ <div class="wrapper">
12
+ {{ content }}
13
+ </div>
14
+ </div>
15
+
16
+ {% include footer.html %}
17
+
18
+ </body>
19
+
20
+ </html>
@@ -0,0 +1,14 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+ <article class="post">
5
+
6
+ <header class="post-header">
7
+ <h1 class="post-title">{{ page.title }}</h1>
8
+ </header>
9
+
10
+ <div class="post-content">
11
+ {{ content }}
12
+ </div>
13
+
14
+ </article>
@@ -0,0 +1,15 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+ <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
5
+
6
+ <header class="post-header">
7
+ <h1 class="post-title" itemprop="name headline">{{ page.title }}</h1>
8
+ <p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}</p>
9
+ </header>
10
+
11
+ <div class="post-content" itemprop="articleBody">
12
+ {{ content }}
13
+ </div>
14
+
15
+ </article>
@@ -0,0 +1,66 @@
1
+ ---
2
+ layout: post
3
+ title: "A first Sketch"
4
+ date: 2015-11-24 07:34:13
5
+ categories: geomerativegem update
6
+ ---
7
+
8
+ ### Requirements
9
+
10
+ Requires JRubyArt-1.0.1+ (hence jruby-9.0.3.0+)
11
+
12
+ ### Install the generative gem
13
+
14
+ ```bash
15
+ jruby -S gem install geomerative # safe way
16
+ gem install geomerative # using rvm rbenv to use jruby instead of MRI
17
+ ```
18
+
19
+ Create basic sketch
20
+
21
+ ```bash
22
+ mkdir 'fred'
23
+ mkdir 'fred/data'
24
+ cp '/usr/share/fonts/TTF/FreeMono.ttf fred/data' # other fonts are available
25
+ # '/usr/share/fonts/TTF/LiberationMono-Bold.ttf' Mac and Windows paths differ
26
+ cd fred
27
+ k9 create fred 600 400
28
+ ```
29
+
30
+ Edit sketch as follows:-
31
+
32
+ ```ruby
33
+ require 'geomerative'
34
+
35
+ # Declare the objects we are going to use, so that they are accessible from
36
+ # setup and from draw (use '@' prefix in declare)
37
+ attr_reader :grp
38
+
39
+ def setup
40
+ sketch_title 'Fred'
41
+ RG.init(self) # important
42
+ fill(255, 102, 0)
43
+ # you could also use absolute path for fonts, then no need to copy
44
+ @grp = RG.get_text('Hello World!', data_path('FreeMono.ttf'), 72, CENTER)
45
+ end
46
+
47
+ def draw
48
+ background(255)
49
+ translate(width / 2, height / 2)
50
+ grp.draw
51
+ end
52
+
53
+ def settings
54
+ size(600, 400)
55
+ end
56
+ ```
57
+
58
+ ![fred.png]({{site.github.url}}/assets/fred.png)
59
+
60
+ See more refined examples [here][examples], and even more [here][amon] including rotating text and text obeying physics.
61
+
62
+ Usage with propane is very similar see [examples here][here]
63
+
64
+ [examples]:https://github.com/ruby-processing/geomerativegem/tree/master/examples/
65
+ [amon]:http://www.creativeapplications.net/processing/generative-typography-processing-tutorial/
66
+ [here]:https://github.com/ruby-processing/propane-examples/tree/master/external_library/gem/geomerative/
@@ -0,0 +1,111 @@
1
+ ---
2
+ layout: post
3
+ title: "A tutorial example"
4
+ date: 2015-11-25 19:59:13
5
+ categories: geomerativegem update
6
+ ---
7
+
8
+ ### Bubble Sketch
9
+
10
+ To use the `RCommand` constant `UNIFORMLENGTH` in JRubyArt (and java constants in general with jruby) you would normally need to address it in the following way:- `Java::Generative::RCommand::UNIFORMLENGTH`. However in the geomerative gem we have done `package_include 'geomerative'` for you so you can get away with the short form `RCommand::UNIFORMLENGTH`, but you do need the `RCommand::` prefix. For processing constants the full form for the `CENTER` constant would be `Java::ProcessingCore::PConstants::CENTER` but because we hate typing we have made the processing constant `CENTER` available without the `PConstants::` prefix. If you have namespace difficulties you can always fall back on the full forms.
11
+
12
+ To make processing methods available in the `FontAgent` class (`font_agent.rb`) we `include` the `Processing::Proxy` module that gives similar access to that of a java inner class as used in vanilla processing.
13
+
14
+ ```ruby
15
+ # --------- GEOMERATIVE EXAMPLES ---------------
16
+ #
17
+ # This sketch deforms the text using noise as the underlying
18
+ # algorithm. mouse_x & mouse_y movement will change the amount
19
+ # & intensity of the noise values.
20
+ # Key 'f' = Switches animation on/off
21
+ # Key '+' & '-' = Changes the diameter of our ellipse.
22
+ #
23
+ # Licensed under GNU General Public License (GPL) version 3.
24
+ # http://www.gnu.org/licenses/gpl.html
25
+ #
26
+ # A series of tutorials for using the Geomerative Library
27
+ # developed by Ricard Marxer.
28
+ # http://www.ricardmarxer.com/geomerative/
29
+ #
30
+ # More info on these tutorials and workshops at :
31
+ # www.freeartbureau.org/blog
32
+ # translated to JRubyArt by Martin Prout
33
+ #
34
+ require 'geomerative'
35
+ require_relative 'font_agent'
36
+
37
+ attr_reader :my_agents, :step, :stop_anime
38
+
39
+ def settings
40
+ size(800, 350)
41
+ smooth
42
+ end
43
+
44
+ def setup
45
+ sketch_title 'Bubbles'
46
+ background(0)
47
+ @step = 3
48
+ my_text = 'BUBBLES'
49
+ RG.init(self)
50
+ my_font = RFont.new(data_path('FreeSans.ttf'), 113, CENTER)
51
+ @stop_anime = false
52
+ RCommand.set_segment_length(10)
53
+ RCommand.set_segmentator(RCommand::UNIFORMLENGTH)
54
+ @my_agents = my_font.to_group(my_text).get_points.map do |point|
55
+ FontAgent.new(loc: Vec2D.new(point.x, point.y))
56
+ end
57
+ end
58
+
59
+ def draw
60
+ translate(400, 205)
61
+ background(0)
62
+ fill(255)
63
+ my_agents.each do |point|
64
+ point.display(step: step)
65
+ point.motion(x: mouse_x, y: mouse_y)
66
+ end
67
+ end
68
+
69
+ def key_pressed
70
+ case key
71
+ when 'f', 'F'
72
+ @stop_anime = !stop_anime
73
+ stop_anime ? no_loop : loop
74
+ when '+'
75
+ @step += 1
76
+ when '-'
77
+ @step -= 1
78
+ end
79
+ end
80
+ ```
81
+
82
+ ### FontAgent class
83
+ ```ruby
84
+ # FontAgent class handles motion and display
85
+ class FontAgent
86
+ include Processing::Proxy # gives java 'inner class like' access to App
87
+ attr_reader :loc, :mot
88
+
89
+ def initialize(loc:)
90
+ @loc = loc
91
+ @mot = 0
92
+ end
93
+
94
+ def motion(x:, y:)
95
+ noise_scale = map1d(x, (0..width), (0.001..0.01))
96
+ noise_z = map1d(y, (0..height), (frame_count * 0.0003..frame_count * 0.02))
97
+ @mot = noise(
98
+ loc.x * noise_scale * noise_z,
99
+ loc.y * noise_scale * noise_z
100
+ ) * 53
101
+ end
102
+
103
+ def display(step:)
104
+ no_stroke
105
+ fill(255, 53)
106
+ ellipse(loc.x, loc.y, mot + step, mot + step)
107
+ end
108
+ end
109
+ ```
110
+
111
+ ![bubbles.png]({{ site.github.url }}/assets/bubbles.png)
@@ -0,0 +1,103 @@
1
+ ---
2
+ layout: post
3
+ title: "Another tutorial example"
4
+ date: 2015-11-26 13:48:13
5
+ ---
6
+
7
+ ### Extra Bright
8
+
9
+
10
+ ```ruby
11
+ # --------- GEOMERATIVE EXAMPLES ---------------
12
+ # //////////////////////////////////////////////
13
+ # Title : TypoGeo_ExtraBright
14
+ # Date : 31/08/2011
15
+ # Version : v0.5
16
+ #
17
+ # Interactive work which you need to play with.
18
+ #
19
+ # Code adapted from an original idea by Stéphane Buellet
20
+ # http://www.chevalvert.fr/
21
+ #
22
+ # Licensed under GNU General Public License (GPL) version 3.
23
+ # http://www.gnu.org/licenses/gpl.html
24
+ #
25
+ # A series of tutorials for using the Geomerative Library
26
+ # developed by Ricard Marxer.
27
+ # http://www.ricardmarxer.com/geomerative/
28
+ #
29
+ # More info on these tutorials and workshops at :
30
+ # www.freeartbureau.org/blog
31
+ # translated for JRubyArt by Martin Prout
32
+ require 'geomerative'
33
+ require_relative 'font_agent'
34
+
35
+ attr_reader :my_agents, :x_incr, :y_incr
36
+
37
+ def settings
38
+ size(900, 350)
39
+ end
40
+
41
+ def setup
42
+ sketch_title 'Extra Bright'
43
+ background(0)
44
+ my_text = 'EXTRA BRIGHT'
45
+ @x_incr = 0.000005
46
+ @y_incr = 0.000008
47
+ RG.init(self)
48
+ my_font = RFont.new(data_path('FreeSans.ttf'), 97, CENTER)
49
+ RCommand.set_segment_length(1)
50
+ RCommand.set_segmentator(RCommand::UNIFORMLENGTH)
51
+ @my_agents = my_font.to_group(my_text).get_points.map do |point|
52
+ FontAgent.new(
53
+ loc: Vec2D.new(point.x, point.y),
54
+ increment: Vec2D.new(x_incr, y_incr)
55
+ )
56
+ end
57
+ end
58
+
59
+ def draw
60
+ translate(width / 2, height / 2)
61
+ background(0)
62
+ my_agents.each do |point|
63
+ m_point = point.motion
64
+ xr = (((100 / m_point) * 2) + mouse_x) - width / 2
65
+ yr = (((100 / m_point) * 2) + mouse_y) - height / 2
66
+ point.display(xr: xr, yr: yr, m_point: m_point)
67
+ end
68
+ end
69
+ ```
70
+
71
+ ### FontAgent class
72
+ ```ruby
73
+ # FontAgent class handles motion and display
74
+ class FontAgent
75
+ include Processing::Proxy # gives java 'inner class like' access to App
76
+ attr_reader :loc, :offset, :increment
77
+
78
+ def initialize(loc:, increment:)
79
+ @loc = loc.copy
80
+ @offset = Vec2D.new
81
+ @increment = increment
82
+ end
83
+
84
+ def motion
85
+ @offset += increment
86
+ loc.dist(Vec2D.new(noise(offset.x) * width, noise(offset.y) * height))
87
+ end
88
+
89
+ def display(xr:, yr:, m_point:)
90
+ no_stroke
91
+ fill(255, 73)
92
+ dia = (150 / m_point) * 5
93
+ # to get weird non-deterministic behaviour of original, created by use of
94
+ # negative inputs to a random range surely not intended, use original:-
95
+ # ellipse(loc.x + random(-xr, xr), loc.y + random(-yr, yr), dia, dia)
96
+ xr *= -1 if xr < 0 # guards against an invalid hi..low range
97
+ yr *= -1 if yr < 0
98
+ ellipse(loc.x + rand(-xr..xr), loc.y + rand(-yr..yr), dia, dia)
99
+ end
100
+ end
101
+ ```
102
+
103
+ ![bright.png]({{ site.github.url }}/assets/bright.png)