Top Level Namespace

Defined Under Namespace

Modules: P5

Instance Method Summary collapse

Instance Method Details

#P5(width, height, &block) ⇒ Object



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/p5rb.rb', line 178

def P5 width, height, &block
  ::P5.module_eval &block
  "    <html>\n      <head>\n        <meta charset=\"UTF-8\">\n        <script src=\"https://github.com/processing/p5.js/releases/download/v1.4.2/p5.min.js\"></script>\n        <script>\n          function setup() {\n            createCanvas(\#{width}, \#{height});\n\#{\n  ::P5.buffer_setup.join(\";\\n\").gsub(/^/, ?\\s*12)\n}\n          }\n          function draw() {\n\#{\n  ::P5.buffer_draw.join(\";\\n\").gsub(/^/, ?\\s*12)\n}\n          }\n        </script>\n      </head>\n      <body style=\"margin: 0\"><main></main></body>\n    </html>\n  HEREDOC\nend\n"