Anonymous (owner)

Revisions

  • 59867d Mon Feb 09 15:08:56 -0800 2009
  • 0f9649 Mon Feb 09 13:39:24 -0800 2009
gist: 61025 Download_button fork
public
Public Clone URL: git://gist.github.com/61025.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'ftor'
module Rubygame
 
class Surface
  def draw_line_s(point1, point2, color, thickness)
    half_thickness = thickness/2.0
    x1 = point1[0]
    y1 = point1[1]
    x2 = point2[0]
    y2 = point2[1]
 
    point1_vector = Ftor.new x1, y1
    point2_vector = Ftor.new x2, y2
 
    line_vector = point2_vector-point1_vector
    perp_vector = line_vector.normal.unit
 
    points = []
    pvt = perp_vector*half_thickness
    poly_point1 = Ftor.new(x1,y1)+pvt
    poly_point2 = Ftor.new(x2,y2)+pvt
    poly_point3 = Ftor.new(x2,y2)-pvt
    poly_point4 = Ftor.new(x1,y1)-pvt
 
    points << [poly_point1.x,poly_point1.y]
    points << [poly_point2.x,poly_point2.y]
    points << [poly_point3.x,poly_point3.y]
    points << [poly_point4.x,poly_point4.y]
    points << [poly_point1.x,poly_point1.y]
 
    draw_polygon_s points, color
    draw_circle_s [x1,y1], half_thickness, color
    draw_circle_s [x2,y2], half_thickness, color
  end
end
 
end # module Rubygame