gosu_more_drawables 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +8 -8
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +39 -39
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/gosu_more_drawables.gemspec +33 -33
- data/lib/gosu_more_drawables/draw_arc.rb +94 -63
- data/lib/gosu_more_drawables/draw_circle.rb +30 -19
- data/lib/gosu_more_drawables/version.rb +3 -3
- data/lib/gosu_more_drawables.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a363874fb18dd5b045675f86bfa6f5f5912420e81aa284ca963415d177e3c1
|
4
|
+
data.tar.gz: 8df53570385f951ab1750843c18d921e9cca6c018118ee8dbcf99187938fdd8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 264661a4ca1155914f874abb0b277a2ddbe80313fe0f0f016c037668d5bf4343098e1be1a1eec629c391e1288da941e2f37a671988c495ad434d84f400654b0f
|
7
|
+
data.tar.gz: e704ea0d5ff1dabfdaf7835f7d118b48654363faa59d3997c6c9bc9bf57321cb45838afd12578783ceda44f5fafb2f43035ef5817ffe3cec87ece5c5ec05b59a
|
data/.gitignore
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/_yardoc/
|
4
|
-
/coverage/
|
5
|
-
/doc/
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/tmp/
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in gosu_more_drawables.gemspec
|
4
|
-
gemspec
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in gosu_more_drawables.gemspec
|
4
|
+
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020 Cyberarm
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Cyberarm
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
# GosuMoreDrawables
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gosu_more_drawables`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'gosu_more_drawables'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install gosu_more_drawables
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gosu_more_drawables.
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
1
|
+
# GosuMoreDrawables
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gosu_more_drawables`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'gosu_more_drawables'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install gosu_more_drawables
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gosu_more_drawables.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
-
end
|
9
|
-
|
10
|
-
task :default => :test
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :test
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "gosu_more_drawables"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gosu_more_drawables"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/gosu_more_drawables.gemspec
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
lib = File.expand_path("lib", __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "gosu_more_drawables/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "gosu_more_drawables"
|
7
|
-
spec.version = GosuMoreDrawables::VERSION
|
8
|
-
spec.authors = ["Cyberarm"]
|
9
|
-
spec.email = ["matthewlikesrobots@gmail.com"]
|
10
|
-
|
11
|
-
spec.summary = %q{Adds circles and arcs to Gosu}
|
12
|
-
spec.description = %q{Adds Gosu.draw_circle and Gosu.draw_arc for Gosu}
|
13
|
-
spec.homepage = "https://github.com/cyberarm/gosu_more_drawables"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
-
|
18
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
-
spec.metadata["source_code_uri"] = "https://github.com/cyberarm/gosu_more_drawables"
|
20
|
-
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
end
|
26
|
-
spec.bindir = "exe"
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = ["lib"]
|
29
|
-
|
30
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
-
end
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "gosu_more_drawables/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gosu_more_drawables"
|
7
|
+
spec.version = GosuMoreDrawables::VERSION
|
8
|
+
spec.authors = ["Cyberarm"]
|
9
|
+
spec.email = ["matthewlikesrobots@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Adds circles and arcs to Gosu}
|
12
|
+
spec.description = %q{Adds Gosu.draw_circle and Gosu.draw_arc for Gosu}
|
13
|
+
spec.homepage = "https://github.com/cyberarm/gosu_more_drawables"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/cyberarm/gosu_more_drawables"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
end
|
@@ -1,64 +1,95 @@
|
|
1
|
-
module Gosu
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
1
|
+
module Gosu
|
2
|
+
# Draw an arc around the point x and y.
|
3
|
+
#
|
4
|
+
# Color accepts the following: *Gosu::Color*, *Array* (with 2 colors), or a *Hash* with keys: _from:_ and _to:_ both colors.
|
5
|
+
#
|
6
|
+
# With a *Gosu::Color* the arc will be painted with color
|
7
|
+
#
|
8
|
+
# With an *Array* the first *Gosu::Color* with be the innermost color and the last *Gosu::Color* with be the outermost color
|
9
|
+
#
|
10
|
+
# With a *Hash* the arc will smoothly transition from the start of the arc to the end
|
11
|
+
# @example
|
12
|
+
# # Using a Hash
|
13
|
+
# Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, {from: Gosu::Color::BLUE, to: Gosu::Color::GREEN}, 0, :default)
|
14
|
+
#
|
15
|
+
# # Using an Array
|
16
|
+
# Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, [Gosu::Color::BLUE, Gosu::Color::GREEN], 0, :default)
|
17
|
+
#
|
18
|
+
# # Using a Gosu::Color
|
19
|
+
# Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, Gosu::Color::BLUE, 0, :default)
|
20
|
+
#
|
21
|
+
#
|
22
|
+
# @param x X position.
|
23
|
+
# @param y Y position.
|
24
|
+
# @param radius radius of arc, in pixels.
|
25
|
+
# @param percentage how complete the segment is, __0.0 is 0% and _1.0_ is 100%.
|
26
|
+
# @param segments how many segments for arc, more will appear smoother, less will appear jagged.
|
27
|
+
# @param thickness how thick arc will be.
|
28
|
+
# @param color [Gosu::Color, Array<Gosu::Color, Gosu::Color>, Hash{from: start_color, to: end_color}] color or colors to draw the arc with.
|
29
|
+
# @param z Z position.
|
30
|
+
# @param mode blend mode.
|
31
|
+
#
|
32
|
+
# @note _thickness_ is subtracted from radius, meaning that the arc will grow towards the origin, not away from it.
|
33
|
+
#
|
34
|
+
# @return [void]
|
35
|
+
def self.draw_arc(x, y, radius, percentage = 1.0, segments = 128, thickness = 4, color = Gosu::Color::WHITE, z = 0, mode = :default)
|
36
|
+
segments = 360.0 / segments
|
37
|
+
|
38
|
+
return if percentage == 0.0
|
39
|
+
|
40
|
+
0.step((359 * percentage), segments) do |angle|
|
41
|
+
angle2 = angle + segments
|
42
|
+
|
43
|
+
point_a_left_x = x + Gosu.offset_x(angle, radius - thickness)
|
44
|
+
point_a_left_y = y + Gosu.offset_y(angle, radius - thickness)
|
45
|
+
|
46
|
+
point_a_right_x = x + Gosu.offset_x(angle2, radius - thickness)
|
47
|
+
point_a_right_y = y + Gosu.offset_y(angle2, radius - thickness)
|
48
|
+
|
49
|
+
point_b_left_x = x + Gosu.offset_x(angle, radius)
|
50
|
+
point_b_left_y = y + Gosu.offset_y(angle, radius)
|
51
|
+
|
52
|
+
point_b_right_x = x + Gosu.offset_x(angle2, radius)
|
53
|
+
point_b_right_y = y + Gosu.offset_y(angle2, radius)
|
54
|
+
|
55
|
+
if color.is_a?(Array)
|
56
|
+
Gosu.draw_quad(
|
57
|
+
point_a_left_x, point_a_left_y, color.first,
|
58
|
+
point_b_left_x, point_b_left_y, color.last,
|
59
|
+
point_a_right_x, point_a_right_y, color.first,
|
60
|
+
point_b_right_x, point_b_right_y, color.last
|
61
|
+
)
|
62
|
+
elsif color.is_a?(Hash)
|
63
|
+
start_color = color[:from]
|
64
|
+
end_color = color[:to]
|
65
|
+
|
66
|
+
color_a = Gosu::Color.rgba(
|
67
|
+
(end_color.red - start_color.red) * (angle / 360.0) + start_color.red,
|
68
|
+
(end_color.green - start_color.green) * (angle / 360.0) + start_color.green,
|
69
|
+
(end_color.blue - start_color.blue) * (angle / 360.0) + start_color.blue,
|
70
|
+
(end_color.alpha - start_color.alpha) * (angle / 360.0) + start_color.alpha,
|
71
|
+
)
|
72
|
+
color_b = Gosu::Color.rgba(
|
73
|
+
(end_color.red - start_color.red) * (angle2 / 360.0) + start_color.red,
|
74
|
+
(end_color.green - start_color.green) * (angle2 / 360.0) + start_color.green,
|
75
|
+
(end_color.blue - start_color.blue) * (angle2 / 360.0) + start_color.blue,
|
76
|
+
(end_color.alpha - start_color.alpha) * (angle2 / 360.0) + start_color.alpha,
|
77
|
+
)
|
78
|
+
|
79
|
+
Gosu.draw_quad(
|
80
|
+
point_a_left_x, point_a_left_y, color_a,
|
81
|
+
point_b_left_x, point_b_left_y, color_a,
|
82
|
+
point_a_right_x, point_a_right_y, color_b,
|
83
|
+
point_b_right_x, point_b_right_y, color_b
|
84
|
+
)
|
85
|
+
else
|
86
|
+
Gosu.draw_quad(
|
87
|
+
point_a_left_x, point_a_left_y, color,
|
88
|
+
point_b_left_x, point_b_left_y, color,
|
89
|
+
point_a_right_x, point_a_right_y, color,
|
90
|
+
point_b_right_x, point_b_right_y, color
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
64
95
|
end
|
@@ -1,20 +1,31 @@
|
|
1
|
-
module Gosu
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
module Gosu
|
2
|
+
##
|
3
|
+
# Draw a filled circled around point X and Y.
|
4
|
+
#
|
5
|
+
# @param x X position.
|
6
|
+
# @param y Y position.
|
7
|
+
# @param radius radius of circle, in pixels.
|
8
|
+
# @param step_size resolution of circle, more steps will apear smoother, less will appear jagged.
|
9
|
+
# @param color color to draw circle with.
|
10
|
+
# @param mode blend mode.
|
11
|
+
#
|
12
|
+
# @return [void]
|
13
|
+
def self.draw_circle(x, y, radius, step_size = 36, color = Gosu::Color::WHITE, z = 0, mode = :default)
|
14
|
+
step_size = (360.0 / step_size).floor
|
15
|
+
|
16
|
+
0.step(359, step_size) do |angle|
|
17
|
+
angle2 = angle + step_size
|
18
|
+
|
19
|
+
point_lx = x + Gosu.offset_x(angle, radius)
|
20
|
+
point_ly = y + Gosu.offset_y(angle, radius)
|
21
|
+
point_rx = x + Gosu.offset_x(angle2, radius)
|
22
|
+
point_ry = y + Gosu.offset_y(angle2, radius)
|
23
|
+
|
24
|
+
Gosu.draw_triangle(
|
25
|
+
point_lx, point_ly, color,
|
26
|
+
point_rx, point_ry, color,
|
27
|
+
x, y, color, z, mode
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
20
31
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module GosuMoreDrawables
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
1
|
+
module GosuMoreDrawables
|
2
|
+
VERSION = "0.2.0"
|
3
|
+
end
|
data/lib/gosu_more_drawables.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require_relative "gosu_more_drawables/draw_arc"
|
2
|
-
require_relative "gosu_more_drawables/draw_circle"
|
3
|
-
require_relative "gosu_more_drawables/version"
|
1
|
+
require_relative "gosu_more_drawables/draw_arc"
|
2
|
+
require_relative "gosu_more_drawables/draw_circle"
|
3
|
+
require_relative "gosu_more_drawables/version"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosu_more_drawables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyberarm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
96
|
+
rubygems_version: 3.1.2
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Adds circles and arcs to Gosu
|