Class: SDL::Surface

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sdl.rb,
lib/rubysdl_aliases.rb,
lib/rubysdl_aliases.rb,
lib/rubysdl_aliases.rb,
lib/sdl1_compatible.rb,
lib/rubysdl_compatible_ver1.rb,
lib/rubysdl_compatible_ver1.rb,
lib/rubysdl_compatible_ver1.rb,
lib/rubysdl_compatible_ver1.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*args) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/sdl.rb', line 46

def self.new(*args)
  case args.size
  when 4
    create(*args)
  when 8
    createWithFormat(*args)
  else
    raise ArgumentError,"must be SDL::Surface.new(flags,w,h,surface) or SDL::Surface.new(flags,w,h,depth,Rmask,Gmask,Bmask,Amask)"
  end
end

.transformBlit(src, dst, angle, xscale, yscale, px, py, qx, qy, flags) ⇒ Object Also known as: transform_blit



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/sdl.rb', line 119

def Surface.transformBlit(src, dst, angle, xscale, yscale,
                          px, py, qx, qy, flags)
  transformed = src.transformSurface(src.colorkey, angle,
                                     xscale, yscale, flags)
  transformed.setColorKey(src.flags & (SDL::SRCCOLORKEY|SDL::RLEACCEL),
                          src.colorkey )
  transformed.setAlpha(src.flags & (SDL::SRCALPHA|SDL::RLEACCEL),
                       src.alpha )
  rad = Math::PI*angle / 180.0
  x = px - src.w/2.0 ; y = py - src.h/2.0
    x *= xscale ; y *= yscale
  dst_x = x*Math.cos(rad)-y*Math.sin(rad) 
  dst_y = x*Math.sin(rad)+y*Math.cos(rad) 
  dst_x += transformed.w / 2
  dst_y += transformed.h / 2
  Surface.blit(transformed, 0, 0, 0, 0, dst, qx-dst_x, qy-dst_y)
end

Instance Method Details

#copyRect(x, y, w, h) ⇒ Object Also known as: copy_rect



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sdl.rb', line 28

def copyRect(x,y,w,h)
  format = self.format
  flagbase=SDL::SWSURFACE|SDL::HWSURFACE|SDL::SRCCOLORKEY|SDL::SRCALPHA
  alpha_flag = self.flags & (SDL::SRCCOLORKEY|SDL::RLEACCEL)
  self.setAlpha(0,format.alpha)
  begin
    new_surface=Surface.new(flagbase&self.flags,w,h,self)
  ensure
    self.setAlpha(alpha_flag,format.alpha)
  end
  SDL.blitSurface(self,x,y,w,h,new_surface,0,0)
  new_surface.setColorKey(self.flags & (SDL::SRCCOLORKEY|SDL::RLEACCEL),
                          format.colorkey )
  new_surface.setAlpha(self.flags & (SDL::SRCALPHA|SDL::RLEACCEL),
                       format.alpha )
  return new_surface
end

#drawAABezier(x1, y1, x2, y2, x3, y3, x4, y4, level, color) ⇒ Object Also known as: draw_aa_bezier



151
152
153
# File 'lib/rubysdl_compatible_ver1.rb', line 151

def drawAABezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color)
  drawBezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color,true)
end

#drawAABezierAlpha(x1, y1, x2, y2, x3, y3, x4, y4, level, color, alpha) ⇒ Object Also known as: draw_aa_bezier_alpha



157
158
159
# File 'lib/rubysdl_compatible_ver1.rb', line 157

def drawAABezierAlpha(x1,y1,x2,y2,x3,y3,x4,y4,level,color,alpha)
  drawBezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color,true,alpha)
end

#drawAACircle(x, y, r, color) ⇒ Object Also known as: draw_aa_circle



103
104
105
# File 'lib/rubysdl_compatible_ver1.rb', line 103

def drawAACircle(x, y, r, color)
  drawCircle(x, y, r, color, false, true)
end

#drawAACircleAlpha(x, y, r, color, alpha) ⇒ Object Also known as: draw_aa_circle_alpha



113
114
115
# File 'lib/rubysdl_compatible_ver1.rb', line 113

def drawAACircleAlpha(x, y, r, color, alpha)
  drawCircle(x, y, r, color, false, true, alpha)
end

#drawAAEllipse(x, y, rx, ry, color) ⇒ Object Also known as: draw_aa_ellipse



141
142
143
# File 'lib/rubysdl_compatible_ver1.rb', line 141

def drawAAEllipse(x, y, rx, ry, color)
  drawEllipse(x, y, rx, ry, color, false, true)
end

#drawAAEllipseAlpha(x, y, rx, ry, color, alpha) ⇒ Object Also known as: draw_aa_ellipse_alpha



144
145
146
# File 'lib/rubysdl_compatible_ver1.rb', line 144

def drawAAEllipseAlpha(x, y, rx, ry, color, alpha)
  drawEllipse(x, y, rx, ry, color, false, true, alpha)
end

#drawAAFilledCircle(x, y, r, color) ⇒ Object Also known as: draw_aa_filled_circle



