rubynk 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/bin/rubynk +18 -0
  3. data/lib/app.rb +105 -0
  4. data/lib/htmltemplate +8 -0
  5. data/lib/opal.js +18876 -0
  6. data/lib/processing.js +432 -0
  7. metadata +63 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cebb2287bf084d7b755c4a9cd62edd403c6d74bd
4
+ data.tar.gz: fce731e31074b3737dc8360674658a238d022fd2
5
+ SHA512:
6
+ metadata.gz: 8f3c0aca79c9658c9468691e17835064b66468ba85be1a2eb52fee86854955a2d28d34f4d79282f933ef25d2371b36f7d448cd654f193e7bc46635052dfcd207
7
+ data.tar.gz: 8d2178250456c3861a51cf7e62fec353b18dae6f7082d614dadb831b82156acf5e775611de0fe198f8585536fa7a2bb911b06106b903266faf5ca7b7402b8c36
data/bin/rubynk ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'opal'
4
+
5
+ def build(script)
6
+ Opal.append_path "."
7
+ Opal.append_path "lib"
8
+ src = IO.binread("lib/processing.js")
9
+ src << IO.binread("lib/opal.js")
10
+ src << Opal::Builder.build("app").to_s
11
+ src << Opal::Builder.build(script).to_s
12
+ File.binwrite "app.js", src
13
+
14
+ html = IO.binread("lib/htmltemplate")
15
+ File.binwrite "main.html", html
16
+
17
+ end
18
+ build(ARGV[0])
data/lib/app.rb ADDED
@@ -0,0 +1,105 @@
1
+ #
2
+ # Made with Opal and Processing
3
+ #
4
+
5
+ # Opal let's us talk directly to JS
6
+ require 'native'
7
+
8
+
9
+ # Methods for general purpose
10
+ module Common
11
+ def ynk_setup
12
+ $window = Native(`window`) # Get Page Window
13
+ $p = Native(`p`) #Set global Processing hook
14
+ end
15
+
16
+ def alert(message)
17
+ $window.alert(message)
18
+ end
19
+
20
+ def black
21
+ $p.background(1)
22
+ end
23
+
24
+ # Check if "mouse" is hovering over given rectangle
25
+ def over?(x,y,l,h)
26
+ true if $p.mouseX >= x &&
27
+ $p.mouseX <= l+x &&
28
+ $p.mouseY >= y &&
29
+ $p.mouseY <= h+y
30
+ end
31
+ end
32
+
33
+
34
+ class Rubynk
35
+ include Common
36
+ attr_accessor :p
37
+ def setup
38
+ ynk_setup
39
+ @p = $p
40
+ end
41
+
42
+ def draw
43
+
44
+
45
+
46
+ end
47
+
48
+ def mousePressed
49
+
50
+ end
51
+ def mouseClicked
52
+ # @container.start
53
+ # @container.hanna.mouseReleased
54
+ end
55
+ def mouseReleased
56
+ # @container.start
57
+ # @container.hanna.mouseReleased
58
+ end
59
+
60
+ def keyPressed
61
+ puts $p.key.to_s
62
+ end
63
+
64
+ end
65
+
66
+
67
+ `function sketchProc(processing) {
68
+ // Override draw function
69
+
70
+ window.p = processing
71
+
72
+ #{
73
+
74
+ @a = App.new #Initilize main app
75
+ }
76
+
77
+ window.a = #{@a}
78
+
79
+ processing.setup = function() {
80
+ #{@a.setup}
81
+ };
82
+
83
+ processing.draw = function() {
84
+ #{@a.draw}
85
+ };
86
+
87
+ processing.mousePressed = function() {
88
+ #{@a.mousePressed}
89
+ };
90
+
91
+ processing.mouseReleased = function() {
92
+ #{@a.mouseReleased}
93
+ };
94
+
95
+ processing.mouseClicked = function() {
96
+ #{@a.mouseClicked}
97
+ };
98
+
99
+ processing.keyPressed = function() {
100
+ #{@a.keyPressed}
101
+ };
102
+
103
+
104
+ }window.sketchProc = sketchProc`
105
+
data/lib/htmltemplate ADDED
@@ -0,0 +1,8 @@
1
+ <meta charset="utf-8">
2
+ <script src="app.js"></script>
3
+ <canvas style="outline:none" id="canvas"></canvas>
4
+ <script id="script1" type="text/javascript">
5
+ // attaching the sketchProc function to the canvas
6
+ var canvas = document.getElementById('canvas');
7
+ var p = new Processing(canvas, window.sketchProc);
8
+ </script>