dxopal 1.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.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.ignore +5 -0
- data/.nojekyll +4 -0
- data/CHANGELOG.md +90 -0
- data/DEVELOPMENT.md +57 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +39 -0
- data/README.md +22 -0
- data/Rakefile +66 -0
- data/TODO.md +278 -0
- data/build/dxopal.js +46590 -0
- data/build/dxopal.min.js +1 -0
- data/config.ru +39 -0
- data/doc/api/DXOpal.html +129 -0
- data/doc/api/DXOpal/Font.html +485 -0
- data/doc/api/DXOpal/Image.html +2533 -0
- data/doc/api/DXOpal/Input.html +1086 -0
- data/doc/api/DXOpal/Input/MouseCodes.html +146 -0
- data/doc/api/DXOpal/RemoteResource.html +641 -0
- data/doc/api/DXOpal/Sound.html +568 -0
- data/doc/api/DXOpal/SoundEffect.html +444 -0
- data/doc/api/DXOpal/SoundEffect/WaveTypes.html +130 -0
- data/doc/api/DXOpal/Sprite.html +1419 -0
- data/doc/api/DXOpal/Window.html +1915 -0
- data/doc/api/_index.html +228 -0
- data/doc/api/class_list.html +51 -0
- data/doc/api/css/common.css +1 -0
- data/doc/api/css/full_list.css +58 -0
- data/doc/api/css/style.css +492 -0
- data/doc/api/file.CHANGELOG.html +162 -0
- data/doc/api/file.README.html +124 -0
- data/doc/api/file_list.html +61 -0
- data/doc/api/frames.html +17 -0
- data/doc/api/index.html +124 -0
- data/doc/api/js/app.js +248 -0
- data/doc/api/js/full_list.js +216 -0
- data/doc/api/js/jquery.js +4 -0
- data/doc/api/method_list.html +939 -0
- data/doc/api/top-level-namespace.html +110 -0
- data/doc/en/index.html +93 -0
- data/doc/ja/index.html +92 -0
- data/dxopal.gemspec +29 -0
- data/exe/dxopal +44 -0
- data/index.html +56 -0
- data/opal/dxopal.rb +54 -0
- data/opal/dxopal/constants/colors.rb +16 -0
- data/opal/dxopal/font.rb +20 -0
- data/opal/dxopal/image.rb +301 -0
- data/opal/dxopal/input.rb +170 -0
- data/opal/dxopal/input/key_codes.rb +168 -0
- data/opal/dxopal/remote_resource.rb +65 -0
- data/opal/dxopal/sound.rb +53 -0
- data/opal/dxopal/sound_effect.rb +84 -0
- data/opal/dxopal/sprite.rb +94 -0
- data/opal/dxopal/sprite/collision_area.rb +288 -0
- data/opal/dxopal/sprite/collision_check.rb +106 -0
- data/opal/dxopal/sprite/collision_checker.rb +169 -0
- data/opal/dxopal/sprite/physics.rb +82 -0
- data/opal/dxopal/version.rb +3 -0
- data/opal/dxopal/window.rb +173 -0
- data/template/index.html +13 -0
- data/template/main.rb +9 -0
- metadata +191 -0
@@ -0,0 +1,2533 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: DXOpal::Image
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "DXOpal::Image";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (I)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../DXOpal.html" title="DXOpal (module)">DXOpal</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Image</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: DXOpal::Image
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="RemoteResource.html" title="DXOpal::RemoteResource (class)">RemoteResource</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next"><span class='object_link'><a href="RemoteResource.html" title="DXOpal::RemoteResource (class)">RemoteResource</a></span></li>
|
78
|
+
|
79
|
+
<li class="next">DXOpal::Image</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>opal/dxopal/image.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
109
|
+
<ul class="summary">
|
110
|
+
|
111
|
+
<li class="public ">
|
112
|
+
<span class="summary_signature">
|
113
|
+
|
114
|
+
<a href="#canvas-instance_method" title="#canvas (instance method)">#<strong>canvas</strong> ⇒ Object </a>
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
</span>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<span class="note title readonly">readonly</span>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<span class="summary_desc"><div class='inline'>
|
134
|
+
<p>Returns the value of attribute canvas.</p>
|
135
|
+
</div></span>
|
136
|
+
|
137
|
+
</li>
|
138
|
+
|
139
|
+
|
140
|
+
<li class="public ">
|
141
|
+
<span class="summary_signature">
|
142
|
+
|
143
|
+
<a href="#ctx-instance_method" title="#ctx (instance method)">#<strong>ctx</strong> ⇒ Object </a>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
</span>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
<span class="note title readonly">readonly</span>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
<span class="summary_desc"><div class='inline'>
|
163
|
+
<p>Returns the value of attribute ctx.</p>
|
164
|
+
</div></span>
|
165
|
+
|
166
|
+
</li>
|
167
|
+
|
168
|
+
|
169
|
+
<li class="public ">
|
170
|
+
<span class="summary_signature">
|
171
|
+
|
172
|
+
<a href="#height-instance_method" title="#height (instance method)">#<strong>height</strong> ⇒ Object </a>
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
</span>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<span class="note title readonly">readonly</span>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
<span class="summary_desc"><div class='inline'>
|
192
|
+
<p>Returns the value of attribute height.</p>
|
193
|
+
</div></span>
|
194
|
+
|
195
|
+
</li>
|
196
|
+
|
197
|
+
|
198
|
+
<li class="public ">
|
199
|
+
<span class="summary_signature">
|
200
|
+
|
201
|
+
<a href="#width-instance_method" title="#width (instance method)">#<strong>width</strong> ⇒ Object </a>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
</span>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
<span class="note title readonly">readonly</span>
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
<span class="summary_desc"><div class='inline'>
|
221
|
+
<p>Returns the value of attribute width.</p>
|
222
|
+
</div></span>
|
223
|
+
|
224
|
+
</li>
|
225
|
+
|
226
|
+
|
227
|
+
</ul>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
<h2>
|
234
|
+
Class Method Summary
|
235
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
236
|
+
</h2>
|
237
|
+
|
238
|
+
<ul class="summary">
|
239
|
+
|
240
|
+
<li class="public ">
|
241
|
+
<span class="summary_signature">
|
242
|
+
|
243
|
+
<a href="#_load-class_method" title="_load (class method)">.<strong>_load</strong>(path_or_url) ⇒ Object </a>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
</span>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
<span class="summary_desc"><div class='inline'>
|
258
|
+
<p>Load remote image (called via Window.load_resources).</p>
|
259
|
+
</div></span>
|
260
|
+
|
261
|
+
</li>
|
262
|
+
|
263
|
+
|
264
|
+
</ul>
|
265
|
+
|
266
|
+
<h2>
|
267
|
+
Instance Method Summary
|
268
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
269
|
+
</h2>
|
270
|
+
|
271
|
+
<ul class="summary">
|
272
|
+
|
273
|
+
<li class="public ">
|
274
|
+
<span class="summary_signature">
|
275
|
+
|
276
|
+
<a href="#[]-instance_method" title="#[] (instance method)">#<strong>[]</strong>(x, y) ⇒ Object </a>
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
</span>
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
<span class="summary_desc"><div class='inline'>
|
291
|
+
<p>Get a pixel as ARGB array.</p>
|
292
|
+
</div></span>
|
293
|
+
|
294
|
+
</li>
|
295
|
+
|
296
|
+
|
297
|
+
<li class="public ">
|
298
|
+
<span class="summary_signature">
|
299
|
+
|
300
|
+
<a href="#[]=-instance_method" title="#[]= (instance method)">#<strong>[]=</strong>(x, y, color) ⇒ Object </a>
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
</span>
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
<span class="summary_desc"><div class='inline'>
|
315
|
+
<p>Put a pixel on this image.</p>
|
316
|
+
</div></span>
|
317
|
+
|
318
|
+
</li>
|
319
|
+
|
320
|
+
|
321
|
+
<li class="public ">
|
322
|
+
<span class="summary_signature">
|
323
|
+
|
324
|
+
<a href="#_draw_raw_image-instance_method" title="#_draw_raw_image (instance method)">#<strong>_draw_raw_image</strong>(x, y, raw_img) ⇒ Object </a>
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
</span>
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
<span class="summary_desc"><div class='inline'>
|
339
|
+
<p>Copy an <img> onto this image.</p>
|
340
|
+
</div></span>
|
341
|
+
|
342
|
+
</li>
|
343
|
+
|
344
|
+
|
345
|
+
<li class="public ">
|
346
|
+
<span class="summary_signature">
|
347
|
+
|
348
|
+
<a href="#_image_data-instance_method" title="#_image_data (instance method)">#<strong>_image_data</strong>(x = 0, y = 0, w = @width, h = @height) ⇒ Object </a>
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
</span>
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
<span class="summary_desc"><div class='inline'>
|
363
|
+
<p>Return .getImageData.</p>
|
364
|
+
</div></span>
|
365
|
+
|
366
|
+
</li>
|
367
|
+
|
368
|
+
|
369
|
+
<li class="public ">
|
370
|
+
<span class="summary_signature">
|
371
|
+
|
372
|
+
<a href="#_put_image_data-instance_method" title="#_put_image_data (instance method)">#<strong>_put_image_data</strong>(image_data, x, y) ⇒ Object </a>
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
</span>
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
<span class="summary_desc"><div class='inline'>
|
387
|
+
<p>Call .putImageData.</p>
|
388
|
+
</div></span>
|
389
|
+
|
390
|
+
</li>
|
391
|
+
|
392
|
+
|
393
|
+
<li class="public ">
|
394
|
+
<span class="summary_signature">
|
395
|
+
|
396
|
+
<a href="#_resize-instance_method" title="#_resize (instance method)">#<strong>_resize</strong>(w, h) ⇒ Object </a>
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
</span>
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
<span class="summary_desc"><div class='inline'>
|
411
|
+
<p>Set size of this image.</p>
|
412
|
+
</div></span>
|
413
|
+
|
414
|
+
</li>
|
415
|
+
|
416
|
+
|
417
|
+
<li class="public ">
|
418
|
+
<span class="summary_signature">
|
419
|
+
|
420
|
+
<a href="#_rgb-instance_method" title="#_rgb (instance method)">#<strong>_rgb</strong>(color) ⇒ Object </a>
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
</span>
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
<span class="summary_desc"><div class='inline'>
|
435
|
+
<p>Return a string like 'rgb(255, 255, 255)' `color` is 3 or 4
|
436
|
+
numbers.</p>
|
437
|
+
</div></span>
|
438
|
+
|
439
|
+
</li>
|
440
|
+
|
441
|
+
|
442
|
+
<li class="public ">
|
443
|
+
<span class="summary_signature">
|
444
|
+
|
445
|
+
<a href="#_rgba-instance_method" title="#_rgba (instance method)">#<strong>_rgba</strong>(color) ⇒ Object </a>
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
</span>
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
<span class="summary_desc"><div class='inline'>
|
460
|
+
<p>Return a string like 'rgba(255, 255, 255, 128)' `color` is 3 or 4
|
461
|
+
numbers.</p>
|
462
|
+
</div></span>
|
463
|
+
|
464
|
+
</li>
|
465
|
+
|
466
|
+
|
467
|
+
<li class="public ">
|
468
|
+
<span class="summary_signature">
|
469
|
+
|
470
|
+
<a href="#_rgba_ary-instance_method" title="#_rgba_ary (instance method)">#<strong>_rgba_ary</strong>(color) ⇒ Object </a>
|
471
|
+
|
472
|
+
|
473
|
+
|
474
|
+
</span>
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
|
484
|
+
<span class="summary_desc"><div class='inline'>
|
485
|
+
<p>Return an array like `[255, 255, 255, 128]`.</p>
|
486
|
+
</div></span>
|
487
|
+
|
488
|
+
</li>
|
489
|
+
|
490
|
+
|
491
|
+
<li class="public ">
|
492
|
+
<span class="summary_signature">
|
493
|
+
|
494
|
+
<a href="#box-instance_method" title="#box (instance method)">#<strong>box</strong>(x1, y1, x2, y2, color) ⇒ Object </a>
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
</span>
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
<span class="summary_desc"><div class='inline'>
|
509
|
+
<p>Draw a rectangle on this image.</p>
|
510
|
+
</div></span>
|
511
|
+
|
512
|
+
</li>
|
513
|
+
|
514
|
+
|
515
|
+
<li class="public ">
|
516
|
+
<span class="summary_signature">
|
517
|
+
|
518
|
+
<a href="#box_fill-instance_method" title="#box_fill (instance method)">#<strong>box_fill</strong>(x1, y1, x2, y2, color) ⇒ Object </a>
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
</span>
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
|
531
|
+
|
532
|
+
<span class="summary_desc"><div class='inline'>
|
533
|
+
<p>Draw a filled box on this image.</p>
|
534
|
+
</div></span>
|
535
|
+
|
536
|
+
</li>
|
537
|
+
|
538
|
+
|
539
|
+
<li class="public ">
|
540
|
+
<span class="summary_signature">
|
541
|
+
|
542
|
+
<a href="#circle-instance_method" title="#circle (instance method)">#<strong>circle</strong>(x, y, r, color) ⇒ Object </a>
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
</span>
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
|
556
|
+
<span class="summary_desc"><div class='inline'>
|
557
|
+
<p>Draw a circle on this image.</p>
|
558
|
+
</div></span>
|
559
|
+
|
560
|
+
</li>
|
561
|
+
|
562
|
+
|
563
|
+
<li class="public ">
|
564
|
+
<span class="summary_signature">
|
565
|
+
|
566
|
+
<a href="#circle_fill-instance_method" title="#circle_fill (instance method)">#<strong>circle_fill</strong>(x, y, r, color) ⇒ Object </a>
|
567
|
+
|
568
|
+
|
569
|
+
|
570
|
+
</span>
|
571
|
+
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
<span class="summary_desc"><div class='inline'>
|
581
|
+
<p>Draw a filled circle on this image.</p>
|
582
|
+
</div></span>
|
583
|
+
|
584
|
+
</li>
|
585
|
+
|
586
|
+
|
587
|
+
<li class="public ">
|
588
|
+
<span class="summary_signature">
|
589
|
+
|
590
|
+
<a href="#clear-instance_method" title="#clear (instance method)">#<strong>clear</strong> ⇒ Object </a>
|
591
|
+
|
592
|
+
|
593
|
+
|
594
|
+
</span>
|
595
|
+
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
|
604
|
+
<span class="summary_desc"><div class='inline'>
|
605
|
+
<p>Clear this image (i.e. fill with `[0,0,0,0]`).</p>
|
606
|
+
</div></span>
|
607
|
+
|
608
|
+
</li>
|
609
|
+
|
610
|
+
|
611
|
+
<li class="public ">
|
612
|
+
<span class="summary_signature">
|
613
|
+
|
614
|
+
<a href="#compare-instance_method" title="#compare (instance method)">#<strong>compare</strong>(x, y, color) ⇒ Object </a>
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
</span>
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
<span class="summary_desc"><div class='inline'>
|
629
|
+
<p>Return true if the pixel at `(x, y)` has the `color`.</p>
|
630
|
+
</div></span>
|
631
|
+
|
632
|
+
</li>
|
633
|
+
|
634
|
+
|
635
|
+
<li class="public ">
|
636
|
+
<span class="summary_signature">
|
637
|
+
|
638
|
+
<a href="#draw-instance_method" title="#draw (instance method)">#<strong>draw</strong>(x, y, image) ⇒ Object </a>
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
</span>
|
643
|
+
|
644
|
+
|
645
|
+
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
|
652
|
+
<span class="summary_desc"><div class='inline'>
|
653
|
+
<p>Draw an Image on this image.</p>
|
654
|
+
</div></span>
|
655
|
+
|
656
|
+
</li>
|
657
|
+
|
658
|
+
|
659
|
+
<li class="public ">
|
660
|
+
<span class="summary_signature">
|
661
|
+
|
662
|
+
<a href="#draw_ex-instance_method" title="#draw_ex (instance method)">#<strong>draw_ex</strong>(x, y, image, options = {}) ⇒ Object </a>
|
663
|
+
|
664
|
+
|
665
|
+
|
666
|
+
</span>
|
667
|
+
|
668
|
+
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
|
675
|
+
|
676
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
677
|
+
|
678
|
+
</li>
|
679
|
+
|
680
|
+
|
681
|
+
<li class="public ">
|
682
|
+
<span class="summary_signature">
|
683
|
+
|
684
|
+
<a href="#draw_font-instance_method" title="#draw_font (instance method)">#<strong>draw_font</strong>(x, y, string, font, color = [255,255,255]) ⇒ Object </a>
|
685
|
+
|
686
|
+
|
687
|
+
|
688
|
+
</span>
|
689
|
+
|
690
|
+
|
691
|
+
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
|
698
|
+
<span class="summary_desc"><div class='inline'>
|
699
|
+
<p>Draw some text on this image.</p>
|
700
|
+
</div></span>
|
701
|
+
|
702
|
+
</li>
|
703
|
+
|
704
|
+
|
705
|
+
<li class="public ">
|
706
|
+
<span class="summary_signature">
|
707
|
+
|
708
|
+
<a href="#draw_rot-instance_method" title="#draw_rot (instance method)">#<strong>draw_rot</strong>(x, y, image, angle, center_x = nil, center_y = nil) ⇒ Object </a>
|
709
|
+
|
710
|
+
|
711
|
+
|
712
|
+
</span>
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
|
721
|
+
|
722
|
+
<span class="summary_desc"><div class='inline'>
|
723
|
+
<p>Draw an Image on this image with rotation - angle: Rotation angle (radian)
|
724
|
+
- center_x, center_y: Rotation center in the `image` (default: center of
|
725
|
+
the `image`).</p>
|
726
|
+
</div></span>
|
727
|
+
|
728
|
+
</li>
|
729
|
+
|
730
|
+
|
731
|
+
<li class="public ">
|
732
|
+
<span class="summary_signature">
|
733
|
+
|
734
|
+
<a href="#fill-instance_method" title="#fill (instance method)">#<strong>fill</strong>(color) ⇒ Object </a>
|
735
|
+
|
736
|
+
|
737
|
+
|
738
|
+
</span>
|
739
|
+
|
740
|
+
|
741
|
+
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
|
747
|
+
|
748
|
+
<span class="summary_desc"><div class='inline'>
|
749
|
+
<p>Fill this image with `color`.</p>
|
750
|
+
</div></span>
|
751
|
+
|
752
|
+
</li>
|
753
|
+
|
754
|
+
|
755
|
+
<li class="public ">
|
756
|
+
<span class="summary_signature">
|
757
|
+
|
758
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(width, height, color = C_DEFAULT, canvas: nil) ⇒ Image </a>
|
759
|
+
|
760
|
+
|
761
|
+
|
762
|
+
</span>
|
763
|
+
|
764
|
+
|
765
|
+
<span class="note title constructor">constructor</span>
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
|
774
|
+
<span class="summary_desc"><div class='inline'>
|
775
|
+
<p>Create an instance of Image.</p>
|
776
|
+
</div></span>
|
777
|
+
|
778
|
+
</li>
|
779
|
+
|
780
|
+
|
781
|
+
<li class="public ">
|
782
|
+
<span class="summary_signature">
|
783
|
+
|
784
|
+
<a href="#line-instance_method" title="#line (instance method)">#<strong>line</strong>(x1, y1, x2, y2, color) ⇒ Object </a>
|
785
|
+
|
786
|
+
|
787
|
+
|
788
|
+
</span>
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
|
793
|
+
|
794
|
+
|
795
|
+
|
796
|
+
|
797
|
+
|
798
|
+
<span class="summary_desc"><div class='inline'>
|
799
|
+
<p>Draw a line on this image.</p>
|
800
|
+
</div></span>
|
801
|
+
|
802
|
+
</li>
|
803
|
+
|
804
|
+
|
805
|
+
<li class="public ">
|
806
|
+
<span class="summary_signature">
|
807
|
+
|
808
|
+
<a href="#slice-instance_method" title="#slice (instance method)">#<strong>slice</strong>(x, y, width, height) ⇒ Object </a>
|
809
|
+
|
810
|
+
|
811
|
+
|
812
|
+
</span>
|
813
|
+
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
|
818
|
+
|
819
|
+
|
820
|
+
|
821
|
+
|
822
|
+
<span class="summary_desc"><div class='inline'>
|
823
|
+
<p>Return an Image which is a copy of the specified area.</p>
|
824
|
+
</div></span>
|
825
|
+
|
826
|
+
</li>
|
827
|
+
|
828
|
+
|
829
|
+
<li class="public ">
|
830
|
+
<span class="summary_signature">
|
831
|
+
|
832
|
+
<a href="#slice_tiles-instance_method" title="#slice_tiles (instance method)">#<strong>slice_tiles</strong>(xcount, ycount) ⇒ Object </a>
|
833
|
+
|
834
|
+
|
835
|
+
|
836
|
+
</span>
|
837
|
+
|
838
|
+
|
839
|
+
|
840
|
+
|
841
|
+
|
842
|
+
|
843
|
+
|
844
|
+
|
845
|
+
|
846
|
+
<span class="summary_desc"><div class='inline'>
|
847
|
+
<p>Slice this image into xcount*ycount tiles.</p>
|
848
|
+
</div></span>
|
849
|
+
|
850
|
+
</li>
|
851
|
+
|
852
|
+
|
853
|
+
<li class="public ">
|
854
|
+
<span class="summary_signature">
|
855
|
+
|
856
|
+
<a href="#triangle-instance_method" title="#triangle (instance method)">#<strong>triangle</strong>(x1, y1, x2, y2, x3, y3, color) ⇒ Object </a>
|
857
|
+
|
858
|
+
|
859
|
+
|
860
|
+
</span>
|
861
|
+
|
862
|
+
|
863
|
+
|
864
|
+
|
865
|
+
|
866
|
+
|
867
|
+
|
868
|
+
|
869
|
+
|
870
|
+
<span class="summary_desc"><div class='inline'>
|
871
|
+
<p>Draw a triangle on this image.</p>
|
872
|
+
</div></span>
|
873
|
+
|
874
|
+
</li>
|
875
|
+
|
876
|
+
|
877
|
+
<li class="public ">
|
878
|
+
<span class="summary_signature">
|
879
|
+
|
880
|
+
<a href="#triangle_fill-instance_method" title="#triangle_fill (instance method)">#<strong>triangle_fill</strong>(x1, y1, x2, y2, x3, y3, color) ⇒ Object </a>
|
881
|
+
|
882
|
+
|
883
|
+
|
884
|
+
</span>
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
|
889
|
+
|
890
|
+
|
891
|
+
|
892
|
+
|
893
|
+
|
894
|
+
<span class="summary_desc"><div class='inline'>
|
895
|
+
<p>Draw a filled triangle on this image.</p>
|
896
|
+
</div></span>
|
897
|
+
|
898
|
+
</li>
|
899
|
+
|
900
|
+
|
901
|
+
</ul>
|
902
|
+
|
903
|
+
|
904
|
+
|
905
|
+
|
906
|
+
|
907
|
+
|
908
|
+
|
909
|
+
|
910
|
+
|
911
|
+
|
912
|
+
|
913
|
+
<h3 class="inherited">Methods inherited from <span class='object_link'><a href="RemoteResource.html" title="DXOpal::RemoteResource (class)">RemoteResource</a></span></h3>
|
914
|
+
<p class="inherited"><span class='object_link'><a href="RemoteResource.html#[]-class_method" title="DXOpal::RemoteResource.[] (method)">[]</a></span>, <span class='object_link'><a href="RemoteResource.html#_klass_name-class_method" title="DXOpal::RemoteResource._klass_name (method)">_klass_name</a></span>, <span class='object_link'><a href="RemoteResource.html#_load_resources-class_method" title="DXOpal::RemoteResource._load_resources (method)">_load_resources</a></span>, <span class='object_link'><a href="RemoteResource.html#add_class-class_method" title="DXOpal::RemoteResource.add_class (method)">add_class</a></span>, <span class='object_link'><a href="RemoteResource.html#register-class_method" title="DXOpal::RemoteResource.register (method)">register</a></span></p>
|
915
|
+
<div id="constructor_details" class="method_details_list">
|
916
|
+
<h2>Constructor Details</h2>
|
917
|
+
|
918
|
+
<div class="method_details first">
|
919
|
+
<h3 class="signature first" id="initialize-instance_method">
|
920
|
+
|
921
|
+
#<strong>initialize</strong>(width, height, color = C_DEFAULT, canvas: nil) ⇒ <tt><span class='object_link'><a href="" title="DXOpal::Image (class)">Image</a></span></tt>
|
922
|
+
|
923
|
+
|
924
|
+
|
925
|
+
|
926
|
+
|
927
|
+
</h3><div class="docstring">
|
928
|
+
<div class="discussion">
|
929
|
+
|
930
|
+
<p>Create an instance of Image</p>
|
931
|
+
|
932
|
+
|
933
|
+
</div>
|
934
|
+
</div>
|
935
|
+
<div class="tags">
|
936
|
+
|
937
|
+
|
938
|
+
</div><table class="source_code">
|
939
|
+
<tr>
|
940
|
+
<td>
|
941
|
+
<pre class="lines">
|
942
|
+
|
943
|
+
|
944
|
+
30
|
945
|
+
31
|
946
|
+
32
|
947
|
+
33
|
948
|
+
34
|
949
|
+
35
|
950
|
+
36</pre>
|
951
|
+
</td>
|
952
|
+
<td>
|
953
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 30</span>
|
954
|
+
|
955
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='op'>=</span><span class='const'>C_DEFAULT</span><span class='comma'>,</span> <span class='label'>canvas:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
956
|
+
<span class='ivar'>@width</span><span class='comma'>,</span> <span class='ivar'>@height</span> <span class='op'>=</span> <span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span>
|
957
|
+
<span class='ivar'>@canvas</span> <span class='op'>=</span> <span class='id identifier rubyid_canvas'>canvas</span> <span class='op'>||</span> <span class='backtick'>`</span><span class='tstring_content'>document.createElement("canvas")</span><span class='tstring_end'>`</span></span>
|
958
|
+
<span class='ivar'>@ctx</span> <span class='op'>=</span> <span class='backtick'>`</span><span class='embexpr_beg'>#{</span><span class='ivar'>@canvas</span><span class='embexpr_end'>}</span><span class='tstring_content'>.getContext('2d')</span><span class='tstring_end'>`</span></span>
|
959
|
+
<span class='id identifier rubyid__resize'>_resize</span><span class='lparen'>(</span><span class='ivar'>@width</span><span class='comma'>,</span> <span class='ivar'>@height</span><span class='rparen'>)</span>
|
960
|
+
<span class='id identifier rubyid_box_fill'>box_fill</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='ivar'>@width</span><span class='comma'>,</span> <span class='ivar'>@height</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
961
|
+
<span class='kw'>end</span></pre>
|
962
|
+
</td>
|
963
|
+
</tr>
|
964
|
+
</table>
|
965
|
+
</div>
|
966
|
+
|
967
|
+
</div>
|
968
|
+
|
969
|
+
<div id="instance_attr_details" class="attr_details">
|
970
|
+
<h2>Instance Attribute Details</h2>
|
971
|
+
|
972
|
+
|
973
|
+
<span id=""></span>
|
974
|
+
<div class="method_details first">
|
975
|
+
<h3 class="signature first" id="canvas-instance_method">
|
976
|
+
|
977
|
+
#<strong>canvas</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
978
|
+
|
979
|
+
|
980
|
+
|
981
|
+
|
982
|
+
|
983
|
+
</h3><div class="docstring">
|
984
|
+
<div class="discussion">
|
985
|
+
|
986
|
+
<p>Returns the value of attribute canvas</p>
|
987
|
+
|
988
|
+
|
989
|
+
</div>
|
990
|
+
</div>
|
991
|
+
<div class="tags">
|
992
|
+
|
993
|
+
|
994
|
+
</div><table class="source_code">
|
995
|
+
<tr>
|
996
|
+
<td>
|
997
|
+
<pre class="lines">
|
998
|
+
|
999
|
+
|
1000
|
+
37
|
1001
|
+
38
|
1002
|
+
39</pre>
|
1003
|
+
</td>
|
1004
|
+
<td>
|
1005
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 37</span>
|
1006
|
+
|
1007
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_canvas'>canvas</span>
|
1008
|
+
<span class='ivar'>@canvas</span>
|
1009
|
+
<span class='kw'>end</span></pre>
|
1010
|
+
</td>
|
1011
|
+
</tr>
|
1012
|
+
</table>
|
1013
|
+
</div>
|
1014
|
+
|
1015
|
+
|
1016
|
+
<span id=""></span>
|
1017
|
+
<div class="method_details ">
|
1018
|
+
<h3 class="signature " id="ctx-instance_method">
|
1019
|
+
|
1020
|
+
#<strong>ctx</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
1021
|
+
|
1022
|
+
|
1023
|
+
|
1024
|
+
|
1025
|
+
|
1026
|
+
</h3><div class="docstring">
|
1027
|
+
<div class="discussion">
|
1028
|
+
|
1029
|
+
<p>Returns the value of attribute ctx</p>
|
1030
|
+
|
1031
|
+
|
1032
|
+
</div>
|
1033
|
+
</div>
|
1034
|
+
<div class="tags">
|
1035
|
+
|
1036
|
+
|
1037
|
+
</div><table class="source_code">
|
1038
|
+
<tr>
|
1039
|
+
<td>
|
1040
|
+
<pre class="lines">
|
1041
|
+
|
1042
|
+
|
1043
|
+
37
|
1044
|
+
38
|
1045
|
+
39</pre>
|
1046
|
+
</td>
|
1047
|
+
<td>
|
1048
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 37</span>
|
1049
|
+
|
1050
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_ctx'>ctx</span>
|
1051
|
+
<span class='ivar'>@ctx</span>
|
1052
|
+
<span class='kw'>end</span></pre>
|
1053
|
+
</td>
|
1054
|
+
</tr>
|
1055
|
+
</table>
|
1056
|
+
</div>
|
1057
|
+
|
1058
|
+
|
1059
|
+
<span id=""></span>
|
1060
|
+
<div class="method_details ">
|
1061
|
+
<h3 class="signature " id="height-instance_method">
|
1062
|
+
|
1063
|
+
#<strong>height</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
1064
|
+
|
1065
|
+
|
1066
|
+
|
1067
|
+
|
1068
|
+
|
1069
|
+
</h3><div class="docstring">
|
1070
|
+
<div class="discussion">
|
1071
|
+
|
1072
|
+
<p>Returns the value of attribute height</p>
|
1073
|
+
|
1074
|
+
|
1075
|
+
</div>
|
1076
|
+
</div>
|
1077
|
+
<div class="tags">
|
1078
|
+
|
1079
|
+
|
1080
|
+
</div><table class="source_code">
|
1081
|
+
<tr>
|
1082
|
+
<td>
|
1083
|
+
<pre class="lines">
|
1084
|
+
|
1085
|
+
|
1086
|
+
37
|
1087
|
+
38
|
1088
|
+
39</pre>
|
1089
|
+
</td>
|
1090
|
+
<td>
|
1091
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 37</span>
|
1092
|
+
|
1093
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_height'>height</span>
|
1094
|
+
<span class='ivar'>@height</span>
|
1095
|
+
<span class='kw'>end</span></pre>
|
1096
|
+
</td>
|
1097
|
+
</tr>
|
1098
|
+
</table>
|
1099
|
+
</div>
|
1100
|
+
|
1101
|
+
|
1102
|
+
<span id=""></span>
|
1103
|
+
<div class="method_details ">
|
1104
|
+
<h3 class="signature " id="width-instance_method">
|
1105
|
+
|
1106
|
+
#<strong>width</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
1107
|
+
|
1108
|
+
|
1109
|
+
|
1110
|
+
|
1111
|
+
|
1112
|
+
</h3><div class="docstring">
|
1113
|
+
<div class="discussion">
|
1114
|
+
|
1115
|
+
<p>Returns the value of attribute width</p>
|
1116
|
+
|
1117
|
+
|
1118
|
+
</div>
|
1119
|
+
</div>
|
1120
|
+
<div class="tags">
|
1121
|
+
|
1122
|
+
|
1123
|
+
</div><table class="source_code">
|
1124
|
+
<tr>
|
1125
|
+
<td>
|
1126
|
+
<pre class="lines">
|
1127
|
+
|
1128
|
+
|
1129
|
+
37
|
1130
|
+
38
|
1131
|
+
39</pre>
|
1132
|
+
</td>
|
1133
|
+
<td>
|
1134
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 37</span>
|
1135
|
+
|
1136
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_width'>width</span>
|
1137
|
+
<span class='ivar'>@width</span>
|
1138
|
+
<span class='kw'>end</span></pre>
|
1139
|
+
</td>
|
1140
|
+
</tr>
|
1141
|
+
</table>
|
1142
|
+
</div>
|
1143
|
+
|
1144
|
+
</div>
|
1145
|
+
|
1146
|
+
|
1147
|
+
<div id="class_method_details" class="method_details_list">
|
1148
|
+
<h2>Class Method Details</h2>
|
1149
|
+
|
1150
|
+
|
1151
|
+
<div class="method_details first">
|
1152
|
+
<h3 class="signature first" id="_load-class_method">
|
1153
|
+
|
1154
|
+
.<strong>_load</strong>(path_or_url) ⇒ <tt>Object</tt>
|
1155
|
+
|
1156
|
+
|
1157
|
+
|
1158
|
+
|
1159
|
+
|
1160
|
+
</h3><div class="docstring">
|
1161
|
+
<div class="discussion">
|
1162
|
+
|
1163
|
+
<p>Load remote image (called via Window.load_resources)</p>
|
1164
|
+
|
1165
|
+
|
1166
|
+
</div>
|
1167
|
+
</div>
|
1168
|
+
<div class="tags">
|
1169
|
+
|
1170
|
+
|
1171
|
+
</div><table class="source_code">
|
1172
|
+
<tr>
|
1173
|
+
<td>
|
1174
|
+
<pre class="lines">
|
1175
|
+
|
1176
|
+
|
1177
|
+
8
|
1178
|
+
9
|
1179
|
+
10
|
1180
|
+
11
|
1181
|
+
12
|
1182
|
+
13
|
1183
|
+
14
|
1184
|
+
15
|
1185
|
+
16
|
1186
|
+
17
|
1187
|
+
18
|
1188
|
+
19
|
1189
|
+
20
|
1190
|
+
21
|
1191
|
+
22
|
1192
|
+
23
|
1193
|
+
24
|
1194
|
+
25
|
1195
|
+
26
|
1196
|
+
27</pre>
|
1197
|
+
</td>
|
1198
|
+
<td>
|
1199
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 8</span>
|
1200
|
+
|
1201
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__load'>_load</span><span class='lparen'>(</span><span class='id identifier rubyid_path_or_url'>path_or_url</span><span class='rparen'>)</span>
|
1202
|
+
<span class='id identifier rubyid_raw_img'>raw_img</span> <span class='op'>=</span> <span class='backtick'>`</span><span class='tstring_content'>new Image()</span><span class='tstring_end'>`</span></span>
|
1203
|
+
<span class='id identifier rubyid_img_promise'>img_promise</span> <span class='op'>=</span> <span class='backtick'>%x{</span><span class='tstring_content'>
|
1204
|
+
new Promise(function(resolve, reject) {
|
1205
|
+
raw_img.onload = function() {
|
1206
|
+
resolve(raw_img);
|
1207
|
+
};
|
1208
|
+
raw_img.src = path_or_url;
|
1209
|
+
});
|
1210
|
+
</span><span class='tstring_end'>}</span></span>
|
1211
|
+
|
1212
|
+
<span class='id identifier rubyid_img'>img</span> <span class='op'>=</span> <span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span><span class='rparen'>)</span>
|
1213
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1214
|
+
</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_img_promise'>img_promise</span><span class='embexpr_end'>}</span><span class='tstring_content'>.then(function(raw_img){
|
1215
|
+
img.$_resize(raw_img.width, raw_img.height);
|
1216
|
+
img.$_draw_raw_image(0, 0, raw_img);
|
1217
|
+
});
|
1218
|
+
</span><span class='tstring_end'>}</span></span>
|
1219
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_img'>img</span><span class='comma'>,</span> <span class='id identifier rubyid_img_promise'>img_promise</span>
|
1220
|
+
<span class='kw'>end</span></pre>
|
1221
|
+
</td>
|
1222
|
+
</tr>
|
1223
|
+
</table>
|
1224
|
+
</div>
|
1225
|
+
|
1226
|
+
</div>
|
1227
|
+
|
1228
|
+
<div id="instance_method_details" class="method_details_list">
|
1229
|
+
<h2>Instance Method Details</h2>
|
1230
|
+
|
1231
|
+
|
1232
|
+
<div class="method_details first">
|
1233
|
+
<h3 class="signature first" id="[]-instance_method">
|
1234
|
+
|
1235
|
+
#<strong>[]</strong>(x, y) ⇒ <tt>Object</tt>
|
1236
|
+
|
1237
|
+
|
1238
|
+
|
1239
|
+
|
1240
|
+
|
1241
|
+
</h3><div class="docstring">
|
1242
|
+
<div class="discussion">
|
1243
|
+
|
1244
|
+
<p>Get a pixel as ARGB array</p>
|
1245
|
+
|
1246
|
+
|
1247
|
+
</div>
|
1248
|
+
</div>
|
1249
|
+
<div class="tags">
|
1250
|
+
|
1251
|
+
|
1252
|
+
</div><table class="source_code">
|
1253
|
+
<tr>
|
1254
|
+
<td>
|
1255
|
+
<pre class="lines">
|
1256
|
+
|
1257
|
+
|
1258
|
+
97
|
1259
|
+
98
|
1260
|
+
99
|
1261
|
+
100
|
1262
|
+
101
|
1263
|
+
102
|
1264
|
+
103
|
1265
|
+
104
|
1266
|
+
105
|
1267
|
+
106</pre>
|
1268
|
+
</td>
|
1269
|
+
<td>
|
1270
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 97</span>
|
1271
|
+
|
1272
|
+
<span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span>
|
1273
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
1274
|
+
<span class='id identifier rubyid_ret'>ret</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
1275
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1276
|
+
var pixel = ctx.getImageData(x, y, 1, 1);
|
1277
|
+
var rgba = pixel.data;
|
1278
|
+
ret = [rgba[3], rgba[0], rgba[1], rgba[2]];
|
1279
|
+
</span><span class='tstring_end'>}</span></span>
|
1280
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_ret'>ret</span>
|
1281
|
+
<span class='kw'>end</span></pre>
|
1282
|
+
</td>
|
1283
|
+
</tr>
|
1284
|
+
</table>
|
1285
|
+
</div>
|
1286
|
+
|
1287
|
+
<div class="method_details ">
|
1288
|
+
<h3 class="signature " id="[]=-instance_method">
|
1289
|
+
|
1290
|
+
#<strong>[]=</strong>(x, y, color) ⇒ <tt>Object</tt>
|
1291
|
+
|
1292
|
+
|
1293
|
+
|
1294
|
+
|
1295
|
+
|
1296
|
+
</h3><div class="docstring">
|
1297
|
+
<div class="discussion">
|
1298
|
+
|
1299
|
+
<p>Put a pixel on this image</p>
|
1300
|
+
|
1301
|
+
|
1302
|
+
</div>
|
1303
|
+
</div>
|
1304
|
+
<div class="tags">
|
1305
|
+
|
1306
|
+
|
1307
|
+
</div><table class="source_code">
|
1308
|
+
<tr>
|
1309
|
+
<td>
|
1310
|
+
<pre class="lines">
|
1311
|
+
|
1312
|
+
|
1313
|
+
109
|
1314
|
+
110
|
1315
|
+
111</pre>
|
1316
|
+
</td>
|
1317
|
+
<td>
|
1318
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 109</span>
|
1319
|
+
|
1320
|
+
<span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1321
|
+
<span class='id identifier rubyid_box_fill'>box_fill</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1322
|
+
<span class='kw'>end</span></pre>
|
1323
|
+
</td>
|
1324
|
+
</tr>
|
1325
|
+
</table>
|
1326
|
+
</div>
|
1327
|
+
|
1328
|
+
<div class="method_details ">
|
1329
|
+
<h3 class="signature " id="_draw_raw_image-instance_method">
|
1330
|
+
|
1331
|
+
#<strong>_draw_raw_image</strong>(x, y, raw_img) ⇒ <tt>Object</tt>
|
1332
|
+
|
1333
|
+
|
1334
|
+
|
1335
|
+
|
1336
|
+
|
1337
|
+
</h3><div class="docstring">
|
1338
|
+
<div class="discussion">
|
1339
|
+
|
1340
|
+
<p>Copy an <img> onto this image</p>
|
1341
|
+
|
1342
|
+
|
1343
|
+
</div>
|
1344
|
+
</div>
|
1345
|
+
<div class="tags">
|
1346
|
+
|
1347
|
+
|
1348
|
+
</div><table class="source_code">
|
1349
|
+
<tr>
|
1350
|
+
<td>
|
1351
|
+
<pre class="lines">
|
1352
|
+
|
1353
|
+
|
1354
|
+
250
|
1355
|
+
251
|
1356
|
+
252
|
1357
|
+
253
|
1358
|
+
254</pre>
|
1359
|
+
</td>
|
1360
|
+
<td>
|
1361
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 250</span>
|
1362
|
+
|
1363
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__draw_raw_image'>_draw_raw_image</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_raw_img'>raw_img</span><span class='rparen'>)</span>
|
1364
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1365
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.drawImage(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_raw_img'>raw_img</span><span class='embexpr_end'>}</span><span class='tstring_content'>, x, y)
|
1366
|
+
</span><span class='tstring_end'>}</span></span>
|
1367
|
+
<span class='kw'>end</span></pre>
|
1368
|
+
</td>
|
1369
|
+
</tr>
|
1370
|
+
</table>
|
1371
|
+
</div>
|
1372
|
+
|
1373
|
+
<div class="method_details ">
|
1374
|
+
<h3 class="signature " id="_image_data-instance_method">
|
1375
|
+
|
1376
|
+
#<strong>_image_data</strong>(x = 0, y = 0, w = @width, h = @height) ⇒ <tt>Object</tt>
|
1377
|
+
|
1378
|
+
|
1379
|
+
|
1380
|
+
|
1381
|
+
|
1382
|
+
</h3><div class="docstring">
|
1383
|
+
<div class="discussion">
|
1384
|
+
|
1385
|
+
<p>Return .getImageData</p>
|
1386
|
+
|
1387
|
+
|
1388
|
+
</div>
|
1389
|
+
</div>
|
1390
|
+
<div class="tags">
|
1391
|
+
|
1392
|
+
|
1393
|
+
</div><table class="source_code">
|
1394
|
+
<tr>
|
1395
|
+
<td>
|
1396
|
+
<pre class="lines">
|
1397
|
+
|
1398
|
+
|
1399
|
+
257
|
1400
|
+
258
|
1401
|
+
259</pre>
|
1402
|
+
</td>
|
1403
|
+
<td>
|
1404
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 257</span>
|
1405
|
+
|
1406
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__image_data'>_image_data</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='op'>=</span><span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='op'>=</span><span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_w'>w</span><span class='op'>=</span><span class='ivar'>@width</span><span class='comma'>,</span> <span class='id identifier rubyid_h'>h</span><span class='op'>=</span><span class='ivar'>@height</span><span class='rparen'>)</span>
|
1407
|
+
<span class='kw'>return</span> <span class='backtick'>`</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.getImageData(x, y, w, h)</span><span class='tstring_end'>`</span></span>
|
1408
|
+
<span class='kw'>end</span></pre>
|
1409
|
+
</td>
|
1410
|
+
</tr>
|
1411
|
+
</table>
|
1412
|
+
</div>
|
1413
|
+
|
1414
|
+
<div class="method_details ">
|
1415
|
+
<h3 class="signature " id="_put_image_data-instance_method">
|
1416
|
+
|
1417
|
+
#<strong>_put_image_data</strong>(image_data, x, y) ⇒ <tt>Object</tt>
|
1418
|
+
|
1419
|
+
|
1420
|
+
|
1421
|
+
|
1422
|
+
|
1423
|
+
</h3><div class="docstring">
|
1424
|
+
<div class="discussion">
|
1425
|
+
|
1426
|
+
<p>Call .putImageData</p>
|
1427
|
+
|
1428
|
+
|
1429
|
+
</div>
|
1430
|
+
</div>
|
1431
|
+
<div class="tags">
|
1432
|
+
|
1433
|
+
|
1434
|
+
</div><table class="source_code">
|
1435
|
+
<tr>
|
1436
|
+
<td>
|
1437
|
+
<pre class="lines">
|
1438
|
+
|
1439
|
+
|
1440
|
+
262
|
1441
|
+
263
|
1442
|
+
264</pre>
|
1443
|
+
</td>
|
1444
|
+
<td>
|
1445
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 262</span>
|
1446
|
+
|
1447
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__put_image_data'>_put_image_data</span><span class='lparen'>(</span><span class='id identifier rubyid_image_data'>image_data</span><span class='comma'>,</span> <span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='rparen'>)</span>
|
1448
|
+
<span class='backtick'>`</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.putImageData(image_data, x, y)</span><span class='tstring_end'>`</span></span>
|
1449
|
+
<span class='kw'>end</span></pre>
|
1450
|
+
</td>
|
1451
|
+
</tr>
|
1452
|
+
</table>
|
1453
|
+
</div>
|
1454
|
+
|
1455
|
+
<div class="method_details ">
|
1456
|
+
<h3 class="signature " id="_resize-instance_method">
|
1457
|
+
|
1458
|
+
#<strong>_resize</strong>(w, h) ⇒ <tt>Object</tt>
|
1459
|
+
|
1460
|
+
|
1461
|
+
|
1462
|
+
|
1463
|
+
|
1464
|
+
</h3><div class="docstring">
|
1465
|
+
<div class="discussion">
|
1466
|
+
|
1467
|
+
<p>Set size of this image</p>
|
1468
|
+
|
1469
|
+
|
1470
|
+
</div>
|
1471
|
+
</div>
|
1472
|
+
<div class="tags">
|
1473
|
+
|
1474
|
+
|
1475
|
+
</div><table class="source_code">
|
1476
|
+
<tr>
|
1477
|
+
<td>
|
1478
|
+
<pre class="lines">
|
1479
|
+
|
1480
|
+
|
1481
|
+
40
|
1482
|
+
41
|
1483
|
+
42
|
1484
|
+
43
|
1485
|
+
44
|
1486
|
+
45
|
1487
|
+
46</pre>
|
1488
|
+
</td>
|
1489
|
+
<td>
|
1490
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 40</span>
|
1491
|
+
|
1492
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__resize'>_resize</span><span class='lparen'>(</span><span class='id identifier rubyid_w'>w</span><span class='comma'>,</span> <span class='id identifier rubyid_h'>h</span><span class='rparen'>)</span>
|
1493
|
+
<span class='ivar'>@width</span><span class='comma'>,</span> <span class='ivar'>@height</span> <span class='op'>=</span> <span class='id identifier rubyid_w'>w</span><span class='comma'>,</span> <span class='id identifier rubyid_h'>h</span>
|
1494
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1495
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@canvas</span><span class='embexpr_end'>}</span><span class='tstring_content'>.width = w;
|
1496
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@canvas</span><span class='embexpr_end'>}</span><span class='tstring_content'>.height = h;
|
1497
|
+
</span><span class='tstring_end'>}</span></span>
|
1498
|
+
<span class='kw'>end</span></pre>
|
1499
|
+
</td>
|
1500
|
+
</tr>
|
1501
|
+
</table>
|
1502
|
+
</div>
|
1503
|
+
|
1504
|
+
<div class="method_details ">
|
1505
|
+
<h3 class="signature " id="_rgb-instance_method">
|
1506
|
+
|
1507
|
+
#<strong>_rgb</strong>(color) ⇒ <tt>Object</tt>
|
1508
|
+
|
1509
|
+
|
1510
|
+
|
1511
|
+
|
1512
|
+
|
1513
|
+
</h3><div class="docstring">
|
1514
|
+
<div class="discussion">
|
1515
|
+
|
1516
|
+
<p>Return a string like 'rgb(255, 255, 255)' `color` is 3 or 4 numbers</p>
|
1517
|
+
|
1518
|
+
|
1519
|
+
</div>
|
1520
|
+
</div>
|
1521
|
+
<div class="tags">
|
1522
|
+
|
1523
|
+
|
1524
|
+
</div><table class="source_code">
|
1525
|
+
<tr>
|
1526
|
+
<td>
|
1527
|
+
<pre class="lines">
|
1528
|
+
|
1529
|
+
|
1530
|
+
268
|
1531
|
+
269
|
1532
|
+
270
|
1533
|
+
271
|
1534
|
+
272
|
1535
|
+
273
|
1536
|
+
274
|
1537
|
+
275
|
1538
|
+
276
|
1539
|
+
277
|
1540
|
+
278
|
1541
|
+
279</pre>
|
1542
|
+
</td>
|
1543
|
+
<td>
|
1544
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 268</span>
|
1545
|
+
|
1546
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__rgb'>_rgb</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1547
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
1548
|
+
<span class='kw'>when</span> <span class='int'>4</span>
|
1549
|
+
<span class='comment'># Just ignore alpha
|
1550
|
+
</span> <span class='id identifier rubyid_rgb'>rgb</span> <span class='op'>=</span> <span class='id identifier rubyid_color'>color</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>3</span><span class='rbracket'>]</span>
|
1551
|
+
<span class='kw'>when</span> <span class='int'>3</span>
|
1552
|
+
<span class='id identifier rubyid_rgb'>rgb</span> <span class='op'>=</span> <span class='id identifier rubyid_color'>color</span>
|
1553
|
+
<span class='kw'>else</span>
|
1554
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>invalid color: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
1555
|
+
<span class='kw'>end</span>
|
1556
|
+
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>rgb(</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='id identifier rubyid_rgb'>rgb</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>, </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span><span class='semicolon'>;</span>
|
1557
|
+
<span class='kw'>end</span></pre>
|
1558
|
+
</td>
|
1559
|
+
</tr>
|
1560
|
+
</table>
|
1561
|
+
</div>
|
1562
|
+
|
1563
|
+
<div class="method_details ">
|
1564
|
+
<h3 class="signature " id="_rgba-instance_method">
|
1565
|
+
|
1566
|
+
#<strong>_rgba</strong>(color) ⇒ <tt>Object</tt>
|
1567
|
+
|
1568
|
+
|
1569
|
+
|
1570
|
+
|
1571
|
+
|
1572
|
+
</h3><div class="docstring">
|
1573
|
+
<div class="discussion">
|
1574
|
+
|
1575
|
+
<p>Return a string like 'rgba(255, 255, 255, 128)' `color` is 3 or 4
|
1576
|
+
numbers</p>
|
1577
|
+
|
1578
|
+
|
1579
|
+
</div>
|
1580
|
+
</div>
|
1581
|
+
<div class="tags">
|
1582
|
+
|
1583
|
+
|
1584
|
+
</div><table class="source_code">
|
1585
|
+
<tr>
|
1586
|
+
<td>
|
1587
|
+
<pre class="lines">
|
1588
|
+
|
1589
|
+
|
1590
|
+
283
|
1591
|
+
284
|
1592
|
+
285</pre>
|
1593
|
+
</td>
|
1594
|
+
<td>
|
1595
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 283</span>
|
1596
|
+
|
1597
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1598
|
+
<span class='kw'>return</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>rgba(</span><span class='tstring_end'>"</span></span> <span class='op'>+</span> <span class='id identifier rubyid__rgba_ary'>_rgba_ary</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>, </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>)</span><span class='tstring_end'>"</span></span>
|
1599
|
+
<span class='kw'>end</span></pre>
|
1600
|
+
</td>
|
1601
|
+
</tr>
|
1602
|
+
</table>
|
1603
|
+
</div>
|
1604
|
+
|
1605
|
+
<div class="method_details ">
|
1606
|
+
<h3 class="signature " id="_rgba_ary-instance_method">
|
1607
|
+
|
1608
|
+
#<strong>_rgba_ary</strong>(color) ⇒ <tt>Object</tt>
|
1609
|
+
|
1610
|
+
|
1611
|
+
|
1612
|
+
|
1613
|
+
|
1614
|
+
</h3><div class="docstring">
|
1615
|
+
<div class="discussion">
|
1616
|
+
|
1617
|
+
<p>Return an array like `[255, 255, 255, 128]`</p>
|
1618
|
+
|
1619
|
+
|
1620
|
+
</div>
|
1621
|
+
</div>
|
1622
|
+
<div class="tags">
|
1623
|
+
|
1624
|
+
|
1625
|
+
</div><table class="source_code">
|
1626
|
+
<tr>
|
1627
|
+
<td>
|
1628
|
+
<pre class="lines">
|
1629
|
+
|
1630
|
+
|
1631
|
+
288
|
1632
|
+
289
|
1633
|
+
290
|
1634
|
+
291
|
1635
|
+
292
|
1636
|
+
293
|
1637
|
+
294
|
1638
|
+
295
|
1639
|
+
296
|
1640
|
+
297
|
1641
|
+
298
|
1642
|
+
299</pre>
|
1643
|
+
</td>
|
1644
|
+
<td>
|
1645
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 288</span>
|
1646
|
+
|
1647
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__rgba_ary'>_rgba_ary</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1648
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
1649
|
+
<span class='kw'>when</span> <span class='int'>4</span>
|
1650
|
+
<span class='comment'># color is ARGB in DXRuby, so move A to the last
|
1651
|
+
</span> <span class='id identifier rubyid_color'>color</span><span class='lbracket'>[</span><span class='int'>1</span><span class='comma'>,</span> <span class='int'>3</span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='id identifier rubyid_color'>color</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='op'>/</span><span class='float'>255.0</span><span class='rbracket'>]</span>
|
1652
|
+
<span class='kw'>when</span> <span class='int'>3</span>
|
1653
|
+
<span class='comment'># Complement 255 as alpha
|
1654
|
+
</span> <span class='id identifier rubyid_color'>color</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='float'>1.0</span><span class='rbracket'>]</span>
|
1655
|
+
<span class='kw'>else</span>
|
1656
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>invalid color: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_color'>color</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
1657
|
+
<span class='kw'>end</span>
|
1658
|
+
<span class='kw'>end</span></pre>
|
1659
|
+
</td>
|
1660
|
+
</tr>
|
1661
|
+
</table>
|
1662
|
+
</div>
|
1663
|
+
|
1664
|
+
<div class="method_details ">
|
1665
|
+
<h3 class="signature " id="box-instance_method">
|
1666
|
+
|
1667
|
+
#<strong>box</strong>(x1, y1, x2, y2, color) ⇒ <tt>Object</tt>
|
1668
|
+
|
1669
|
+
|
1670
|
+
|
1671
|
+
|
1672
|
+
|
1673
|
+
</h3><div class="docstring">
|
1674
|
+
<div class="discussion">
|
1675
|
+
|
1676
|
+
<p>Draw a rectangle on this image</p>
|
1677
|
+
|
1678
|
+
|
1679
|
+
</div>
|
1680
|
+
</div>
|
1681
|
+
<div class="tags">
|
1682
|
+
|
1683
|
+
|
1684
|
+
</div><table class="source_code">
|
1685
|
+
<tr>
|
1686
|
+
<td>
|
1687
|
+
<pre class="lines">
|
1688
|
+
|
1689
|
+
|
1690
|
+
145
|
1691
|
+
146
|
1692
|
+
147
|
1693
|
+
148
|
1694
|
+
149
|
1695
|
+
150
|
1696
|
+
151
|
1697
|
+
152
|
1698
|
+
153
|
1699
|
+
154</pre>
|
1700
|
+
</td>
|
1701
|
+
<td>
|
1702
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 145</span>
|
1703
|
+
|
1704
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_box'>box</span><span class='lparen'>(</span><span class='id identifier rubyid_x1'>x1</span><span class='comma'>,</span> <span class='id identifier rubyid_y1'>y1</span><span class='comma'>,</span> <span class='id identifier rubyid_x2'>x2</span><span class='comma'>,</span> <span class='id identifier rubyid_y2'>y2</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1705
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
1706
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1707
|
+
ctx.beginPath();
|
1708
|
+
ctx.strokeStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
1709
|
+
ctx.rect(x1, y1, x2-x1+1, y2-y1+1);
|
1710
|
+
ctx.stroke();
|
1711
|
+
</span><span class='tstring_end'>}</span></span>
|
1712
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
1713
|
+
<span class='kw'>end</span></pre>
|
1714
|
+
</td>
|
1715
|
+
</tr>
|
1716
|
+
</table>
|
1717
|
+
</div>
|
1718
|
+
|
1719
|
+
<div class="method_details ">
|
1720
|
+
<h3 class="signature " id="box_fill-instance_method">
|
1721
|
+
|
1722
|
+
#<strong>box_fill</strong>(x1, y1, x2, y2, color) ⇒ <tt>Object</tt>
|
1723
|
+
|
1724
|
+
|
1725
|
+
|
1726
|
+
|
1727
|
+
|
1728
|
+
</h3><div class="docstring">
|
1729
|
+
<div class="discussion">
|
1730
|
+
|
1731
|
+
<p>Draw a filled box on this image</p>
|
1732
|
+
|
1733
|
+
|
1734
|
+
</div>
|
1735
|
+
</div>
|
1736
|
+
<div class="tags">
|
1737
|
+
|
1738
|
+
|
1739
|
+
</div><table class="source_code">
|
1740
|
+
<tr>
|
1741
|
+
<td>
|
1742
|
+
<pre class="lines">
|
1743
|
+
|
1744
|
+
|
1745
|
+
157
|
1746
|
+
158
|
1747
|
+
159
|
1748
|
+
160
|
1749
|
+
161
|
1750
|
+
162
|
1751
|
+
163
|
1752
|
+
164
|
1753
|
+
165</pre>
|
1754
|
+
</td>
|
1755
|
+
<td>
|
1756
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 157</span>
|
1757
|
+
|
1758
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_box_fill'>box_fill</span><span class='lparen'>(</span><span class='id identifier rubyid_x1'>x1</span><span class='comma'>,</span> <span class='id identifier rubyid_y1'>y1</span><span class='comma'>,</span> <span class='id identifier rubyid_x2'>x2</span><span class='comma'>,</span> <span class='id identifier rubyid_y2'>y2</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1759
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
1760
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1761
|
+
ctx.beginPath();
|
1762
|
+
ctx.fillStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
1763
|
+
ctx.fillRect(x1, y1, x2-x1+1, y2-y1+1);
|
1764
|
+
</span><span class='tstring_end'>}</span></span>
|
1765
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
1766
|
+
<span class='kw'>end</span></pre>
|
1767
|
+
</td>
|
1768
|
+
</tr>
|
1769
|
+
</table>
|
1770
|
+
</div>
|
1771
|
+
|
1772
|
+
<div class="method_details ">
|
1773
|
+
<h3 class="signature " id="circle-instance_method">
|
1774
|
+
|
1775
|
+
#<strong>circle</strong>(x, y, r, color) ⇒ <tt>Object</tt>
|
1776
|
+
|
1777
|
+
|
1778
|
+
|
1779
|
+
|
1780
|
+
|
1781
|
+
</h3><div class="docstring">
|
1782
|
+
<div class="discussion">
|
1783
|
+
|
1784
|
+
<p>Draw a circle on this image</p>
|
1785
|
+
|
1786
|
+
|
1787
|
+
</div>
|
1788
|
+
</div>
|
1789
|
+
<div class="tags">
|
1790
|
+
|
1791
|
+
|
1792
|
+
</div><table class="source_code">
|
1793
|
+
<tr>
|
1794
|
+
<td>
|
1795
|
+
<pre class="lines">
|
1796
|
+
|
1797
|
+
|
1798
|
+
168
|
1799
|
+
169
|
1800
|
+
170
|
1801
|
+
171
|
1802
|
+
172
|
1803
|
+
173
|
1804
|
+
174
|
1805
|
+
175
|
1806
|
+
176
|
1807
|
+
177</pre>
|
1808
|
+
</td>
|
1809
|
+
<td>
|
1810
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 168</span>
|
1811
|
+
|
1812
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_circle'>circle</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1813
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
1814
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1815
|
+
ctx.beginPath();
|
1816
|
+
ctx.strokeStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
1817
|
+
ctx.arc(x, y, r, 0, Math.PI*2, false)
|
1818
|
+
ctx.stroke();
|
1819
|
+
</span><span class='tstring_end'>}</span></span>
|
1820
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
1821
|
+
<span class='kw'>end</span></pre>
|
1822
|
+
</td>
|
1823
|
+
</tr>
|
1824
|
+
</table>
|
1825
|
+
</div>
|
1826
|
+
|
1827
|
+
<div class="method_details ">
|
1828
|
+
<h3 class="signature " id="circle_fill-instance_method">
|
1829
|
+
|
1830
|
+
#<strong>circle_fill</strong>(x, y, r, color) ⇒ <tt>Object</tt>
|
1831
|
+
|
1832
|
+
|
1833
|
+
|
1834
|
+
|
1835
|
+
|
1836
|
+
</h3><div class="docstring">
|
1837
|
+
<div class="discussion">
|
1838
|
+
|
1839
|
+
<p>Draw a filled circle on this image</p>
|
1840
|
+
|
1841
|
+
|
1842
|
+
</div>
|
1843
|
+
</div>
|
1844
|
+
<div class="tags">
|
1845
|
+
|
1846
|
+
|
1847
|
+
</div><table class="source_code">
|
1848
|
+
<tr>
|
1849
|
+
<td>
|
1850
|
+
<pre class="lines">
|
1851
|
+
|
1852
|
+
|
1853
|
+
180
|
1854
|
+
181
|
1855
|
+
182
|
1856
|
+
183
|
1857
|
+
184
|
1858
|
+
185
|
1859
|
+
186
|
1860
|
+
187
|
1861
|
+
188
|
1862
|
+
189</pre>
|
1863
|
+
</td>
|
1864
|
+
<td>
|
1865
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 180</span>
|
1866
|
+
|
1867
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_circle_fill'>circle_fill</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_r'>r</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1868
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
1869
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1870
|
+
ctx.beginPath();
|
1871
|
+
ctx.fillStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
1872
|
+
ctx.arc(x, y, r, 0, Math.PI*2, false)
|
1873
|
+
ctx.fill();
|
1874
|
+
</span><span class='tstring_end'>}</span></span>
|
1875
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
1876
|
+
<span class='kw'>end</span></pre>
|
1877
|
+
</td>
|
1878
|
+
</tr>
|
1879
|
+
</table>
|
1880
|
+
</div>
|
1881
|
+
|
1882
|
+
<div class="method_details ">
|
1883
|
+
<h3 class="signature " id="clear-instance_method">
|
1884
|
+
|
1885
|
+
#<strong>clear</strong> ⇒ <tt>Object</tt>
|
1886
|
+
|
1887
|
+
|
1888
|
+
|
1889
|
+
|
1890
|
+
|
1891
|
+
</h3><div class="docstring">
|
1892
|
+
<div class="discussion">
|
1893
|
+
|
1894
|
+
<p>Clear this image (i.e. fill with `[0,0,0,0]`)</p>
|
1895
|
+
|
1896
|
+
|
1897
|
+
</div>
|
1898
|
+
</div>
|
1899
|
+
<div class="tags">
|
1900
|
+
|
1901
|
+
|
1902
|
+
</div><table class="source_code">
|
1903
|
+
<tr>
|
1904
|
+
<td>
|
1905
|
+
<pre class="lines">
|
1906
|
+
|
1907
|
+
|
1908
|
+
226
|
1909
|
+
227
|
1910
|
+
228</pre>
|
1911
|
+
</td>
|
1912
|
+
<td>
|
1913
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 226</span>
|
1914
|
+
|
1915
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_clear'>clear</span>
|
1916
|
+
<span class='id identifier rubyid_fill'>fill</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
1917
|
+
<span class='kw'>end</span></pre>
|
1918
|
+
</td>
|
1919
|
+
</tr>
|
1920
|
+
</table>
|
1921
|
+
</div>
|
1922
|
+
|
1923
|
+
<div class="method_details ">
|
1924
|
+
<h3 class="signature " id="compare-instance_method">
|
1925
|
+
|
1926
|
+
#<strong>compare</strong>(x, y, color) ⇒ <tt>Object</tt>
|
1927
|
+
|
1928
|
+
|
1929
|
+
|
1930
|
+
|
1931
|
+
|
1932
|
+
</h3><div class="docstring">
|
1933
|
+
<div class="discussion">
|
1934
|
+
|
1935
|
+
<p>Return true if the pixel at `(x, y)` has the `color`</p>
|
1936
|
+
|
1937
|
+
|
1938
|
+
</div>
|
1939
|
+
</div>
|
1940
|
+
<div class="tags">
|
1941
|
+
|
1942
|
+
|
1943
|
+
</div><table class="source_code">
|
1944
|
+
<tr>
|
1945
|
+
<td>
|
1946
|
+
<pre class="lines">
|
1947
|
+
|
1948
|
+
|
1949
|
+
114
|
1950
|
+
115
|
1951
|
+
116
|
1952
|
+
117
|
1953
|
+
118
|
1954
|
+
119
|
1955
|
+
120
|
1956
|
+
121
|
1957
|
+
122
|
1958
|
+
123
|
1959
|
+
124
|
1960
|
+
125
|
1961
|
+
126
|
1962
|
+
127
|
1963
|
+
128
|
1964
|
+
129</pre>
|
1965
|
+
</td>
|
1966
|
+
<td>
|
1967
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 114</span>
|
1968
|
+
|
1969
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_compare'>compare</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1970
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
1971
|
+
<span class='id identifier rubyid_rgba1'>rgba1</span> <span class='op'>=</span> <span class='id identifier rubyid__rgba_ary'>_rgba_ary</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
1972
|
+
<span class='id identifier rubyid_rgba2'>rgba2</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
1973
|
+
<span class='id identifier rubyid_ret'>ret</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
1974
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
1975
|
+
var pixel = ctx.getImageData(x, y, 1, 1);
|
1976
|
+
rgba2 = pixel.data;
|
1977
|
+
// TODO: what is the right way to compare an Array and an Uint8ClampedArray?
|
1978
|
+
ret = rgba1[0] == rgba2[0] &&
|
1979
|
+
rgba1[1] == rgba2[1] &&
|
1980
|
+
rgba1[2] == rgba2[2] &&
|
1981
|
+
rgba1[3] == rgba2[3]
|
1982
|
+
</span><span class='tstring_end'>}</span></span>
|
1983
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_ret'>ret</span>
|
1984
|
+
<span class='kw'>end</span></pre>
|
1985
|
+
</td>
|
1986
|
+
</tr>
|
1987
|
+
</table>
|
1988
|
+
</div>
|
1989
|
+
|
1990
|
+
<div class="method_details ">
|
1991
|
+
<h3 class="signature " id="draw-instance_method">
|
1992
|
+
|
1993
|
+
#<strong>draw</strong>(x, y, image) ⇒ <tt>Object</tt>
|
1994
|
+
|
1995
|
+
|
1996
|
+
|
1997
|
+
|
1998
|
+
|
1999
|
+
</h3><div class="docstring">
|
2000
|
+
<div class="discussion">
|
2001
|
+
|
2002
|
+
<p>Draw an Image on this image</p>
|
2003
|
+
|
2004
|
+
|
2005
|
+
</div>
|
2006
|
+
</div>
|
2007
|
+
<div class="tags">
|
2008
|
+
|
2009
|
+
|
2010
|
+
</div><table class="source_code">
|
2011
|
+
<tr>
|
2012
|
+
<td>
|
2013
|
+
<pre class="lines">
|
2014
|
+
|
2015
|
+
|
2016
|
+
49
|
2017
|
+
50
|
2018
|
+
51
|
2019
|
+
52
|
2020
|
+
53
|
2021
|
+
54</pre>
|
2022
|
+
</td>
|
2023
|
+
<td>
|
2024
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 49</span>
|
2025
|
+
|
2026
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_draw'>draw</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_image'>image</span><span class='rparen'>)</span>
|
2027
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
2028
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.drawImage(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_image'>image</span><span class='period'>.</span><span class='id identifier rubyid_canvas'>canvas</span><span class='embexpr_end'>}</span><span class='tstring_content'>, x, y);
|
2029
|
+
</span><span class='tstring_end'>}</span></span>
|
2030
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
2031
|
+
<span class='kw'>end</span></pre>
|
2032
|
+
</td>
|
2033
|
+
</tr>
|
2034
|
+
</table>
|
2035
|
+
</div>
|
2036
|
+
|
2037
|
+
<div class="method_details ">
|
2038
|
+
<h3 class="signature " id="draw_ex-instance_method">
|
2039
|
+
|
2040
|
+
#<strong>draw_ex</strong>(x, y, image, options = {}) ⇒ <tt>Object</tt>
|
2041
|
+
|
2042
|
+
|
2043
|
+
|
2044
|
+
|
2045
|
+
|
2046
|
+
</h3><table class="source_code">
|
2047
|
+
<tr>
|
2048
|
+
<td>
|
2049
|
+
<pre class="lines">
|
2050
|
+
|
2051
|
+
|
2052
|
+
63
|
2053
|
+
64
|
2054
|
+
65
|
2055
|
+
66
|
2056
|
+
67
|
2057
|
+
68
|
2058
|
+
69
|
2059
|
+
70
|
2060
|
+
71
|
2061
|
+
72
|
2062
|
+
73
|
2063
|
+
74
|
2064
|
+
75
|
2065
|
+
76
|
2066
|
+
77
|
2067
|
+
78
|
2068
|
+
79
|
2069
|
+
80
|
2070
|
+
81
|
2071
|
+
82</pre>
|
2072
|
+
</td>
|
2073
|
+
<td>
|
2074
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 63</span>
|
2075
|
+
|
2076
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_draw_ex'>draw_ex</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_image'>image</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
2077
|
+
<span class='id identifier rubyid_scale_x'>scale_x</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:scale_x</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span>
|
2078
|
+
<span class='id identifier rubyid_scale_y'>scale_y</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:scale_y</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>1</span>
|
2079
|
+
<span class='id identifier rubyid_center_x'>center_x</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:center_x</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_image'>image</span><span class='period'>.</span><span class='id identifier rubyid_width'>width</span><span class='op'>/</span><span class='int'>2</span>
|
2080
|
+
<span class='id identifier rubyid_center_y'>center_y</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:center_y</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_image'>image</span><span class='period'>.</span><span class='id identifier rubyid_height'>height</span><span class='op'>/</span><span class='int'>2</span>
|
2081
|
+
<span class='comment'># TODO: alpha
|
2082
|
+
</span> <span class='comment'># TODO: blend
|
2083
|
+
</span> <span class='id identifier rubyid_angle'>angle</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:angle</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='int'>0</span>
|
2084
|
+
|
2085
|
+
<span class='id identifier rubyid_cx'>cx</span> <span class='op'>=</span> <span class='id identifier rubyid_x'>x</span> <span class='op'>+</span> <span class='id identifier rubyid_center_x'>center_x</span>
|
2086
|
+
<span class='id identifier rubyid_cy'>cy</span> <span class='op'>=</span> <span class='id identifier rubyid_y'>y</span> <span class='op'>+</span> <span class='id identifier rubyid_center_y'>center_y</span>
|
2087
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
2088
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.translate(cx, cy);
|
2089
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.rotate(angle * Math.PI / 180.0);
|
2090
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.scale(scale_x, scale_y);
|
2091
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.drawImage(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_image'>image</span><span class='period'>.</span><span class='id identifier rubyid_canvas'>canvas</span><span class='embexpr_end'>}</span><span class='tstring_content'>, x-cx, y-cy);
|
2092
|
+
</span><span class='embexpr_beg'>#{</span><span class='ivar'>@ctx</span><span class='embexpr_end'>}</span><span class='tstring_content'>.setTransform(1, 0, 0, 1, 0, 0); // reset
|
2093
|
+
</span><span class='tstring_end'>}</span></span>
|
2094
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
2095
|
+
<span class='kw'>end</span></pre>
|
2096
|
+
</td>
|
2097
|
+
</tr>
|
2098
|
+
</table>
|
2099
|
+
</div>
|
2100
|
+
|
2101
|
+
<div class="method_details ">
|
2102
|
+
<h3 class="signature " id="draw_font-instance_method">
|
2103
|
+
|
2104
|
+
#<strong>draw_font</strong>(x, y, string, font, color = [255,255,255]) ⇒ <tt>Object</tt>
|
2105
|
+
|
2106
|
+
|
2107
|
+
|
2108
|
+
|
2109
|
+
|
2110
|
+
</h3><div class="docstring">
|
2111
|
+
<div class="discussion">
|
2112
|
+
|
2113
|
+
<p>Draw some text on this image</p>
|
2114
|
+
|
2115
|
+
|
2116
|
+
</div>
|
2117
|
+
</div>
|
2118
|
+
<div class="tags">
|
2119
|
+
|
2120
|
+
|
2121
|
+
</div><table class="source_code">
|
2122
|
+
<tr>
|
2123
|
+
<td>
|
2124
|
+
<pre class="lines">
|
2125
|
+
|
2126
|
+
|
2127
|
+
85
|
2128
|
+
86
|
2129
|
+
87
|
2130
|
+
88
|
2131
|
+
89
|
2132
|
+
90
|
2133
|
+
91
|
2134
|
+
92
|
2135
|
+
93
|
2136
|
+
94</pre>
|
2137
|
+
</td>
|
2138
|
+
<td>
|
2139
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 85</span>
|
2140
|
+
|
2141
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_draw_font'>draw_font</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_string'>string</span><span class='comma'>,</span> <span class='id identifier rubyid_font'>font</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='op'>=</span><span class='lbracket'>[</span><span class='int'>255</span><span class='comma'>,</span><span class='int'>255</span><span class='comma'>,</span><span class='int'>255</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
2142
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
2143
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
2144
|
+
ctx.font = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_font'>font</span><span class='period'>.</span><span class='id identifier rubyid__spec_str'>_spec_str</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
2145
|
+
ctx.textBaseline = 'top';
|
2146
|
+
ctx.fillStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
2147
|
+
ctx.fillText(string, x, y);
|
2148
|
+
</span><span class='tstring_end'>}</span></span>
|
2149
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
2150
|
+
<span class='kw'>end</span></pre>
|
2151
|
+
</td>
|
2152
|
+
</tr>
|
2153
|
+
</table>
|
2154
|
+
</div>
|
2155
|
+
|
2156
|
+
<div class="method_details ">
|
2157
|
+
<h3 class="signature " id="draw_rot-instance_method">
|
2158
|
+
|
2159
|
+
#<strong>draw_rot</strong>(x, y, image, angle, center_x = nil, center_y = nil) ⇒ <tt>Object</tt>
|
2160
|
+
|
2161
|
+
|
2162
|
+
|
2163
|
+
|
2164
|
+
|
2165
|
+
</h3><div class="docstring">
|
2166
|
+
<div class="discussion">
|
2167
|
+
|
2168
|
+
<p>Draw an Image on this image with rotation</p>
|
2169
|
+
<ul><li>
|
2170
|
+
<p>angle: Rotation angle (radian)</p>
|
2171
|
+
</li><li>
|
2172
|
+
<p>center_x, center_y: Rotation center in the `image` (default: center of the
|
2173
|
+
`image`)</p>
|
2174
|
+
</li></ul>
|
2175
|
+
|
2176
|
+
|
2177
|
+
</div>
|
2178
|
+
</div>
|
2179
|
+
<div class="tags">
|
2180
|
+
|
2181
|
+
|
2182
|
+
</div><table class="source_code">
|
2183
|
+
<tr>
|
2184
|
+
<td>
|
2185
|
+
<pre class="lines">
|
2186
|
+
|
2187
|
+
|
2188
|
+
59
|
2189
|
+
60
|
2190
|
+
61</pre>
|
2191
|
+
</td>
|
2192
|
+
<td>
|
2193
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 59</span>
|
2194
|
+
|
2195
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_draw_rot'>draw_rot</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_image'>image</span><span class='comma'>,</span> <span class='id identifier rubyid_angle'>angle</span><span class='comma'>,</span> <span class='id identifier rubyid_center_x'>center_x</span><span class='op'>=</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_center_y'>center_y</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
2196
|
+
<span class='id identifier rubyid_draw_ex'>draw_ex</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_image'>image</span><span class='comma'>,</span> <span class='label'>angle:</span> <span class='id identifier rubyid_angle'>angle</span><span class='comma'>,</span> <span class='label'>center_x:</span> <span class='id identifier rubyid_center_x'>center_x</span><span class='comma'>,</span> <span class='label'>center_y:</span> <span class='id identifier rubyid_center_y'>center_y</span><span class='rparen'>)</span>
|
2197
|
+
<span class='kw'>end</span></pre>
|
2198
|
+
</td>
|
2199
|
+
</tr>
|
2200
|
+
</table>
|
2201
|
+
</div>
|
2202
|
+
|
2203
|
+
<div class="method_details ">
|
2204
|
+
<h3 class="signature " id="fill-instance_method">
|
2205
|
+
|
2206
|
+
#<strong>fill</strong>(color) ⇒ <tt>Object</tt>
|
2207
|
+
|
2208
|
+
|
2209
|
+
|
2210
|
+
|
2211
|
+
|
2212
|
+
</h3><div class="docstring">
|
2213
|
+
<div class="discussion">
|
2214
|
+
|
2215
|
+
<p>Fill this image with `color`</p>
|
2216
|
+
|
2217
|
+
|
2218
|
+
</div>
|
2219
|
+
</div>
|
2220
|
+
<div class="tags">
|
2221
|
+
|
2222
|
+
|
2223
|
+
</div><table class="source_code">
|
2224
|
+
<tr>
|
2225
|
+
<td>
|
2226
|
+
<pre class="lines">
|
2227
|
+
|
2228
|
+
|
2229
|
+
221
|
2230
|
+
222
|
2231
|
+
223</pre>
|
2232
|
+
</td>
|
2233
|
+
<td>
|
2234
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 221</span>
|
2235
|
+
|
2236
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_fill'>fill</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
2237
|
+
<span class='id identifier rubyid_box_fill'>box_fill</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='ivar'>@width</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='ivar'>@height</span><span class='op'>-</span><span class='int'>1</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
2238
|
+
<span class='kw'>end</span></pre>
|
2239
|
+
</td>
|
2240
|
+
</tr>
|
2241
|
+
</table>
|
2242
|
+
</div>
|
2243
|
+
|
2244
|
+
<div class="method_details ">
|
2245
|
+
<h3 class="signature " id="line-instance_method">
|
2246
|
+
|
2247
|
+
#<strong>line</strong>(x1, y1, x2, y2, color) ⇒ <tt>Object</tt>
|
2248
|
+
|
2249
|
+
|
2250
|
+
|
2251
|
+
|
2252
|
+
|
2253
|
+
</h3><div class="docstring">
|
2254
|
+
<div class="discussion">
|
2255
|
+
|
2256
|
+
<p>Draw a line on this image</p>
|
2257
|
+
|
2258
|
+
|
2259
|
+
</div>
|
2260
|
+
</div>
|
2261
|
+
<div class="tags">
|
2262
|
+
|
2263
|
+
|
2264
|
+
</div><table class="source_code">
|
2265
|
+
<tr>
|
2266
|
+
<td>
|
2267
|
+
<pre class="lines">
|
2268
|
+
|
2269
|
+
|
2270
|
+
132
|
2271
|
+
133
|
2272
|
+
134
|
2273
|
+
135
|
2274
|
+
136
|
2275
|
+
137
|
2276
|
+
138
|
2277
|
+
139
|
2278
|
+
140
|
2279
|
+
141
|
2280
|
+
142</pre>
|
2281
|
+
</td>
|
2282
|
+
<td>
|
2283
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 132</span>
|
2284
|
+
|
2285
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_line'>line</span><span class='lparen'>(</span><span class='id identifier rubyid_x1'>x1</span><span class='comma'>,</span> <span class='id identifier rubyid_y1'>y1</span><span class='comma'>,</span> <span class='id identifier rubyid_x2'>x2</span><span class='comma'>,</span> <span class='id identifier rubyid_y2'>y2</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
2286
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
2287
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
2288
|
+
ctx.beginPath();
|
2289
|
+
ctx.strokeStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
2290
|
+
ctx.moveTo(x1, y1);
|
2291
|
+
ctx.lineTo(x2, y2);
|
2292
|
+
ctx.stroke();
|
2293
|
+
</span><span class='tstring_end'>}</span></span>
|
2294
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
2295
|
+
<span class='kw'>end</span></pre>
|
2296
|
+
</td>
|
2297
|
+
</tr>
|
2298
|
+
</table>
|
2299
|
+
</div>
|
2300
|
+
|
2301
|
+
<div class="method_details ">
|
2302
|
+
<h3 class="signature " id="slice-instance_method">
|
2303
|
+
|
2304
|
+
#<strong>slice</strong>(x, y, width, height) ⇒ <tt>Object</tt>
|
2305
|
+
|
2306
|
+
|
2307
|
+
|
2308
|
+
|
2309
|
+
|
2310
|
+
</h3><div class="docstring">
|
2311
|
+
<div class="discussion">
|
2312
|
+
|
2313
|
+
<p>Return an Image which is a copy of the specified area</p>
|
2314
|
+
|
2315
|
+
|
2316
|
+
</div>
|
2317
|
+
</div>
|
2318
|
+
<div class="tags">
|
2319
|
+
|
2320
|
+
|
2321
|
+
</div><table class="source_code">
|
2322
|
+
<tr>
|
2323
|
+
<td>
|
2324
|
+
<pre class="lines">
|
2325
|
+
|
2326
|
+
|
2327
|
+
231
|
2328
|
+
232
|
2329
|
+
233
|
2330
|
+
234
|
2331
|
+
235
|
2332
|
+
236</pre>
|
2333
|
+
</td>
|
2334
|
+
<td>
|
2335
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 231</span>
|
2336
|
+
|
2337
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span><span class='rparen'>)</span>
|
2338
|
+
<span class='id identifier rubyid_newimg'>newimg</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="DXOpal::Image (class)">Image</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="DXOpal::Image#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span><span class='rparen'>)</span>
|
2339
|
+
<span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid__image_data'>_image_data</span><span class='lparen'>(</span><span class='id identifier rubyid_x'>x</span><span class='comma'>,</span> <span class='id identifier rubyid_y'>y</span><span class='comma'>,</span> <span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span><span class='rparen'>)</span>
|
2340
|
+
<span class='id identifier rubyid_newimg'>newimg</span><span class='period'>.</span><span class='id identifier rubyid__put_image_data'>_put_image_data</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='int'>0</span><span class='comma'>,</span> <span class='int'>0</span><span class='rparen'>)</span>
|
2341
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_newimg'>newimg</span>
|
2342
|
+
<span class='kw'>end</span></pre>
|
2343
|
+
</td>
|
2344
|
+
</tr>
|
2345
|
+
</table>
|
2346
|
+
</div>
|
2347
|
+
|
2348
|
+
<div class="method_details ">
|
2349
|
+
<h3 class="signature " id="slice_tiles-instance_method">
|
2350
|
+
|
2351
|
+
#<strong>slice_tiles</strong>(xcount, ycount) ⇒ <tt>Object</tt>
|
2352
|
+
|
2353
|
+
|
2354
|
+
|
2355
|
+
|
2356
|
+
|
2357
|
+
</h3><div class="docstring">
|
2358
|
+
<div class="discussion">
|
2359
|
+
|
2360
|
+
<p>Slice this image into xcount*ycount tiles</p>
|
2361
|
+
|
2362
|
+
|
2363
|
+
</div>
|
2364
|
+
</div>
|
2365
|
+
<div class="tags">
|
2366
|
+
|
2367
|
+
|
2368
|
+
</div><table class="source_code">
|
2369
|
+
<tr>
|
2370
|
+
<td>
|
2371
|
+
<pre class="lines">
|
2372
|
+
|
2373
|
+
|
2374
|
+
239
|
2375
|
+
240
|
2376
|
+
241
|
2377
|
+
242
|
2378
|
+
243
|
2379
|
+
244
|
2380
|
+
245
|
2381
|
+
246
|
2382
|
+
247</pre>
|
2383
|
+
</td>
|
2384
|
+
<td>
|
2385
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 239</span>
|
2386
|
+
|
2387
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_slice_tiles'>slice_tiles</span><span class='lparen'>(</span><span class='id identifier rubyid_xcount'>xcount</span><span class='comma'>,</span> <span class='id identifier rubyid_ycount'>ycount</span><span class='rparen'>)</span>
|
2388
|
+
<span class='id identifier rubyid_tile_w'>tile_w</span> <span class='op'>=</span> <span class='ivar'>@width</span> <span class='op'>/</span> <span class='id identifier rubyid_xcount'>xcount</span>
|
2389
|
+
<span class='id identifier rubyid_tile_h'>tile_h</span> <span class='op'>=</span> <span class='ivar'>@height</span> <span class='op'>/</span> <span class='id identifier rubyid_ycount'>ycount</span>
|
2390
|
+
<span class='kw'>return</span> <span class='lparen'>(</span><span class='int'>0</span><span class='op'>...</span><span class='id identifier rubyid_ycount'>ycount</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_flat_map'>flat_map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
|
2391
|
+
<span class='lparen'>(</span><span class='int'>0</span><span class='op'>...</span><span class='id identifier rubyid_xcount'>xcount</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_u'>u</span><span class='op'>|</span>
|
2392
|
+
<span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='id identifier rubyid_tile_w'>tile_w</span> <span class='op'>*</span> <span class='id identifier rubyid_u'>u</span><span class='comma'>,</span> <span class='id identifier rubyid_tile_h'>tile_h</span> <span class='op'>*</span> <span class='id identifier rubyid_v'>v</span><span class='comma'>,</span> <span class='id identifier rubyid_tile_w'>tile_w</span><span class='comma'>,</span> <span class='id identifier rubyid_tile_h'>tile_h</span><span class='rparen'>)</span>
|
2393
|
+
<span class='rbrace'>}</span>
|
2394
|
+
<span class='rbrace'>}</span>
|
2395
|
+
<span class='kw'>end</span></pre>
|
2396
|
+
</td>
|
2397
|
+
</tr>
|
2398
|
+
</table>
|
2399
|
+
</div>
|
2400
|
+
|
2401
|
+
<div class="method_details ">
|
2402
|
+
<h3 class="signature " id="triangle-instance_method">
|
2403
|
+
|
2404
|
+
#<strong>triangle</strong>(x1, y1, x2, y2, x3, y3, color) ⇒ <tt>Object</tt>
|
2405
|
+
|
2406
|
+
|
2407
|
+
|
2408
|
+
|
2409
|
+
|
2410
|
+
</h3><div class="docstring">
|
2411
|
+
<div class="discussion">
|
2412
|
+
|
2413
|
+
<p>Draw a triangle on this image</p>
|
2414
|
+
|
2415
|
+
|
2416
|
+
</div>
|
2417
|
+
</div>
|
2418
|
+
<div class="tags">
|
2419
|
+
|
2420
|
+
|
2421
|
+
</div><table class="source_code">
|
2422
|
+
<tr>
|
2423
|
+
<td>
|
2424
|
+
<pre class="lines">
|
2425
|
+
|
2426
|
+
|
2427
|
+
192
|
2428
|
+
193
|
2429
|
+
194
|
2430
|
+
195
|
2431
|
+
196
|
2432
|
+
197
|
2433
|
+
198
|
2434
|
+
199
|
2435
|
+
200
|
2436
|
+
201
|
2437
|
+
202
|
2438
|
+
203
|
2439
|
+
204</pre>
|
2440
|
+
</td>
|
2441
|
+
<td>
|
2442
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 192</span>
|
2443
|
+
|
2444
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_triangle'>triangle</span><span class='lparen'>(</span><span class='id identifier rubyid_x1'>x1</span><span class='comma'>,</span> <span class='id identifier rubyid_y1'>y1</span><span class='comma'>,</span> <span class='id identifier rubyid_x2'>x2</span><span class='comma'>,</span> <span class='id identifier rubyid_y2'>y2</span><span class='comma'>,</span> <span class='id identifier rubyid_x3'>x3</span><span class='comma'>,</span> <span class='id identifier rubyid_y3'>y3</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
2445
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
2446
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
2447
|
+
ctx.beginPath();
|
2448
|
+
ctx.strokeStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
2449
|
+
ctx.moveTo(x1, y1);
|
2450
|
+
ctx.lineTo(x2, y2);
|
2451
|
+
ctx.lineTo(x3, y3);
|
2452
|
+
ctx.lineTo(x1, y1);
|
2453
|
+
ctx.stroke();
|
2454
|
+
</span><span class='tstring_end'>}</span></span>
|
2455
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
2456
|
+
<span class='kw'>end</span></pre>
|
2457
|
+
</td>
|
2458
|
+
</tr>
|
2459
|
+
</table>
|
2460
|
+
</div>
|
2461
|
+
|
2462
|
+
<div class="method_details ">
|
2463
|
+
<h3 class="signature " id="triangle_fill-instance_method">
|
2464
|
+
|
2465
|
+
#<strong>triangle_fill</strong>(x1, y1, x2, y2, x3, y3, color) ⇒ <tt>Object</tt>
|
2466
|
+
|
2467
|
+
|
2468
|
+
|
2469
|
+
|
2470
|
+
|
2471
|
+
</h3><div class="docstring">
|
2472
|
+
<div class="discussion">
|
2473
|
+
|
2474
|
+
<p>Draw a filled triangle on this image</p>
|
2475
|
+
|
2476
|
+
|
2477
|
+
</div>
|
2478
|
+
</div>
|
2479
|
+
<div class="tags">
|
2480
|
+
|
2481
|
+
|
2482
|
+
</div><table class="source_code">
|
2483
|
+
<tr>
|
2484
|
+
<td>
|
2485
|
+
<pre class="lines">
|
2486
|
+
|
2487
|
+
|
2488
|
+
207
|
2489
|
+
208
|
2490
|
+
209
|
2491
|
+
210
|
2492
|
+
211
|
2493
|
+
212
|
2494
|
+
213
|
2495
|
+
214
|
2496
|
+
215
|
2497
|
+
216
|
2498
|
+
217
|
2499
|
+
218</pre>
|
2500
|
+
</td>
|
2501
|
+
<td>
|
2502
|
+
<pre class="code"><span class="info file"># File 'opal/dxopal/image.rb', line 207</span>
|
2503
|
+
|
2504
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_triangle_fill'>triangle_fill</span><span class='lparen'>(</span><span class='id identifier rubyid_x1'>x1</span><span class='comma'>,</span> <span class='id identifier rubyid_y1'>y1</span><span class='comma'>,</span> <span class='id identifier rubyid_x2'>x2</span><span class='comma'>,</span> <span class='id identifier rubyid_y2'>y2</span><span class='comma'>,</span> <span class='id identifier rubyid_x3'>x3</span><span class='comma'>,</span> <span class='id identifier rubyid_y3'>y3</span><span class='comma'>,</span> <span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span>
|
2505
|
+
<span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='ivar'>@ctx</span>
|
2506
|
+
<span class='backtick'>%x{</span><span class='tstring_content'>
|
2507
|
+
ctx.beginPath();
|
2508
|
+
ctx.fillStyle = </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid__rgba'>_rgba</span><span class='lparen'>(</span><span class='id identifier rubyid_color'>color</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
|
2509
|
+
ctx.moveTo(x1, y1);
|
2510
|
+
ctx.lineTo(x2, y2);
|
2511
|
+
ctx.lineTo(x3, y3);
|
2512
|
+
ctx.fill();
|
2513
|
+
</span><span class='tstring_end'>}</span></span>
|
2514
|
+
<span class='kw'>return</span> <span class='kw'>self</span>
|
2515
|
+
<span class='kw'>end</span></pre>
|
2516
|
+
</td>
|
2517
|
+
</tr>
|
2518
|
+
</table>
|
2519
|
+
</div>
|
2520
|
+
|
2521
|
+
</div>
|
2522
|
+
|
2523
|
+
</div>
|
2524
|
+
|
2525
|
+
<div id="footer">
|
2526
|
+
Generated on Tue Oct 17 13:56:27 2017 by
|
2527
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2528
|
+
0.9.9 (ruby-2.4.2).
|
2529
|
+
</div>
|
2530
|
+
|
2531
|
+
</div>
|
2532
|
+
</body>
|
2533
|
+
</html>
|