pixelflow_canvas 0.7.8 → 0.7.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ebbe88b5083517e9676724f9895e6bc925c9cb5a590b186008e2cce7d645c0e
4
- data.tar.gz: 4ae32148f1a6490df8cb7407f7e4f766c5a2d524fc8b0770c95d09331840b9c4
3
+ metadata.gz: cdb3e2c3c3b8440c943a807f9db245b390bbd0fa9e01d760436e618c6b00efe7
4
+ data.tar.gz: 595d68bb7f02a6f68bc3a880e587356aaa3074a9a15af2646c195af53c5b9913
5
5
  SHA512:
6
- metadata.gz: 023dd8880da90f36aa99a2c14f3018f3d7eb7ab370f30fa925861ddac37f2e8784658dabb03851be180d31515abaf56968d7fc28dfff85ddfd0e39d4d94679ae
7
- data.tar.gz: dfd0f07ac8154b7cacd2cc9f4900bc5e018959a2681c6ed786d7d6c11853d65fd439cce6a151f278190d3e80938c5b86601bdd4cb56058959a0f5673a8919b4f
6
+ metadata.gz: 8bc3dd4acd2ad8181552969191b5fb25892dbfa2e0b45f42efd3876227d6386bb330e95a150774f082c1f25761da00747b9cfc3fcf5cacf7c05a8598770b7f97
7
+ data.tar.gz: bee7230e58e606d6b6197ed50f9fc7713b389142e29d61fea9536728aceaad65dabec8fe679ee4183826729a7be80d7399fb5ebbd077d762c96087563838c7c1
data/docs/advanced_use.md CHANGED
@@ -11,7 +11,7 @@ Masks can be used to specify which parts of the image should be affected by draw
11
11
  To set a mask, use the `set_mask` method:
12
12
 
13
13
  ```ruby
14
- canvas.set_mask do
14
+ set_mask do
15
15
  add_color(5)
16
16
  end
17
17
  ```
@@ -21,14 +21,14 @@ In the example above, the mask is set to all pixels that currently have a color
21
21
  Remove a mask by calling the `remove_mask` method:
22
22
 
23
23
  ```ruby
24
- canvas.remove_mask
24
+ remove_mask
25
25
  ```
26
26
  # Saving the canvas
27
27
 
28
28
  You can save the canvas to a file using the `save_as_png` method.
29
29
 
30
30
  ```ruby
31
- canvas.save_as_png("output.png")
31
+ save_as_png("output.png")
32
32
  ```
33
33
 
34
34
  # Event polling
@@ -26,14 +26,14 @@ The `Canvas` class provides a number of methods for drawing things on the canvas
26
26
  The `set_pixel` method sets the color of a single pixel on the canvas.
27
27
 
28
28
  ```ruby
29
- canvas.set_pixel(160, 90, 10) # in palette mode
30
- canvas.set_pixel(160, 90, 0, 255, 0) # in RGB mode
29
+ set_pixel(160, 90, 10) # in palette mode
30
+ set_pixel(160, 90, 0, 255, 0) # in RGB mode
31
31
  ```
32
32
 
33
33
  To read the color of a pixel, use the `get_pixel` method.
34
34
 
35
35
  ```ruby
36
- color = canvas.get_pixel(160, 90)
36
+ color = get_pixel(160, 90)
37
37
  ```
38
38
 
39
39
  Depending on the color mode, the `get_pixel` method returns either a palette index or an array of RGB values.
@@ -43,14 +43,14 @@ Depending on the color mode, the `get_pixel` method returns either a palette ind
43
43
  The `set_color` method sets the color that will be used by all subsequent drawing operations.
44
44
 
45
45
  ```ruby
46
- canvas.set_color(10)
46
+ set_color(10)
47
47
  ```
48
48
 
49
49
  You can omit the color argument in the `set_pixel` method if you have previously set the color using the `set_color` method.
50
50
 
51
51
  ```ruby
52
- canvas.set_color(10)
53
- canvas.set_pixel(160, 90)
52
+ set_color(10)
53
+ set_pixel(160, 90)
54
54
  ```
55
55
 
56
56
  ## Drawing lines
@@ -58,8 +58,8 @@ canvas.set_pixel(160, 90)
58
58
  Use the `draw_line` method to draw a line between two points.
