picrate 0.0.2-java → 0.0.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/Rakefile +1 -1
  4. data/docs/_classes/aabb/aabb.md +28 -0
  5. data/docs/_classes/app/app.md +38 -0
  6. data/docs/_classes/app_render/app_render.md +93 -0
  7. data/docs/_classes/arc_ball/arc_ball.md +33 -0
  8. data/docs/_classes/chooser/chooser.md +56 -0
  9. data/docs/_classes/deglut/deglut.md +20 -0
  10. data/docs/_classes/library_proxy/library_proxy.md +76 -0
  11. data/docs/_classes/vec2d/vec2d.md +53 -0
  12. data/docs/_classes/vec3d/vec3d.md +53 -0
  13. data/docs/_config.yml +36 -7
  14. data/docs/_editors/vim.md +63 -0
  15. data/docs/_gems/gems/gems.md +29 -0
  16. data/docs/_gems/other_gems/other_gems.md +198 -0
  17. data/docs/_layouts/post.html +6 -6
  18. data/docs/_libraries/control_panel.md +137 -0
  19. data/docs/_libraries/custom.md +126 -0
  20. data/docs/_libraries/custom_java.md +162 -0
  21. data/docs/_libraries/gems.md +57 -0
  22. data/docs/_libraries/library_proxy.md +9 -0
  23. data/docs/_libraries/picrate.md +511 -0
  24. data/docs/_libraries/processing.md +126 -0
  25. data/docs/_libraries/vector_utils.md +126 -0
  26. data/docs/_magic/java.md +30 -0
  27. data/docs/_magic/jruby.md +105 -0
  28. data/docs/_magic/processing.md +297 -0
  29. data/docs/_magic/ruby.md +31 -0
  30. data/docs/_methods/alternative_methods.md +66 -0
  31. data/docs/_methods/color.md +109 -0
  32. data/docs/_methods/data_path.md +109 -0
  33. data/docs/_methods/draw.md +20 -0
  34. data/docs/_methods/key_pressed.md +27 -0
  35. data/docs/_methods/library_loader.md +49 -0
  36. data/docs/_methods/map1d.md +77 -0
  37. data/docs/_methods/methods_summary.md +103 -0
  38. data/docs/_methods/mouse_pressed.md +25 -0
  39. data/docs/_methods/post_initialize.md +9 -0
  40. data/docs/_methods/processing_api.md +46 -0
  41. data/docs/_methods/settings.md +48 -0
  42. data/docs/_methods/setup.md +36 -0
  43. data/docs/_methods/sketch_title.md +24 -0
  44. data/docs/_modules/custom.md +61 -0
  45. data/docs/_modules/helper_methods.md +10 -0
  46. data/docs/_modules/interface.md +66 -0
  47. data/docs/_modules/processing.md +7 -0
  48. data/docs/_modules/processing_proxy.md +28 -0
  49. data/docs/_objects/class/class.md +7 -0
  50. data/docs/_objects/global/global.md +7 -0
  51. data/docs/_objects/instance/instance.md +74 -0
  52. data/docs/_objects/numeric/numeric.md +37 -0
  53. data/docs/_posts/2018-05-06-getting_started.md +60 -0
  54. data/docs/_posts/2018-05-06-processing-api.md +68 -0
  55. data/docs/_posts/2018-05-11-arch-linux-arm.md +17 -0
  56. data/docs/about.md +7 -1
  57. data/docs/classes.md +10 -0
  58. data/docs/editors.md +10 -0
  59. data/docs/gems.md +11 -0
  60. data/docs/libraries.md +20 -0
  61. data/docs/magic.md +11 -0
  62. data/docs/methods.md +10 -0
  63. data/docs/modules.md +12 -0
  64. data/docs/objects.md +9 -0
  65. data/lib/picrate/version.rb +1 -1
  66. data/lib/picrate-0.0.3.jar +0 -0
  67. data/picrate.gemspec +2 -2
  68. data/pom.rb +1 -1
  69. data/pom.xml +7 -7
  70. data/src/main/java/monkstone/MathToolModule.java +2 -2
  71. data/src/main/java/monkstone/videoevent/VideoInterface.java +1 -1
  72. data/src/main/java/processing/core/PApplet.java +3 -3
  73. data/src/main/java/processing/javafx/PGraphicsFX2D.java +1 -1
  74. data/test/respond_to_test.rb +4 -4
  75. data/test/sketches/key_event.rb +3 -3
  76. data/vendors/Rakefile +1 -1
  77. metadata +61 -4
  78. data/lib/picrate-0.0.2.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 292bad32642f52265d09b224e75f536f2548947a5e1631f6f41e53376cdc6769
