Method: Tea::Primitive#line
- Defined in:
- lib/tea/mix_primitive.rb
#line(x1, y1, x2, y2, color, options = nil) ⇒ Object
Draw a line from (x1, y1) to (x2, y2) with the given color (0xRRGGBBAA). Optional hash arguments:
:antialias-
If true, smooth the line with antialiasing.
:mix-
:blendaverages the RGB parts of the line and destination colours by the line alpha (default).:replacewrites over the RGBA parts of the line destination pixels.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/tea/mix_primitive.rb', line 121 def line(x1, y1, x2, y2, color, =nil) r, g, b, a = Color.split(color) if == nil antialias = false mix = (a < 0xff) ? :blend : :replace else if [:mix] && [:blend, :replace].include?([:mix]) == false raise Tea::Error, "invalid mix option \"#{mix}\"", caller end antialias = [:antialias] || false mix = ([:mix] && a < 0xff) ? [:mix] : :replace mix = (a < 0xff) ? ([:mix] ? [:mix] : :blend) : :replace end if primitive_buffer.class == SDL::Screen primitive_buffer.draw_line x1, y1, x2, y2, primitive_rgba_to_color(r, g, b, (mix == :replace ? a : 255)), antialias, (mix == :blend ? a : nil) else if antialias primitive_aa_line x1, y1, x2, y2, r, g, b, a, (mix == :blend ? BLEND_MIXER : REPLACE_MIXER) else primitive_line x1, y1, x2, y2, r, g, b, a, (mix == :blend ? BLEND_MIXER : REPLACE_MIXER) end end end |