59
59
 
60
60
  ```ruby
61
- canvas.set_color(10)
62
- canvas.draw_line(10, 10, 100, 50)
61
+ set_color(10)
62
+ draw_line(10, 10, 100, 50)
63
63
  ```
64
64
 
65
65
  <!-- code begin
@@ -76,10 +76,10 @@ code end --><img class='full' src='images/code/0ba813cd6b7e0ae0.png'>
76
76
  Use the `draw_rect` and `fill_rect` methods to draw rectangles. Specify the coordinates of the upper-left corner and the lower-right corner of the rectangle.
77
77
 
78
78
  ```ruby
79
- canvas.set_color(3)
80
- canvas.fill_rect(10, 10, 100, 50)
81
- canvas.set_color(10)
82
- canvas.draw_rect(10, 10, 100, 50)
79
+ set_color(3)
80
+ fill_rect(10, 10, 100, 50)
81
+ set_color(10)
82
+ draw_rect(10, 10, 100, 50)
83
83
  ```
84
84
 
85
85
  <!-- code begin
@@ -98,10 +98,10 @@ code end --><img class='full' src='images/code/584e2ee3b7526718.png'>
98
98
  Use the `draw_circle` and `fill_circle` methods to draw circles. Specify the center and the radius of the circle.
99
99
 
100
100
  ```ruby
101
- canvas.set_color(3)
102
- canvas.fill_circle(160, 90, 50)
103
- canvas.set_color(10)
104
- canvas.draw_circle(160, 90, 50)
101
+ set_color(3)
102
+ fill_circle(160, 90, 50)
103
+ set_color(10)
104
+ draw_circle(160, 90, 50)
105
105
  ```
106
106
 
107
107
  <!-- code begin
@@ -120,10 +120,10 @@ code end --><img class='full' src='images/code/809d9ce7d7a8ce6c.png'>
120
120
  Use the `draw_ellipse` and `fill_ellipse` methods to draw ellipses. Specify the center, the horizontal radius, and the vertical radius of the ellipse.
121
121
 
122
122
  ```ruby
123
- canvas.set_color(3)
124
- canvas.fill_ellipse(160, 90, 50, 30)
125
- canvas.set_color(10)
126
- canvas.draw_ellipse(160, 90, 50, 30)
123
+ set_color(3)
124
+ fill_ellipse(160, 90, 50, 30)
125
+ set_color(10)
126
+ draw_ellipse(160, 90, 50, 30)
127
127
  ```
128
128
  <!-- code begin
129
129
  Pixelflow::Canvas.new(64, 19, :palette) do
@@ -141,10 +141,10 @@ code end --><img class='full' src='images/code/3871051301832e44.png'>
141
141
  Use the `draw_arc` and `fill_arc` methods to draw arcs. Specify the center, the radius, the start angle, and the end angle of the arc.
142
142
 
143
143
  ```ruby
144
- canvas.set_color(3)
145
- canvas.fill_arc(160, 90, 50, 0, 180)
146
- canvas.set_color(10)
147
- canvas.draw_arc(160, 90, 50, 0, 180)
144
+ set_color(3)
145
+ fill_arc(160, 90, 50, 0, 180)
146
+ set_color(10)
147
+ draw_arc(160, 90, 50, 0, 180)
148
148
  ```
149
149
 
150
150
  <!-- code begin
@@ -163,9 +163,9 @@ code end --><img class='full' src='images/code/4eb9d4f97e05c739.png'>
163
163
  Use the `draw_quadratic_bezier` and `draw_cubic_bezier` methods to draw quadratic and cubic Bézier curves, respectively.
164
164
 
165
165
  ```ruby
166
- canvas.set_color(10)
167
- canvas.draw_quadratic_bezier(10, 10, 50, 50, 100, 10)
168
- canvas.draw_cubic_bezier(10, 10, 50, 50, 100, 50, 150, 10)
166
+ set_color(10)
167
+ draw_quadratic_bezier(10, 10, 50, 50, 100, 10)
168
+ draw_cubic_bezier(10, 10, 50, 50, 100, 50, 150, 10)
169
169
  ```
170
170
 
171
171
  <!-- code begin
