cwiid 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. data/README.md +44 -18
  2. data/Rakefile +1 -1
  3. metadata +3 -3
data/README.md CHANGED
@@ -31,27 +31,53 @@ Simply run Interactive Ruby:
31
31
 
32
32
  Here's a small example displaying the state of the accelerometer:
33
33
 
34
- #!/usr/bin/env ruby
35
34
  require 'rubygems'
35
+ require 'opengl'
36
36
  require 'cwiid'
37
- require 'hornetseye_rmagick'
38
- require 'hornetseye_xorg'
39
- include Hornetseye
40
- include Magick
41
37
  wiimote = WiiMote.new
42
- X11Display.show do |display|
43
- display.status = wiimote.buttons != WiiMote::BTN_1
44
- wiimote.get_state
38
+ display = proc do
45
39
  acc = wiimote.acc
46
- image = Image.new 240, 240, HatchFill.new( 'white', 'lightcyan2' )
47
- gc = Draw.new
48
- gc.fill_opacity 0
49
- gc.stroke_width 2
50
- gc.stroke 'red'
51
- gc.line 120, 120, acc[0], acc[2]
52
- gc.stroke 'green'
53
- gc.line 120, 120, acc[1], acc[2]
54
- gc.draw image
55
- image.to_multiarray
40
+ glClear GL_COLOR_BUFFER_BIT
41
+ glLineWidth 3.0
42
+ glColor 1.0, 0.0, 0.0
43
+ glBegin GL_LINES
44
+ glVertex 120, 120
45
+ glVertex acc[0], acc[2]
46
+ glEnd
47
+ glColor 0.0, 1.0, 0.0
48
+ glBegin GL_LINES
49
+ glVertex 120, 120
50
+ glVertex acc[1], acc[2]
51
+ glEnd
52
+ glutSwapBuffers
53
+ end
54
+ reshape = proc do |w, h|
55
+ glViewport 0, 0, w, h
56
+ glMatrixMode GL_PROJECTION
57
+ glLoadIdentity
58
+ GLU.Ortho2D 0.0, w, 0.0, h
59
+ end
60
+ keyboard = proc do |key, x, y|
61
+ case key
62
+ when ?\e
63
+ exit 0
64
+ end
65
+ end
66
+ animate = proc do
67
+ wiimote.get_state
68
+ exit 0 if wiimote.buttons == WiiMote::BTN_1
69
+ glutPostRedisplay
56
70
  end
71
+ glutInit
72
+ glutInitDisplayMode GLUT_DOUBLE | GLUT_RGB
73
+ glutInitWindowSize 240, 240
74
+ glutCreateWindow 'Wii Remote'
75
+ glClearColor 1.0, 1.0, 1.0, 0.0
76
+ glShadeModel GL_FLAT
77
+
78
+ glutDisplayFunc display
79
+ glutReshapeFunc reshape
80
+ glutKeyboardFunc keyboard
81
+ glutIdleFunc animate
82
+ glutMainLoop
57
83
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'cwiid'
10
- PKG_VERSION = '0.1.0'
10
+ PKG_VERSION = '0.1.1'
11
11
  CFG = RbConfig::CONFIG
12
12
  CXX = ENV[ 'CXX' ] || 'g++'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-24 00:00:00 +00:00
17
+ date: 2010-12-25 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency