edu_draw 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +72 -73
  3. data/examples/animations.rb +1 -1
  4. metadata +6 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfc3b98dd75cc8bba96e5c4232b6fd63af037220
4
- data.tar.gz: 7ad1c99a69f9146c9ec8b9c2fdc8d3d58c1591ea
3
+ metadata.gz: 2933de9336d411206319c9eca057e7d3606ec48a
4
+ data.tar.gz: 0ca6d99f9bb2f58f6f5a900fe577e108250ef970
5
5
  SHA512:
6
- metadata.gz: 94cdaeefbc9b682466f99041b32632e0fcb167f92140cd4d363d6cb67c6926e52b8a25f14d7191a7bf636207213aa7c4e23839bbf1a0f8bc1da7b0bea93d3851
7
- data.tar.gz: 1516ae2a65123eebbe63a900f9500d744635c320cf71c79e08b34ce00d17c59f085cce7a65d6afd42ce9c25613e7818e790e1ac89254e79cadff63cc1d6ac10e
6
+ metadata.gz: 40ec8360a716f3a9fed464665f731fd1ce2ab04067a4cbdb211755b4c5a4cfba8251dfcaed6fed88bfd5c885a78520d6f9e9a472d78ccaca5339825f39e837ae
7
+ data.tar.gz: 19e4c224ffab789f881fb246388522311ff06bebf728d40687423a5d69a845c2abb9f7f3ed3813b43af093061df6114427bedd845f368d527d5be6c84d4652ef
data/README.md CHANGED
@@ -2,7 +2,8 @@
2
2
  Simple ruby drawing API based on gosu meant for educational purposes.
3
3
 
4
4
  ## Install
5
- `gem install edu_draw`
5
+
6
+ gem install edu_draw
6
7
 
7
8
  If you run into any problems its most likely because of [gosu](https://github.com/jlnr/gosu/wiki/Ruby-Tutorial), as this is the only runtime dependency of edu_draw.
8
9
 
@@ -10,118 +11,116 @@ If you run into any problems its most likely because of [gosu](https://github.co
10
11
  There are only two classes: A sheet to draw on and a pen to draw with. The sheet is also the window. Unfortunately, the underlying engine only supports really one window, so you should only create one sheet per program. This is done as follows:
11
12
  First, load edu_draw into your program
12
13
 
13
- `require "edu_draw"`
14
+ require "edu_draw"
14
15
 
15
16
  Then, create the sheet
16
17
 
17
- `sheet = EduDraw::Sheet.new x: 500, y: 600, title: "It works"`
18
+ sheet = EduDraw::Sheet.new x: 500, y: 600, title: "It works"
18
19
 
19
20
  Now that you have a sheet, that is 500 pixels wide and 600 pixels high, you can create pens for this sheet to draw on.
20
21
 
21
- `green_pen = sheet.new_pen x: 100, y: 20`
22
+ green_pen = sheet.new_pen x: 100, y: 20
22
23
 
23
24
  Green is the default color for pens but you can have any color using the `color` parameter.
24
25
 
25
26
  Now it's time to draw a rectangle!
26
27
 
27
- ```
28
- green_pen.move 100
29
- green_pen.turn_right 90
30
- green_pen.move 80
31
- green_pen.turn_right 90
32
- green_pen.move 100
33
- green_pen.turn_right 90
34
- green_pen.move 80
35
- ```
28
+
29
+ green_pen.move 100
30
+ green_pen.turn_right 90
31
+ green_pen.move 80
32
+ green_pen.turn_right 90
33
+ green_pen.move 100
34
+ green_pen.turn_right 90
35
+ green_pen.move 80
36
36
 
37
37
 
38
38
  When you are done drawing, you have to make one final call to the sheet, to actually display the window with your drawings.
39
39
 
40
- `sheet.show`
40
+ sheet.show
41
41
 
42
42
  The whole program looks like this:
43
43
 
44
- ```ruby
45
- require "edu_draw"
46
44
 
47
- sheet = EduDraw::Sheet.new x: 500, y: 600, title: "A beautiful rectangle"
48
- green_pen = sheet.new_pen(x: 100, y: 20)
45
+ require "edu_draw"
49
46
 
50
- green_pen.move 100
51
- green_pen.turn_right 90
52
- green_pen.move 80
53
- green_pen.turn_right 90
54
- green_pen.move 100
55
- green_pen.turn_right 90
56
- green_pen.move 80
47
+ sheet = EduDraw::Sheet.new x: 500, y: 600, title: "A beautiful rectangle"
48
+ green_pen = sheet.new_pen(x: 100, y: 20)
57
49
 
58
- sheet.show
59
- ```
50
+ green_pen.move 100
51
+ green_pen.turn_right 90
52
+ green_pen.move 80
53
+ green_pen.turn_right 90
54
+ green_pen.move 100
55
+ green_pen.turn_right 90
56
+ green_pen.move 80
57
+
58
+ sheet.show
60
59
 
61
60
  ### Areas / Filled shapes
62
61
  You can also draw filled or party-filled shapes. Here is an short example, that can be also found in the examples folder:
63
- ```ruby
64
- require "edu_draw"
65
62
 
66
- sheet = EduDraw::Sheet.new(x: 150, y: 150)
67
- pen = sheet.new_pen(x: 52, y: 10)
63
+ require "edu_draw"
64
+
65
+ sheet = EduDraw::Sheet.new(x: 150, y: 150)
66
+ pen = sheet.new_pen(x: 52, y: 10)
68
67
 
69
- # Every move in the fill-block will create a filled a shape
70
- pen.fill do
71
- 5.times do
72
- pen.move 40
73
- pen.turn_right 36
74
- end
75
- end
68
+ # Every move in the fill-block will create a filled a shape
69
+ pen.fill do
70
+ 5.times do
71
+ pen.move 40
72
+ pen.turn_right 36
73
+ end
74
+ end
76
75
 
77
- #Every move out of the fill block just draws a line
78
- # Those 10 moves result in a half-filled decagon
79
- 5.times do
80
- pen.move 40
81
- pen.turn_right 36
82
- end
76
+ # Every move out of the fill block just draws a line
77
+ # Those 10 moves result in a half-filled decagon
78
+ 5.times do
79
+ pen.move 40
80
+ pen.turn_right 36
81
+ end
83
82
 
84
83
 
85
- sheet.show
86
- ```
84
+ sheet.show
85
+
87
86
 
88
87
  ### Animations
89
88
  You can even draw animated shapes. Here is an short example, that can be also found in the examples folder:
90
- ```ruby
91
- require "edu_draw"
92
89
 
93
- sheet = EduDraw::Sheet.new(x: 150, y: 150)
90
+ require "edu_draw"
91
+
92
+ sheet = EduDraw::Sheet.new(x: 150, y: 150)
93
+
94
+ # Instead of using sheet.new_pen, now you create a new_animation_pen
95
+ pen = sheet.new_animation_pen(x: 75, y: 75)
94
96
 
95
- # Instead of using sheet.new_pen, now you create a new_animation_pen
96
- pen = sheet.new_animation_pen(x: 75, y: 75)
97
+ # Here you define what happens in the beginning of each frame
98
+ pen.each_frame do
99
+ pen.turn_right 1
100
+ end
97
101
 
98
- # Here you define what happens in the beginning of each frame
99
- pen.each_frame do
100
- pen.turn_right 1
101
- end
102
+ # Now you define what the pen should draw each frame
103
+ # It is important to leave the pen in a state, where
104
+ # it can start drawing on the next frame, that's why
105
+ # the pens moves back, even though it does not draw
106
+ # any actual lines.
107
+ pen.draw_frame do
108
+ pen.move 50
109
+ pen.move -50
110
+ end
102
111
 
103
- # Now you define what the pen should draw each frame
104
- # It is important to leave the pen in a state, where
105
- # it can start drawing on the next frame, that's why
106
- # the pens moves back, even though it does not draw
107
- # any actual lines.
108
- pen.draw_frame do
109
- pen.move 50
110
- pen.move -50
111
- end
112
112
 
113
+ # You're set. Now just show the sheet as usual and enjoy
114
+ # the wonderfully spinning line you just drew.
115
+ sheet.show
113
116
 
114
- # You're set. No just show the sheet as usual and enjoy
115
- # the wonderfully spinning line you just drew.
116
- sheet.show
117
- ```
118
117
 
119
118
  ## Changelog
120
- * 2.0.0
121
- * Adds ability to fill shapes. See `examples/areas.rb`
122
- * Adds ability to draw animated shapes. See `examples/animations.rb`
123
- * Makes state of pen writable
124
- * Greatly improves documentation
119
+ - 2.0.0
120
+ - Adds ability to fill shapes. See `examples/areas.rb`
121
+ - Adds ability to draw animated shapes. See `examples/animations.rb`
122
+ - Makes state of pen writable
123
+ - Greatly improves documentation
125
124
 
126
125
  ## Contributing
127
126
  Feel free to contribute anything, may it be better tests, better documentation or more features. As you can see, I tried to keep the code tidy so it is appreciated if you'd do the same. Just add a pull request and we will make it work. Oh, and don't forget to have fun ;)
@@ -21,6 +21,6 @@ pen.draw_frame do
21
21
  end
22
22
 
23
23
 
24
- # You're set. No just show the sheet as usual and enjoy
24
+ # You're set. Now just show the sheet as usual and enjoy
25
25
  # the wonderfully spinning line you just drew.
26
26
  sheet.show
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edu_draw
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Ede
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-18 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu
@@ -80,14 +80,15 @@ licenses:
80
80
  - MIT
81
81
  metadata: {}
82
82
  post_install_message:
83
- rdoc_options: []
83
+ rdoc_options:
84
+ - "--no-private"
84
85
  require_paths:
85
86
  - lib
86
87
  required_ruby_version: !ruby/object:Gem::Requirement
87
88
  requirements:
88
89
  - - ">="
89
90
  - !ruby/object:Gem::Version
90
- version: '0'
91
+ version: '2'
91
92
  required_rubygems_version: !ruby/object:Gem::Requirement
92
93
  requirements:
93
94
  - - ">="
@@ -100,4 +101,4 @@ signing_key:
100
101
  specification_version: 4
101
102
  summary: Offers a simple API to open a window and draw in it
102
103
  test_files: []
103
- has_rdoc:
104
+ has_rdoc: yard