File: sgetest.rb

package info (click to toggle)
ruby-sdl 2.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,344 kB
  • ctags: 4,200
  • sloc: cpp: 7,598; ansic: 4,475; ruby: 2,258; sh: 102; makefile: 97
file content (34 lines) | stat: -rw-r--r-- 845 bytes parent folder | download | duplicates (3)
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
require 'sdl'

SDL.init( SDL::INIT_VIDEO )
screen = SDL::Screen.open(640,480,16,SDL::SWSURFACE)
SDL::WM.set_caption $0, $0

format = screen.format
# draw red pixel at (200,200)
screen[200,200]= format.map_rgb(255,0,0)
# draw green pixel at (250,200)
screen[250,200]= format.map_rgb(0,255,0)
# draw blue pixel at (200,200)
screen[300,200]= format.map_rgb(0,0,255)

Red=format.map_rgb(255,0,0)
screen.draw_line(20,20,300,200,Red)
screen.draw_rect(49,59,80,80,Red)
screen.draw_circle(100,100,50,[87,87,87])
screen.draw_circle(300,300,30,Red, true)
screen.draw_circle(230, 300, 30, Red, true, true)

screen.draw_bezier(100, 100, 150, 200, 300, 150, 400, 200, 7, [255, 255,255], true, 128)
screen.flip

while true
  while event = SDL::Event.poll
    case event
    when SDL::Event::KeyDown, SDL::Event::Quit
      exit
    end
  end

  sleep 0.2
end