4
- data.tar.gz: 299f55ed80ae243525eafcc9286687486732a2faf153e15ad457b19f584937c7
3
+ metadata.gz: 3356804d4e8a73be8e31daceea79e551d0874f3aeb4e4e62b12ab9c4b2dd49de
4
+ data.tar.gz: 0a92a0e1a62969be5678c160701408c390fb67dd2bfeb0d3a57c6c95e68befa9
5
5
  SHA512:
6
- metadata.gz: 8d835c17104b60279636de242146cb89684aefe07766edcc6bde7f3523305d00405928d60d33d528fbbe2c85750c44945d0a87ab3f424f8eb02433001f792590
7
- data.tar.gz: 3b56360f1c6321eec552b543453944d9eda164f46ffd2c9398edcb8a77d2674ac02295b0693d345d0505d1abe3d038239a4d04b9c9402a65d746e61b0baa8242
6
+ metadata.gz: 791e4d54e4d1576ade00904c2d032ca0526a9245174f3d7a2ebb7ca1b84f5b99eb22b7c981564ed3f68790e9fe6cf21fbc00ab4bc1b2ef02daea49bc168188f5
7
+ data.tar.gz: 922bf6e7884fd966fe2b631fe1f61fb4b61ea4b9327643c365ab1d7d259fe3b95afd4fe7b182720d113a85e53a1a5f74560f9cfc36a64b0af01ac84279b389d4
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
- __C6H3N3O7__ [![Build Status](https://travis-ci.org/ruby-processing/PiCrate.svg?branch=master)](https://travis-ci.org/ruby-processing/PiCrate)
1
+ __C6H3N3O7__ [![Build Status](https://travis-ci.org/ruby-processing/PiCrate.svg?branch=master)](https://travis-ci.org/ruby-processing/PiCrate)
2
+ [![Gem Version](https://badge.fury.io/rb/picrate.svg)](https://badge.fury.io/rb/picrate)
2
3
 
3
4
  # PiCrate
4
- Create processing sketches in ruby on raspberry-pi and linux (this project is a parallel development of [propane][propane] targetting the raspberry-pi, but will initially be developed on a regular linux box). The aim is to produce a gem installable app that can be run with jruby, with minimal dependencies.
5
+ Create processing sketches in ruby on raspberry-pi and linux (this project is a parallel development of [picrate][picrate] targetting the raspberry-pi, but will initially be developed on a regular linux box). The aim is to produce a gem installable app that can be run with jruby, with minimal dependencies.
5
6
 
6
7
  ### To Build and Test ###
7
8
 
@@ -12,7 +13,7 @@ Requires maven, jdk8 (can be openjdk), and a jruby install.
12
13
  ```bash
13
14
  cd PiCrate
14
15
  rake
15
- jgem install picrate-0.0.1-java.gem
16
+ jgem install picrate-0.0.2-java.gem
16
17
  ```
17
18
  To create a template sketch:-
18
19
  ```bash
@@ -48,4 +49,4 @@ jruby my_sketch.rb
48
49
  ```
49
50
 
50
51
 
51
- [propane]:https://ruby-processing.github.io/propane/
52
+ [picrate]:https://ruby-processing.github.io/picrate/
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ end
21
21
  desc 'Install'
22
22
  task :install do
23
23
  sh 'mvn dependency:copy'
24
- sh 'mv target/picrate-0.0.2.jar lib'
24
+ sh 'mv target/picrate-0.0.3.jar lib'
25
25
  end
26
26
 
27
27
  desc 'Gem'
@@ -0,0 +1,28 @@
1
+ ---
2
+ layout: page
3
+ title: "AaBb"
4
+ permalink: /classes/aabb/
5
+ ---
6
+
7
+ AaBb is a 2D axis aligned bounding box for propane
8
+
9
+ Constructors:-
10
+ ```ruby
11
+ # Regular constructor where vec_one and vec_two are instances of Vec2D
12
+ AaBb.new(center: vec_one, extent: vec_two)
13
+ # Alternative constructor where vec_one and vec_two are instances of Vec2D
14
+ AaBb.new(min: vec_one, max: vec_two)
15
+ ```
16
+
17
+ Methods:-
18
+ ```ruby
19
+ center # returns the AaBb center Vec2D
20
+ extent # returns the AaBb extent as Vec2D
21
+ position(vec) # set the center as vec
22
+ position(vec) { block } # set the center as vec, if block evaluates to true
23
+ contains?(vec) # returns true/false if box contains point at vec
24
+ ```
25
+
26
+ Example: [Constrained Box][example]
27
+
28
+ [example]: https://github.com/ruby-processing/picrate-examples/blob/master/library/vecmath/vec2d/aabb_test.rb
@@ -0,0 +1,38 @@
1
+ ---
2
+ layout: post
3
+ title: "App"
4
+ keywords: App, PApplet
5
+ ---
6
+ The `App` class (`Processing::App`) is a subclass of `PApplet`, and one way or another your propane sketch inherits from `Processing::App`, it is just not obvious in a `nude` or `bare` propane sketch. Unless you explicitly create your own Sketch class, the default is to create an instance of `Sketch < Processing::App` as below. What a bare sketch would look like when wrapped prior to eval.
7
+
8
+ ```ruby
9
+ class Sketch < Processing::App
10
+ # your bare sketch code may include 'draw' should include 'settings'
11
+ end
12
+
13
+ Sketch.new
14
+ ```
15
+
16
+ What a nude static sketch would look like when wrapped prior to eval.
17
+
18
+ ```ruby
19
+ class Sketch < Processing::App
20
+ def setup
21
+ sketch_title 'Nude Sketch'
22
+ # your nude sketch code here eg `background 0`
23
+ no_loop
24
+ end
25
+ def settings
26
+ size(150, 150)
27
+ end
28
+ end
29
+
30
+ Sketch.new
31
+ ```
32
+ You should be aware that all vanilla processing sketches are similary wrapped prior to java compilation. The idea of processing and also propane is to make it easy to create sketches, so this is all you need to know, and you should probably look at [propane][propane] if you really prefer class wrapped sketches.
33
+
34
+ For propane see also [Processing][processing] module for more details, you could also see [magic][magic] (_but it 'really' is not necessary_)
35
+
36
+ [propane]:https://ruby-processing.github.io/propane/
37
+ [processing]:{{ site.github.url }}/modules/processing
38
+ [magic]:{{ site.github.url }}/magic.html
@@ -0,0 +1,93 @@
1
+ ---
2
+ layout: post
3
+ title: "AppRender and ShapeRender"
4
+ keywords: to_vertex, Vec3D, Vec2D, AppRender, ShapeRender
5
+ ---
6
+ Vec2D and Vec3D classes can be efficiently rendered as both PApplet vertices, and PShape vertices using AppRender and ShapeRender utility classes. To use the AppRender renderer you should create a single instance in the processing setup see below example:-
7
+
8
+ ### AppRender
9
+
10
+ ```ruby
11
+ attr_reader :renderer
12
+ ...
13
+ def setup
14
+ @renderer = AppRender.new(self)
15
+ end
16
+ ...
17
+ ```
18
+
19
+ Note the use of `attr_reader` so we can access the `renderer` outside of `setup`. Here is a snippet of code for a 2D sketch, where we draw a polygon outline directly using the processing vertex (nested within `begin_shape` and `end_shape(CLOSE)`). All we need to do is supply our renderer as an argument to the Vec2D `:to_vertex` instance method.
20
+
21
+ ```ruby
22
+ ...
23
+ begin_shape # Vec2D example
24
+ no_fill
25
+ stroke(255)
26
+ morph.each do |v|
27
+ v.to_vertex(renderer)
28
+ end
29
+ end_shape(CLOSE)
30
+ ...
31
+ ```
32
+
33
+ If you chose not use the renderer, this is how the code would look, requires more ruby to java conversions:-
34
+
35
+ ```ruby
36
+ ...
37
+ begin_shape # Vec2D example
38
+ no_fill
39
+ stroke(255)
40
+ morph.each do |v|
41
+ vertex(v.x, v.y)
42
+ end
43
+ end_shape(CLOSE)
44
+ ...
45
+ ```
46
+
47
+ ### ShapeRender
48
+
49
+ Usage of the ShapeRender is similar, except that you need to `create_shape` first, and it is the created `shape` that needs to be available in the draw loop. Here is a code snippet for use of a `ShapeRender` with `Vec2D`, where `original` is an array of `Vec2D` describing a closed polygon. We use an attr_reader for `s` so that we can define it one block of code and use `shape(s)` to call it in the draw loop in the normal way for a 'retained shape/vbo'.
50
+
51
+ ```ruby
52
+ attr_reader :s
53
+ ...
54
+ @s = create_shape
55
+ renderer = ShapeRender.new(s)
56
+ s.begin_shape
57
+ s.fill(127)
58
+ s.stroke(0)
59
+ s.stroke_weight(2)
60
+ original.map{ |v| v.to_vertex(renderer) }
61
+ s.end_shape(CLOSE)
62
+ ...
63
+ shape(s)
64
+ ```
65
+
66
+ There is also the possibility of adding texture see this `ShapeRender` usage snippet:-
67
+
68
+ ```ruby
69
+ ...
70
+ # Put all the relevant data into the PShape
71
+
72
+ texture_mode(NORMAL) # set texture_mode to normalized (range 0 to 1)
73
+ tex = load_image(data_path 'Texture01.jpg')
74
+
75
+ mesh = create_shape # create the initial PShape
76
+ renderer = ShapeRender.new(mesh) # initialize the shape renderer
77
+ mesh.begin_shape(QUADS) # define the PShape type: QUADS
78
+ mesh.no_stroke
79
+ mesh.texture(tex) # set a texture to make a textured PShape
80
+ # put all the vertices, uv texture coordinates and normals into the PShape
81
+ positions.each_with_index do |p, i|
82
+ t = tex_coords[i]
83
+ p.to_vertex_uv(renderer, t.x, t.y)
84
+ end
85
+ mesh.end_shape
86
+ ...
87
+ ```
88
+
89
+ The above snippet is taken from the [glsl_heighmap_noise.rb sketch][glsl], for another example of the advanced use of the ShapeRender class see the [trefoil sketch][trefoil]. Warning if you are using ShapeRender inside a custom class you need to prefix it with the sketch class name `Sketch::` for bare sketches, see [wiggle_pshape][wiggling] sketch.
90
+
91
+ [glsl]:https://github.com/ruby-processing/picrate-examples/blob/master/topics/shaders/glsl_heightmap_noise.rb
92
+ [trefoil]:https://github.com/ruby-processing/picrate-examples/blob/master/demos/graphics/trefoil.rb
93
+ [wiggling]:https://github.com/ruby-processing/picrate-examples/blob/master/library/vecmath/vec2d/wiggle_pshape.rb
@@ -0,0 +1,33 @@
1
+ ---
2
+ layout: page
3
+ title: "ArcBall"
4
+ permalink: /classes/arcball/
5
+ ---
6
+
7
+ ArcBall is a user input interface to make a 3D object rotate in an intuitive way. It uses quaternions to represent orientations, although this implementation detail is hidden in propane. Use the ArcBall to enable mouse drag rotation and mouse wheel zoom in 3D sketches. Hold down x, y or z keys to constrain the rotation axis.
8
+
9
+ See a simple example below, where the box (a cube in this case) gets centered in the middle of the display.
10
+
11
+ ```ruby
12
+ def setup
13
+ sketch_title 'Arcball Box'
14
+ ArcBall.init self
15
+ fill 180
16
+ end
17
+
18
+ def draw
19
+ background 50
20
+ box 300, 300, 300
21
+ end
22
+
23
+ def settings
24
+ size 600, 600, P3D
25
+ smooth 8
26
+ end
27
+ ```
28
+
29
+ Alternative Examples: [3D Menger][menger], [Retained Shape][shape], [Constrained ArcBall][constrain]
30
+
31
+ [menger]: https://github.com/ruby-processing/picrate-examples/blob/master/library/vecmath/vec3d/retained_menger.rb
32
+ [shape]: https://github.com/ruby-processing/picrate-examples/blob/master/library/vecmath/arcball/arcball_shape.rb
33
+ [constrain]: https://github.com/ruby-processing/picrate-examples/blob/master/library/vecmath/arcball/constrain.rb
@@ -0,0 +1,56 @@
1
+ ---
2
+ layout: page
3
+ title: "File Chooser"
4
+ permalink: /classes/chooser/
5
+ ---
6
+
7
+ A native file chooser for propane, bases around vanilla processing `selectInput`.
8
+
9
+ ### Usage ###
10
+
11
+ First load the `chooser` library, this creates the interface:-
12
+
13
+ `public void file_selected(java.io.File selected);`
14
+
15
+ which you need to define in your sketch, to make use the `selected` file. This sketch makes use of the propane method `resizable` (vanilla processing `surface.setResizable(true)`) so that we can change sketch size to match our `image`. Note we need to guard against `img` being `nil` or sketch will crash. You may change the the prompt `select an image` in `select_input` but you cannot change `file_selected` which is hard-wired to cope with java reflection.
16
+
17
+ ### example sketch ###
18
+ ```ruby
19
+ load_library :chooser
20
+
21
+ attr_reader :img
22
+
23
+ def settings
24
+ size(400, 200)
25
+ end
26
+
27
+ def setup
28
+ sketch_title 'Chooser'
29
+ resizable
30
+ fill 0, 0, 200
31
+ text('Click Window to Load Image', 10, 100)
32
+ end
33
+
34
+ def draw
35
+ image(img, 0, 0) unless img.nil?
36
+ end
37
+
38
+ def file_selected(selection)
39
+ if selection.nil?
40
+ puts 'Nothing Chosen'
41
+ else
42
+ @img = load_image(selection.get_absolute_path)
43
+ surface.set_size(img.width, img.height)
44
+ end
45
+ end
46
+
47
+ def mouse_clicked
48
+ @img = nil
49
+ # java_signature 'void selectInput(String, String)'
50
+ select_input('select an image', 'file_selected')
51
+ end
52
+ ```
53
+
54
+ See more [examples here][examples]
55
+
56
+ [examples]:https://github.com/ruby-processing/picrate-examples/tree/master/processing_app/library/file_chooser
@@ -0,0 +1,20 @@
1
+ ---
2
+ layout: page
3
+ title: "Deglut"
4
+ permalink: /classes/deglut/
5
+ ---
6
+
7
+ Deglut is a fast math module that does sin and cos for integer degrees
8
+
9
+ Methods:-
10
+ ```ruby
11
+ # Returns sine from integer degree input (uses look up table)
12
+ DegLut.sin(deg)
13
+ # Returns cosine from integer degree input (uses look up table)
14
+ DegLut.cos(deg)
15
+ ```
16
+
17
+ Example Usages: [Analog Clock][clock], [Function Grapher][grapher]
18
+
19
+ [clock]: https://github.com/ruby-processing/picrate-examples/blob/master/library/fastmath/clock.rb
20
+ [grapher]: https://github.com/ruby-processing/picrate-examples/blob/master/contributed/grapher.rb
@@ -0,0 +1,76 @@
1
+ ---
2
+ layout: post
3
+ title: "LibraryProxy"
4
+ keywords: processing, abstract class, library
5
+ ---
6
+ The purpose of the `LibraryProxy` class is to provide access to [processing reflection][library] methods:-
7
+
8
+ In the sketch we must `load_library :library_proxy` then our ruby library class can inherit from `LibraryProxy` as below, but it must implement all the abstract methods, even if method is empty
9
+
10
+ ```ruby
11
+ class MyClass < LibraryProxy
12
+ # access to pre, draw, etc
13
+ end
14
+ ```
15
+
16
+ Example sketch:-
17
+ ```ruby
18
+ #!/usr/bin/env jruby
19
+ require 'picrate'
20
+ require_relative 'register_send'
21
+
22
+ class LibraryProxySketch < Processing::App
23
+
24
+ # A simple demonstration of vanilla processing 'reflection' methods using
25
+ # propane :library_proxy. See my_library.rb code for the guts.
26
+ load_library :library_proxy
27
+ require_relative 'my_library'
28
+
29
+ def settings
30
+ size 300, 200
31
+ end
32
+
33
+ def setup
34
+ sketch_title 'Reflection Voodoo Proxy'
35
+ MyLibrary.new self
36
+ no_loop
37
+ end
38
+
39
+ def draw
40
+ fill(0, 0, 200)
41
+ ellipse(170, 115, 70, 100)
42
+ end
43
+ end
44
+
45
+ LibraryProxySketch.new
46
+ ```
47
+ my_library.rb
48
+
49
+ ```ruby
50
+ # This class demonstrates how by inheriting from the abstract class LibraryProxy
51
+ # we can access 'pre', 'draw' and 'post' (Note we need a post method even
52
+ # though it is empty)
53
+ class MyLibrary < LibraryProxy
54
+ attr_reader :app
55
+
56
+ def initialize(parent)
57
+ @app = parent
58
+ end
59
+
60
+ def pre
61
+ background(100)
62
+ end
63
+
64
+ def draw
65
+ app.fill(200, 100)
66
+ app.ellipse(150, 100, 200, 60)
67
+ end
68
+
69
+ def post # required but empty method is fine
70
+ end
71
+ end
72
+ ```
73
+
74
+ ![library_proxy_sketch.rb]({{ site.github.url }}/assets/library_proxy.png)
75
+
76
+ [library]:https://github.com/processing/processing/wiki/Library-Basics
@@ -0,0 +1,53 @@
1
+ ---
2
+ layout: page
3
+ title: "Vec2D"
4
+ permalink: /classes/vec2d/
5
+ ---
6
+
7
+ The Vec2D class is a direct replacement for processings PVector class (when used for 2D work, see Vec3D for 3D version).
8
+
9
+ ### Methods:-
10
+ ```ruby
11
+ a * b # where a is instance of Vec2D and b is a scalar
12
+ a + b # where both a and b are both instances of Vec2D
13
+ a - b # where both a and b are both instances of Vec2D
14
+ a / b # where a is instance of Vec2D and b is a scalar
15
+ a == b # where both a and b are both instances of Vec2D
16
+ a.angle_between(b) # where both a and b are both instances of Vec2D
17
+ a.copy # where a is instance of Vec2D returns a deep copy
18
+ a.cross(b) # where both a and b are both instances of Vec2D
19
+ a.dist(b) # where both a and b are both instances of Vec2D
20
+ a.dot(b) # where both a and b are both instances of Vec2D
21
+ a.heading # where a is instance of Vec2D
22
+ a.lerp(b) # where both a and b are both instances of Vec2D
23
+ a.lerp!(b) # where both a and b are both instances of Vec2D
24
+ a.mag # where a is instance of Vec2D
25
+ a.normalize # where a is instance of Vec2D
26
+ a.normalize! # where a is instance of Vec2D
27
+ a.normalize!(b) # where both a and b are both instances of Vec2D
28
+ a.rotate(b) # where both a is an instance of Vec2D and b is scalar radians
29
+ a.rotate!(b) # where both a is an instance of Vec2D and b is scalar radians
30
+ a.set_mag(b) # where both a is instance of Vec2D and b is scalar
31
+ a.set_mag(b) &block # a conditional variantwhere &block evaluates to a boolean
32
+ a.to_a # returns an array [x, y] where a is instance of Vec2D
33
+ a.to_s # returns a string where a is instance of Vec2D
34
+ a.to_vertex(b) # where b is a instance of Render sends vector a to PApplet.vertex
35
+ a.x returns x as a float # where a is instance of Vec2D
36
+ a.x=b # sets the x value of Vec2D a to the float b
37
+ a.y # returns y as a float # where a is instance of Vec2D
38
+ a.y=b # sets the y value of Vec2D a to the float b
39
+ ```
40
+ ### Constructors:-
41
+ ```ruby
42
+ Vec2D.from_angle(a) # returns a new Vec2D object # where a is a float radians
43
+ Vec2D.random # returns a new random Vec2D object # with mag 1.0
44
+ Vec2D.new # returns new instance where x, y are both zero.
45
+ Vec2D.new(a, b) # where a and b are both float or numeric (NB: stored as float)
46
+ Vec2D.new(vec) # where vec has methods `:x` and `:y` that return float or numeric
47
+ ```
48
+
49
+ Note: normalize on zero vector returns a zero vector for simplicities sake (like PVector)
50
+
51
+ Example Usages: [Examples][Vec2D]
52
+
53
+ [Vec2D]: https://github.com/ruby-processing/picrate-examples/blob/master/library/vecmath/vec2d/
@@ -0,0 +1,53 @@
1
+ ---
2
+ layout: page
3
+ title: "Vec3D"
4
+ permalink: /classes/vec3d/
5
+ ---
6
+
7
+ The Vec3D class is a direct replacement for processings PVector class (when used for 3D work, see Vec2D for 2D version).
8
+
9
+ ### Methods:-
10
+ ```ruby
11
+ a * b # where a is instance of Vec3D and b is a scalar
12
+ a + b # where both a and b are both instances of Vec3D
13
+ a - b # where both a and b are both instances of Vec3D
14
+ a / b # where a is instance of Vec3D and b is a scalar
15
+ a == b # where both a and b are both instances of Vec3D
16
+ a.angle_between(b) # where both a and b are both instances of Vec3D
17
+ a.copy # where a is instance of Vec3D returns a deep copy
18
+ a.cross(b) # where both a and b are both instances of Vec3D
19
+ a.dist(b) # where both a and b are both instances of Vec3D
20
+ a.dist_squared(b) # where both a and b are both instances of Vec3D
21
+ a.dot(b) # where both a and b are both instances of Vec3D
22
+ a.mag # where a is instance of Vec3D
23
+ a.mag_squared # where a is instance of Vec3D
24
+ a.normalize # where a is instance of Vec3D
25
+ a.normalize! # where a is instance of Vec3D
26
+ a.set_mag(b) # where a is instance of Vec3D and b is a scalar
27
+ a.set_mag(b) &block # a conditional variant where &block evaluates to a boolean
28
+ a.to_a returns array [x, y, z] # where a is an instance of Vec3D
29
+ a.to_normal(b) # where b is a instance of Render sends vector a to PApplet.normal
30
+ a.to_s # where a is instance of Vec3D
31
+ a.to_vertex(b) # where b is a instance of Render sends vector a to PApplet.vertex
32
+ a.to_vertex_uv(b, u, v) # where b is a instance of Render sends vector a to PApplet.vertex, with float u and v (texture)
33
+ a.x # returns x as a float where a is instance of Vec2D
34
+ a.x = b # sets the x value of Vec3D a to the float b
35
+ a.y # returns y as a float where a is instance of Vec2D
36
+ a.y = b # sets the y value of Vec3D a to the float b
37
+ a.z # returns z as a float where a is instance of Vec2D
38
+ a.z = b # sets the z value of Vec3D a to the float b
39
+ ```
40
+ ### Constructors:-
41
+ ```ruby
42
+ Vec3D.random # returns a new random Vec3D object # with mag 1.0
43
+ Vec3D.new # returns new instance where x, y, z are all zero.
44
+ Vec3D.new(a, b, c) # where a, b & c are float or numeric (NB: stored as float)
45
+ Vec3D.new(vec) # where vec has methods `:x` and `:y` that return float or numeric
46
+ # if vec has no method `:z` then z is set to zero.
47
+ ```
48
+
49
+ Note: normalize on zero vector returns a zero vector for simplicities sake (like PVector)
50
+
51
+ Example Usages: [Examples][Vec3D]
52
+
53
+ [Vec3D]: https://github.com/ruby-processing/picrate-examples/blob/master/library/vecmath/vec3d/
data/docs/_config.yml CHANGED
@@ -15,16 +15,45 @@ urls:
15
15
  wiki: https://github.com/ruby-processing/PiCrate/wiki
16
16
  twitter_username: monkstoneT
17
17
  github_username: monkstone
18
-
19
- syntax-highlighting:
20
- enabled: true
21
-
22
- sass:
23
- sass_dir: _sass
24
-
25
18
  # Build settings
26
19
  markdown: kramdown
27
20
  gems:
28
21
  - jekyll-sitemap
29
22
  - jekyll-feed
30
23
  - jekyll-seo-tag
24
+
25
+ include: [collections]
26
+ collections:
27
+ blocks:
28
+ output: true
29
+ permalink: /blocks/index.html
30
+ classes:
31
+ output: true
32
+ permalink: /classes/index.html
33
+ editors:
34
+ output: true
35
+ permalink: /editors/index.html
36
+ methods:
37
+ output: true
38
+ permalink: /methods/index.html
39
+ gems:
40
+ output: true
41
+ permalink: /gems/index.html
42
+ libraries:
43
+ output: true
44
+ permalink: /libraries/index.html
45
+ modules:
46
+ output: true
47
+ permalink: /modules/index.html
48
+ magic:
49
+ output: true
50
+ permalink: /magic/index.html
51
+ objects:
52
+ output: true
53
+ permalink: /objects/index.html
54
+
55
+ syntax-highlighting:
56
+ enabled: true
57
+
58
+ sass:
59
+ sass_dir: _sass
@@ -0,0 +1,63 @@
1
+ ---
2
+ layout: post
3
+ title: "Vim"
4
+ permalink: /editors/vim/
5
+ keywords: editor, ide, ruby, picrate, vim, emacs, jedit
6
+ ---
7
+
8
+ Is an excellent choice for linux and mac users, it is lighweight (runs from the console) commands available from vim:-
9
+ ```bash
10
+ :!jruby % # will run the sketch
11
+ ```
12
+
13
+ ### Live coding with Pry ###
14
+
15
+ ```bash
16
+ jgem install pry
17
+ # or jruby -S gem install pry
18
+ # or if you must use rvm or rbenv not recommended
19
+ ```
20
+ Do `echo "Pry.config.editor = 'vim'" > ~/.pryrc` to set vim as the pry editor.
21
+
22
+ Fire up pry using
23
+
24
+ ```bash
25
+ jruby -e "require 'pry'; binding.pry"
26
+ ```
27
+
28
+ Or more conveniently create a shortcut by using `jpry` alias in your `.bashrc` or equivalent eg `.profile` debian linux:-
29
+
30
+ ```bash
31
+ alias jpry="jruby -e \"require 'pry'; binding.pry\""
32
+ ```
33
+
34
+ At the pry prompt:-
35
+
36
+ ```ruby
37
+ load 'my_sketch'
38
+ ```
39
+
40
+ Creating `my_sketch` is a easy as `picrate -c my_sketch 300 300`
41
+
42
+ To get full listing of sketch in pry enter `$` at the prompt, to edit the `draw` method at the prompt do:-
43
+
44
+ ```bash
45
+ edit -p MySketch#draw
46
+ ```
47
+
48
+ On finished save and quit `:wq` (or `:wqa` to save all changed buffers) sketch will redraw reflecting changes, but you can repeat:-
49
+
50
+ ```bash
51
+ edit -p MySketch#draw
52
+ ```
53
+
54
+ this allows you to edit your changes which are saved in a `.tmp` file. Read more about vim / emacs integration [here][pry-wiki]
55
+
56
+ ### Other advantages of vim ###
57
+
58
+ Also because vim is run from the console it is so easy to run old friends like `rubocop` or `reek` on your sketch code.
59
+
60
+ If you are millenial and allergic to the command line install use an editor that supports ruby syntax, emacs is only for hardcore geeks. As yet I don't think the raspberrypi supports `atom` as an editor.
61
+
62
+ [atom]:{{ site.github.url }}/atom/
63
+ [pry-wiki]:https://github.com/pry/pry/wiki/Editor-integration/
@@ -0,0 +1,29 @@
1
+ ---
2
+ layout: post
3
+ title: "Gems Built For picrate"
4
+ date: 2015-11-21 20:55:13
5
+ categories: picrate update
6
+ keywords: gem, library, picrate
7
+ permalink: gems/gems.html
8
+ ---
9
+
10
+ ### Processing libraries ported as ruby-gems
11
+
12
+ [arcball][arcball], [toxiclibs][tox], [geomerative][geom], [wordcram][wordcram]
13
+
14
+ NB: the arcball gem is installed as a picrate dependency
15
+
16
+ ### Other java libraries ported as ruby-gems
17
+
18
+ jbox2d ([pbox2d][jbox2d])
19
+
20
+ ### Stand Alone Gems
21
+ [cf3][cf3] context free art in ruby
22
+
23
+ [cf3]:https://github.com/monkstone/cf3ruby/
24
+ [arcball]:https://github.com/ruby-processing/ArcBall/
25
+ [tox]:https://github.com/ruby-processing/toxicgem/
26
+ [geom]:https://ruby-processing.github.io/geomerativegem/
27
+ [jbox2d]:https://github.com/ruby-processing/jbox2d/
28
+ [cf3]:https://github.com/monkstone/cf3ruby/
29
+ [wordcram]:https://ruby-processing.github.io/WordCram/