gosu_more_drawables 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4ec007dfd8eca24b8cbb5afa197f310ed1457e41bb5b83a94368f38d63d10116
4
+ data.tar.gz: 441048e8c1eda429610704b42e5d4e052784ea86794500195d47c8976c31b32f
5
+ SHA512:
6
+ metadata.gz: d3871f25e8f8e9474db6211cd5a819c5e022edc8d2c2dd7bf34838fb30f395a1880be0087950be7090410e8629179b6b3fed687dcb4e011b65be90d97450fd18
7
+ data.tar.gz: 8effdd030f874ba90458c7b7a075a9cfe2f59d71c4d631b55e042fccd2dfb9dd621ea4fdf59441de22670501c000638d3a619b6d2692d1c81fe44e68dcac921a
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in gosu_more_drawables.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +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.
data/README.md ADDED
@@ -0,0 +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).
data/Rakefile ADDED
@@ -0,0 +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
data/bin/console ADDED
@@ -0,0 +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__)
data/bin/setup ADDED
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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"
@@ -0,0 +1,64 @@
1
+ module Gosu
2
+ def self.draw_arc(x, y, z, radius, percentage = 1.0, segments = nil, thickness = 4, color = Gosu::Color::WHITE)
3
+ segments ||= 128
4
+
5
+ segments = 360.0 / segments
6
+
7
+ return if percentage == 0.0
8
+
9
+ 0.step((359 * percentage), segments) do |angle|
10
+ angle2 = angle + segments
11
+
12
+ point_a_left_x = x + Gosu.offset_x(angle, radius - thickness)
13
+ point_a_left_y = y + Gosu.offset_y(angle, radius - thickness)
14
+
15
+ point_a_right_x = x + Gosu.offset_x(angle2, radius - thickness)
16
+ point_a_right_y = y + Gosu.offset_y(angle2, radius - thickness)
17
+
18
+ point_b_left_x = x + Gosu.offset_x(angle, radius)
19
+ point_b_left_y = y + Gosu.offset_y(angle, radius)
20
+
21
+ point_b_right_x = x + Gosu.offset_x(angle2, radius)
22
+ point_b_right_y = y + Gosu.offset_y(angle2, radius)
23
+
24
+ if color.is_a?(Array)
25
+ Gosu.draw_quad(
26
+ point_a_left_x, point_a_left_y, color.first,
27
+ point_b_left_x, point_b_left_y, color.last,
28
+ point_a_right_x, point_a_right_y, color.first,
29
+ point_b_right_x, point_b_right_y, color.last
30
+ )
31
+ elsif color.is_a?(Hash)
32
+ start_color = color[:from]
33
+ end_color = color[:to]
34
+
35
+ color_a = Gosu::Color.rgba(
36
+ (end_color.red - start_color.red) * (angle / 360.0) + start_color.red,
37
+ (end_color.green - start_color.green) * (angle / 360.0) + start_color.green,
38
+ (end_color.blue - start_color.blue) * (angle / 360.0) + start_color.blue,
39
+ (end_color.alpha - start_color.alpha) * (angle / 360.0) + start_color.alpha,
40
+ )
41
+ color_b = Gosu::Color.rgba(
42
+ (end_color.red - start_color.red) * (angle2 / 360.0) + start_color.red,
43
+ (end_color.green - start_color.green) * (angle2 / 360.0) + start_color.green,
44
+ (end_color.blue - start_color.blue) * (angle2 / 360.0) + start_color.blue,
45
+ (end_color.alpha - start_color.alpha) * (angle2 / 360.0) + start_color.alpha,
46
+ )
47
+
48
+ Gosu.draw_quad(
49
+ point_a_left_x, point_a_left_y, color_a,
50
+ point_b_left_x, point_b_left_y, color_a,
51
+ point_a_right_x, point_a_right_y, color_b,
52
+ point_b_right_x, point_b_right_y, color_b
53
+ )
54
+ else
55
+ Gosu.draw_quad(
56
+ point_a_left_x, point_a_left_y, color,
57
+ point_b_left_x, point_b_left_y, color,
58
+ point_a_right_x, point_a_right_y, color,
59
+ point_b_right_x, point_b_right_y, color
60
+ )
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,20 @@
1
+ module Gosu
2
+ def self.draw_circle(x, y, z, radius, color = Gosu::Color::WHITE, step_size = 36)
3
+ step_size = (360.0/step_size).floor
4
+
5
+ 0.step(359, step_size) do |angle|
6
+ angle2 = angle + step_size
7
+
8
+ point_lx = x + Gosu.offset_x(angle, radius)
9
+ point_ly = y + Gosu.offset_y(angle, radius)
10
+ point_rx = x + Gosu.offset_x(angle2, radius)
11
+ point_ry = y + Gosu.offset_y(angle2, radius)
12
+
13
+ Gosu.draw_triangle(
14
+ point_lx, point_ly, color,
15
+ point_rx, point_ry, color,
16
+ x, y, color, z
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module GosuMoreDrawables
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gosu_more_drawables
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Cyberarm
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: Adds Gosu.draw_circle and Gosu.draw_arc for Gosu
56
+ email:
57
+ - matthewlikesrobots@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - gosu_more_drawables.gemspec
70
+ - lib/gosu_more_drawables.rb
71
+ - lib/gosu_more_drawables/draw_arc.rb
72
+ - lib/gosu_more_drawables/draw_circle.rb
73
+ - lib/gosu_more_drawables/version.rb
74
+ homepage: https://github.com/cyberarm/gosu_more_drawables
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ homepage_uri: https://github.com/cyberarm/gosu_more_drawables
80
+ source_code_uri: https://github.com/cyberarm/gosu_more_drawables
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.0.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Adds circles and arcs to Gosu
100
+ test_files: []