tung-tea 0.1.4 → 0.1.5
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.
- data/lib/tea/m_primitive_drawing.rb +18 -0
- metadata +2 -2
@@ -27,13 +27,25 @@ module Tea
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Plot a point at (x, y) with the given color (0xRRGGBBAA) on the Bitmap.
|
30
|
+
#
|
31
|
+
# Raises Tea::Error if (x, y) is outside of the drawing buffer.
|
30
32
|
def point(x, y, color)
|
33
|
+
w = primitive_buffer.w
|
34
|
+
h = primitive_buffer.h
|
35
|
+
if x < 0 || x > w || y < 0 || y > h
|
36
|
+
raise Tea::Error, "can't plot point (#{x}, #{y}), not within #{w}x#{h}", caller
|
37
|
+
end
|
31
38
|
primitive_buffer[x, y] = primitive_color(color)
|
32
39
|
end
|
33
40
|
|
34
41
|
# Draw a rectangle of size w * h with the top-left corner at (x, y) with
|
35
42
|
# the given color (0xRRGGBBAA).
|
43
|
+
#
|
44
|
+
# Raises Tea::Error if w or h are less than 0.
|
36
45
|
def rect(x, y, w, h, color)
|
46
|
+
if w < 0 || h < 0
|
47
|
+
raise Tea::Error, "can't draw rectangle of size #{w}x#{h}", caller
|
48
|
+
end
|
37
49
|
primitive_buffer.fill_rect x, y, w, h, primitive_color(color)
|
38
50
|
end
|
39
51
|
|
@@ -53,7 +65,13 @@ module Tea
|
|
53
65
|
# +:outline+:: If true, do not fill the circle, just draw an outline.
|
54
66
|
# +:antialias+:: If true, smooth the edges of the circle with
|
55
67
|
# antialiasing.
|
68
|
+
#
|
69
|
+
# Raises Tea::Error if the radius is less than 0.
|
56
70
|
def circle(x, y, radius, color, options=nil)
|
71
|
+
if radius < 0
|
72
|
+
raise Tea::Error, "can't draw circle with radius #{radius}", caller
|
73
|
+
end
|
74
|
+
|
57
75
|
if options
|
58
76
|
primitive_buffer.draw_circle x, y, radius, primitive_color(color),
|
59
77
|
!options[:outline], options[:antialias]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tung-tea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|