@@ -191,10 +191,10 @@ code end --><img class='full' src='images/code/40acf0284459aa0e.png'>
191
191
  Use the `draw_triangle` and `fill_triangle` methods to draw triangles. Specify the coordinates of the three vertices of the triangle.
192
192
 
193
193
  ```ruby
194
- canvas.set_color(3)
195
- canvas.fill_triangle(10, 10, 100, 50, 50, 100)
196
- canvas.set_color(10)
197
- canvas.draw_triangle(10, 10, 100, 50, 50, 100)
194
+ set_color(3)
195
+ fill_triangle(10, 10, 100, 50, 50, 100)
196
+ set_color(10)
197
+ draw_triangle(10, 10, 100, 50, 50, 100)
198
198
  ```
199
199
 
200
200
  <!-- code begin
@@ -213,10 +213,10 @@ code end --><img class='full' src='images/code/85abc3576f6d78b1.png'>
213
213
  The `flood_fill` method fills an area of the canvas with the current color. Specify the starting point of the fill operation.
214
214
 
215
215
  ```ruby
216
- canvas.set_color(10)
217
- canvas.draw_circle(110, 90, 50)
218
- canvas.draw_circle(210, 90, 40)
219
- canvas.flood_fill(160, 90)
216
+ set_color(10)
217
+ draw_circle(110, 90, 50)
218
+ draw_circle(210, 90, 40)
219
+ flood_fill(160, 90)
220
220
  ```
221
221
 
222
222
  <!-- code begin
@@ -237,8 +237,8 @@ code end --><img class='full' src='images/code/ef667cfe7ff65c27.png'>
237
237
  Use the `draw_text` method to draw text on the canvas. Specify the position, the text to draw, the font name, and the scale factor.
238
238
 
239
239
  ```ruby
240
- canvas.set_color(10)
241
- canvas.draw_text(10, 10, "Hello, world!", "4x6", 2)
240
+ set_color(10)
241
+ draw_text(10, 10, "Hello, world!", "4x6", 2)
242
242
  ```
243
243
 
244
244
  <!-- code begin
@@ -254,7 +254,7 @@ code end --><img class='full' src='images/code/30c5ac94e5fa22ba.png'>
254
254
  Use `text_width` to get the width and height of a given text string in pixels.
255
255
 
256
256
  ```ruby
257
- width = canvas.text_width("Hello, world!", "4x6", 2)
257
+ width = text_width("Hello, world!", "4x6", 2)
258
258
  ```
259
259
 
260
260
  There are several built-in fonts available:
data/docs/index.md CHANGED
@@ -76,7 +76,7 @@ There are two color modes: `:palette` and `:rgb`. In palette mode, the canvas us
76
76
  The default color mode is `:rgb`. It can be changed by calling `set_color_mode`.
77
77
 
78
78
  ```ruby
79
- canvas.set_color_mode(:palette)
79
+ set_color_mode(:palette)
80
80
  ```
81
81
 
82
82
  ### Double buffering
@@ -86,7 +86,7 @@ There are two drawing modes: `:direct` and `:buffered`. In direct mode, every pi
86
86
  The default drawing mode is `:direct`. It can be changed by calling `set_draw_mode`.
87
87
 
88
88
  ```ruby
89
- canvas.set_draw_mode(:buffered)
89
+ set_draw_mode(:buffered)
90
90
  ```
91
91
 
92
92
  {: .info }
@@ -104,7 +104,7 @@ There are three composition modes: `:copy`, `:add`, `:subtract` and `:multiply`.
104
104
  The default composition mode is `:copy`. It can be changed by calling `set_composition_mode`.
105
105
 
106
106
  ```ruby
107
- canvas.set_composition_mode(:add)
107
+ set_composition_mode(:add)
108
108
  ```
109
109
 
110
110
  {: .info }
@@ -117,7 +117,7 @@ There are two interpolation modes: `:nearest` and `:bilinear`. This mode only af
117
117
  The default interpolation mode is `:nearest`. It can be changed by calling `set_interpolation_mode`.
118
118
 
119
119
  ```ruby
120
- canvas.set_interpolation_mode(:bilinear)
120
+ set_interpolation_mode(:bilinear)
121
121
  ```
122
122
  <!--
123
123
  - Using masks