panda_canvas 0.1.0
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.
- data/LICENSE +19 -0
- data/README.rdoc +10 -0
- data/lib/panda_canvas/version.rb +6 -0
- data/lib/panda_canvas.rb +50 -0
- metadata +100 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Dimitry Solovyov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
= Panda Canvas
|
2
|
+
|
3
|
+
Panda Canvas is an educational 2D drawing canvas on top of Gosu and TexPlay.
|
4
|
+
It is created as a teaching tool for the {Computer Club n.a. 8-bit Panda}[http://panda.tsi.lv]
|
5
|
+
|
6
|
+
== Installation
|
7
|
+
|
8
|
+
Panda Canvas is available as a gem:
|
9
|
+
|
10
|
+
$ gem install panda_canvas
|
data/lib/panda_canvas.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'texplay'
|
2
|
+
|
3
|
+
class PandaCanvas < Gosu::Window
|
4
|
+
|
5
|
+
# Creates a new canvas window with dimensions +width+ and +height+.
|
6
|
+
# A list of +commands+ of the form +[:method, [*args]]+ is passed to be executed.
|
7
|
+
def initialize(width, height, commands)
|
8
|
+
super(width, height, false)
|
9
|
+
self.caption = 'Panda Canvas'
|
10
|
+
@image = TexPlay.create_image(self, width, height)
|
11
|
+
@commands = commands
|
12
|
+
end
|
13
|
+
|
14
|
+
# Runs a range of commands until the next flush.
|
15
|
+
def update
|
16
|
+
unless @commands.empty?
|
17
|
+
@commands.slice!(0...@commands.index(FLUSH_SIGNATURE)).each do |command|
|
18
|
+
@image.send command[0], *command[1]
|
19
|
+
end
|
20
|
+
@commands.shift
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Draws the image in memory.
|
25
|
+
def draw
|
26
|
+
@image.draw(0, 0, 0)
|
27
|
+
end
|
28
|
+
|
29
|
+
end # end PandaCanvas
|
30
|
+
|
31
|
+
__width__ = 640
|
32
|
+
__height__ = 480
|
33
|
+
__commands__ = []
|
34
|
+
IMAGE_METHODS = (Gosu::Image.public_instance_methods + [:flush]).freeze
|
35
|
+
FLUSH_SIGNATURE = [:flush, []].freeze
|
36
|
+
|
37
|
+
self.class.instance_eval do
|
38
|
+
define_method(:method_missing) do |sym, *args|
|
39
|
+
if IMAGE_METHODS.include? sym
|
40
|
+
__commands__ << [sym, args]
|
41
|
+
else
|
42
|
+
super(sym, *args)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
at_exit do
|
48
|
+
__commands__ << FLUSH_SIGNATURE
|
49
|
+
PandaCanvas.new(__width__, __height__, __commands__).show if $!.nil?
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: panda_canvas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Dimitry Solovyov
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-20 00:00:00 +03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: gosu
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 7
|
31
|
+
- 24
|
32
|
+
version: 0.7.24
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: texplay
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 2
|
46
|
+
- 981
|
47
|
+
version: 0.2.981
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
description: Educational 2D drawing canvas on top of Gosu and TexPlay.
|
51
|
+
email:
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- lib/panda_canvas/version.rb
|
60
|
+
- lib/panda_canvas.rb
|
61
|
+
- LICENSE
|
62
|
+
- README.rdoc
|
63
|
+
has_rdoc: true
|
64
|
+
homepage:
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 1
|
79
|
+
- 9
|
80
|
+
- 2
|
81
|
+
version: 1.9.2
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
segments:
|
88
|
+
- 1
|
89
|
+
- 3
|
90
|
+
- 6
|
91
|
+
version: 1.3.6
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 1.3.7
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: Educational 2D drawing canvas on top of Gosu and TexPlay.
|
99
|
+
test_files: []
|
100
|
+
|