106
107
108
# File 'lib/rubysdl_compatible_ver1.rb', line 106

def drawAAFilledCircle(x, y, r, color)
  drawCircle(x, y, r, color, true, true)
end

#drawAAFilledEllipse(x, y, rx, ry, color) ⇒ Object



134
135
136
# File 'lib/rubysdl_compatible_ver1.rb', line 134

def drawAAFilledEllipse(x, y, rx, ry, color)
  drawEllipse(x, y, rx, ry, color, true, true)
end

#drawAALine(x1, y1, x2, y2, col) ⇒ Object Also known as: draw_aa_line



93
94
95
# File 'lib/rubysdl_compatible_ver1.rb', line 93

def drawAALine(x1, y1, x2, y2, col)
  drawLine(x1, y1, x2, y2, col, true)
end

#drawAALineAlpha(x1, y1, x2, y2, col, alpha) ⇒ Object Also known as: draw_aa_line_alpha



96
97
98
# File 'lib/rubysdl_compatible_ver1.rb', line 96

def drawAALineAlpha(x1, y1, x2, y2, col, alpha)
  drawLine(x1, y1, x2, y2, col, true, alpha)
end

#drawBezierAlpha(x1, y1, x2, y2, x3, y3, x4, y4, level, color, alpha) ⇒ Object Also known as: draw_bezier_alpha



154
155
156
# File 'lib/rubysdl_compatible_ver1.rb', line 154

def drawBezierAlpha(x1,y1,x2,y2,x3,y3,x4,y4,level,color,alpha)
  drawBezier(x1,y1,x2,y2,x3,y3,x4,y4,level,color,false,alpha)
end

#drawCircleAlpha(x, y, r, color, alpha) ⇒ Object Also known as: draw_circle_alpha



110
111
112
# File 'lib/rubysdl_compatible_ver1.rb', line 110

def drawCircleAlpha(x, y, r, color, alpha)
  drawCircle(x, y, r, color, false, false, alpha)
end

#drawEllipseAlpha(x, y, rx, ry, color, alpha) ⇒ Object Also known as: draw_ellipse_alpha



147
148
149
# File 'lib/rubysdl_compatible_ver1.rb', line 147

def drawEllipseAlpha(x, y, rx, ry, color, alpha)
  drawEllipse(x, y, rx, ry, color, false, false, alpha)
end

#drawFilledCircle(x, y, r, color) ⇒ Object Also known as: draw_filled_circle



119
120
121
# File 'lib/rubysdl_compatible_ver1.rb', line 119

def drawFilledCircle(x, y, r, color)
  drawCircle(x, y, r, color, true)
end

#drawFilledCircleAlpha(x, y, r, color, alpha) ⇒ Object Also known as: draw_filled_circle_alpha



116
117
118
# File 'lib/rubysdl_compatible_ver1.rb', line 116

def drawFilledCircleAlpha(x, y, r, color, alpha)
  drawCircle(x, y, r, color, true, false, alpha)
end

#drawFilledEllipse(x, y, rx, ry, color) ⇒ Object Also known as: draw_filled_ellipse



131
132
133
# File 'lib/rubysdl_compatible_ver1.rb', line 131

def drawFilledEllipse(x, y, rx, ry, color)
  drawEllipse(x, y, rx, ry, color, true)
end

#drawFilledEllipseAlpha(x, y, rx, ry, color, alpha) ⇒ Object Also known as: draw_filled_ellipse_alpha



137
138
139
# File 'lib/rubysdl_compatible_ver1.rb', line 137

def drawFilledEllipseAlpha(x, y, rx, ry, color, alpha)
  drawEllipse(x, y, rx, ry, color, true, false, alpha)
end

#drawFilledRectAlpha(x1, y1, x2, y2, color, alpha) ⇒ Object Also known as: draw_filled_rect_alpha



127
128
129
# File 'lib/rubysdl_compatible_ver1.rb', line 127

def drawFilledRectAlpha(x1, y1, x2, y2, color, alpha)
  drawRect(x1, y1, x2, y2, color, true, alpha)
end

#drawLineAlpha(x1, y1, x2, y2, col, alpha) ⇒ Object Also known as: draw_line_alpha



99
100
101
# File 'lib/rubysdl_compatible_ver1.rb', line 99

def drawLineAlpha(x1, y1, x2, y2, col, alpha)
  drawLine(x1, y1, x2, y2, col, false, alpha)
end

#drawRectAlpha(x1, y1, x2, y2, color, alpha) ⇒ Object Also known as: draw_rect_alpha



124
125
126
# File 'lib/rubysdl_compatible_ver1.rb', line 124

def drawRectAlpha(x1, y1, x2, y2, color, alpha)
  drawRect(x1, y1, x2, y2, color, false, alpha)
end

#getPaletteObject Also known as: get_palette



80
81
82
# File 'lib/rubysdl_compatible_ver1.rb', line 80

def getPalette
  format.palette
end

#put(surface, x, y) ⇒ Object



24
25
26
# File 'lib/sdl.rb', line 24

def put(surface,x,y)
  SDL::Surface.blit(surface,0,0,surface.w,surface.h,self,x,y)
end