gosu_more_drawables 0.3.0 → 0.3.1
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 +55 -55
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/examples/circle_with_arc_border.rb +15 -15
- data/gosu_more_drawables.gemspec +34 -34
- data/lib/gosu_more_drawables.rb +4 -4
- data/lib/gosu_more_drawables/draw_arc.rb +97 -97
- data/lib/gosu_more_drawables/draw_circle.rb +30 -30
- data/lib/gosu_more_drawables/version.rb +3 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff59071666b8d755c82ad42e815450e78db243832d0f0eb3e5867a8acacec56f
|
4
|
+
data.tar.gz: e3f8f3293dea739f3f36c83544ed81c4e42544e1200abd55455cd24956ca038e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91ef4132f0bb1a23ee609636d5b1b11ef621af949f76b3b82d5d5f236bb53b0925c97f989c9f56ac394bbeb0e476f5cc914bdd062d2e1cfb43bee382927b935e
|
7
|
+
data.tar.gz: 3739156c1bd2cb5acb1bfda74f551b1addb7bb0f9f2c6a2f0d154714546ee3dd441aaa3bcfc299ae8809cb17fc0c37a9f1f5a89c2007089b1bc37955faff2f5b
|
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,55 +1,55 @@
|
|
1
|
-
# GosuMoreDrawables
|
2
|
-
|
3
|
-
Adds `Gosu.draw_circle` and `Gosu.draw_arc` to the Gosu game library.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'gosu_more_drawables'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install gosu_more_drawables
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
``` ruby
|
24
|
-
require "gosu"
|
25
|
-
require "gosu_more_drawables"
|
26
|
-
|
27
|
-
class DemoWindow < Gosu::Window
|
28
|
-
def initialize
|
29
|
-
super(500, 500, false)
|
30
|
-
end
|
31
|
-
|
32
|
-
def draw
|
33
|
-
Gosu.draw_circle(250, 250, 200, 128, Gosu::Color.rgb(0, 200, 0))
|
34
|
-
Gosu.draw_arc(250, 250, 200, 1.0, 128, 4, Gosu::Color.rgba(127, 64, 0, 100))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
DemoWindow.new.show
|
39
|
-
```
|
40
|
-
|
41
|
-
![screenshot of example](https://raw.githubusercontent.com/cyberarm/gosu_more_drawables/master/media/screenshot.png)
|
42
|
-
|
43
|
-
## Development
|
44
|
-
|
45
|
-
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.
|
46
|
-
|
47
|
-
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).
|
48
|
-
|
49
|
-
## Contributing
|
50
|
-
|
51
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/cyberarm/gosu_more_drawables.
|
52
|
-
|
53
|
-
## License
|
54
|
-
|
55
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
1
|
+
# GosuMoreDrawables
|
2
|
+
|
3
|
+
Adds `Gosu.draw_circle` and `Gosu.draw_arc` to the Gosu game library.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'gosu_more_drawables'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install gosu_more_drawables
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
require "gosu"
|
25
|
+
require "gosu_more_drawables"
|
26
|
+
|
27
|
+
class DemoWindow < Gosu::Window
|
28
|
+
def initialize
|
29
|
+
super(500, 500, false)
|
30
|
+
end
|
31
|
+
|
32
|
+
def draw
|
33
|
+
Gosu.draw_circle(250, 250, 200, 128, Gosu::Color.rgb(0, 200, 0))
|
34
|
+
Gosu.draw_arc(250, 250, 200, 1.0, 128, 4, Gosu::Color.rgba(127, 64, 0, 100))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
DemoWindow.new.show
|
39
|
+
```
|
40
|
+
|
41
|
+
![screenshot of example](https://raw.githubusercontent.com/cyberarm/gosu_more_drawables/master/media/screenshot.png)
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
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.
|
46
|
+
|
47
|
+
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).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cyberarm/gosu_more_drawables.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
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
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require "gosu"
|
2
|
-
require "gosu_more_drawables"
|
3
|
-
|
4
|
-
class DemoWindow < Gosu::Window
|
5
|
-
def initialize
|
6
|
-
super(500, 500, false)
|
7
|
-
end
|
8
|
-
|
9
|
-
def draw
|
10
|
-
Gosu.draw_circle(250, 250, 200, 128, Gosu::Color.rgb(0, 200, 0))
|
11
|
-
Gosu.draw_arc(250, 250, 200, 1.0, 128, 4, Gosu::Color.rgba(127, 64, 0, 100))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
DemoWindow.new.show
|
1
|
+
require "gosu"
|
2
|
+
require "gosu_more_drawables"
|
3
|
+
|
4
|
+
class DemoWindow < Gosu::Window
|
5
|
+
def initialize
|
6
|
+
super(500, 500, false)
|
7
|
+
end
|
8
|
+
|
9
|
+
def draw
|
10
|
+
Gosu.draw_circle(250, 250, 200, 128, Gosu::Color.rgb(0, 200, 0))
|
11
|
+
Gosu.draw_arc(250, 250, 200, 1.0, 128, 4, Gosu::Color.rgba(127, 64, 0, 100))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
DemoWindow.new.show
|
data/gosu_more_drawables.gemspec
CHANGED
@@ -1,34 +1,34 @@
|
|
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
|
-
spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/gosu_more_drawables"
|
21
|
-
|
22
|
-
# Specify which files should be added to the gem when it is released.
|
23
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
-
end
|
27
|
-
spec.bindir = "exe"
|
28
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
-
spec.require_paths = ["lib"]
|
30
|
-
|
31
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
32
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
34
|
-
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
|
+
spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/gosu_more_drawables"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
34
|
+
end
|
data/lib/gosu_more_drawables.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative "gosu_more_drawables/draw_arc"
|
2
|
-
require_relative "gosu_more_drawables/draw_path"
|
3
|
-
require_relative "gosu_more_drawables/draw_circle"
|
4
|
-
require_relative "gosu_more_drawables/version"
|
1
|
+
require_relative "gosu_more_drawables/draw_arc"
|
2
|
+
require_relative "gosu_more_drawables/draw_path"
|
3
|
+
require_relative "gosu_more_drawables/draw_circle"
|
4
|
+
require_relative "gosu_more_drawables/version"
|
@@ -1,98 +1,98 @@
|
|
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
|
-
z, mode
|
62
|
-
)
|
63
|
-
elsif color.is_a?(Hash)
|
64
|
-
start_color = color[:from]
|
65
|
-
end_color = color[:to]
|
66
|
-
|
67
|
-
color_a = Gosu::Color.rgba(
|
68
|
-
(end_color.red - start_color.red) * (angle / 360.0) + start_color.red,
|
69
|
-
(end_color.green - start_color.green) * (angle / 360.0) + start_color.green,
|
70
|
-
(end_color.blue - start_color.blue) * (angle / 360.0) + start_color.blue,
|
71
|
-
(end_color.alpha - start_color.alpha) * (angle / 360.0) + start_color.alpha,
|
72
|
-
)
|
73
|
-
color_b = Gosu::Color.rgba(
|
74
|
-
(end_color.red - start_color.red) * (angle2 / 360.0) + start_color.red,
|
75
|
-
(end_color.green - start_color.green) * (angle2 / 360.0) + start_color.green,
|
76
|
-
(end_color.blue - start_color.blue) * (angle2 / 360.0) + start_color.blue,
|
77
|
-
(end_color.alpha - start_color.alpha) * (angle2 / 360.0) + start_color.alpha,
|
78
|
-
)
|
79
|
-
|
80
|
-
Gosu.draw_quad(
|
81
|
-
point_a_left_x, point_a_left_y, color_a,
|
82
|
-
point_b_left_x, point_b_left_y, color_a,
|
83
|
-
point_a_right_x, point_a_right_y, color_b,
|
84
|
-
point_b_right_x, point_b_right_y, color_b,
|
85
|
-
z, mode
|
86
|
-
)
|
87
|
-
else
|
88
|
-
Gosu.draw_quad(
|
89
|
-
point_a_left_x, point_a_left_y, color,
|
90
|
-
point_b_left_x, point_b_left_y, color,
|
91
|
-
point_a_right_x, point_a_right_y, color,
|
92
|
-
point_b_right_x, point_b_right_y, color,
|
93
|
-
z, mode
|
94
|
-
)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
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), percentage > 0 ? segments : -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
|
+
z, mode
|
62
|
+
)
|
63
|
+
elsif color.is_a?(Hash)
|
64
|
+
start_color = color[:from]
|
65
|
+
end_color = color[:to]
|
66
|
+
|
67
|
+
color_a = Gosu::Color.rgba(
|
68
|
+
(end_color.red - start_color.red) * (angle / 360.0) + start_color.red,
|
69
|
+
(end_color.green - start_color.green) * (angle / 360.0) + start_color.green,
|
70
|
+
(end_color.blue - start_color.blue) * (angle / 360.0) + start_color.blue,
|
71
|
+
(end_color.alpha - start_color.alpha) * (angle / 360.0) + start_color.alpha,
|
72
|
+
)
|
73
|
+
color_b = Gosu::Color.rgba(
|
74
|
+
(end_color.red - start_color.red) * (angle2 / 360.0) + start_color.red,
|
75
|
+
(end_color.green - start_color.green) * (angle2 / 360.0) + start_color.green,
|
76
|
+
(end_color.blue - start_color.blue) * (angle2 / 360.0) + start_color.blue,
|
77
|
+
(end_color.alpha - start_color.alpha) * (angle2 / 360.0) + start_color.alpha,
|
78
|
+
)
|
79
|
+
|
80
|
+
Gosu.draw_quad(
|
81
|
+
point_a_left_x, point_a_left_y, color_a,
|
82
|
+
point_b_left_x, point_b_left_y, color_a,
|
83
|
+
point_a_right_x, point_a_right_y, color_b,
|
84
|
+
point_b_right_x, point_b_right_y, color_b,
|
85
|
+
z, mode
|
86
|
+
)
|
87
|
+
else
|
88
|
+
Gosu.draw_quad(
|
89
|
+
point_a_left_x, point_a_left_y, color,
|
90
|
+
point_b_left_x, point_b_left_y, color,
|
91
|
+
point_a_right_x, point_a_right_y, color,
|
92
|
+
point_b_right_x, point_b_right_y, color,
|
93
|
+
z, mode
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
98
|
end
|
@@ -1,31 +1,31 @@
|
|
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
|
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
|
31
31
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module GosuMoreDrawables
|
2
|
-
VERSION = "0.3.
|
3
|
-
end
|
1
|
+
module GosuMoreDrawables
|
2
|
+
VERSION = "0.3.1"
|
3
|
+
end
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyberarm
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,7 +83,7 @@ metadata:
|
|
83
83
|
homepage_uri: https://github.com/cyberarm/gosu_more_drawables
|
84
84
|
source_code_uri: https://github.com/cyberarm/gosu_more_drawables
|
85
85
|
documentation_uri: https://rubydoc.info/gems/gosu_more_drawables
|
86
|
-
post_install_message:
|
86
|
+
post_install_message:
|
87
87
|
rdoc_options: []
|
88
88
|
require_paths:
|
89
89
|
- lib
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubygems_version: 3.1.2
|
102
|
-
signing_key:
|
102
|
+
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Adds circles and arcs to Gosu
|
105
105
|
test_files: []
|