magick_canvas 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +29 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/magick_canvas.rb +9 -0
- data/lib/magick_canvas/base.rb +84 -0
- data/lib/magick_canvas/version.rb +5 -0
- data/magick_canvas.gemspec +26 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9b890474b3b81ebef810664fb1f146e431709e21aa07e50f00efbaa17ca823f3
|
4
|
+
data.tar.gz: 9ebc3e403171f0d9fbe74c3014b26f9e7ae1ac8a5647827564078b2598e81f78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7b2646fa6fbdeed196ec49c20bdca32ca2da04592ab7aff198622a62097faac735ca4d78a205a8dab3b2a6dfd83e989d5f36fc07f2eac1794c55a5ffe350b44
|
7
|
+
data.tar.gz: 6b12cfdd44ce6c5d0c4c35517624bf802905ff6602a6ef3f9e069f57b3b29a173ac350dc65bc5fd0358b5ce3b62b69d43661a31fa48b4978fa2abf94438e3356
|
@@ -0,0 +1,29 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
docker:
|
5
|
+
- image: circleci/ruby:2.6.5
|
6
|
+
working_directory: ~/repo
|
7
|
+
steps:
|
8
|
+
- checkout
|
9
|
+
- restore_cache:
|
10
|
+
keys:
|
11
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
12
|
+
- v1-dependencies-
|
13
|
+
- run:
|
14
|
+
name: install dependencies
|
15
|
+
command: |
|
16
|
+
gem install bundler
|
17
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
18
|
+
- save_cache:
|
19
|
+
paths:
|
20
|
+
- ./vendor/bundle
|
21
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
22
|
+
- run:
|
23
|
+
name: run lint
|
24
|
+
command: |
|
25
|
+
bundle exec rubocop
|
26
|
+
- run:
|
27
|
+
name: run test
|
28
|
+
command: |
|
29
|
+
bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.5
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
magick_canvas (0.1.0)
|
5
|
+
rmagick (~> 4.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.0)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
jaro_winkler (1.5.4)
|
13
|
+
parallel (1.19.1)
|
14
|
+
parser (2.6.5.0)
|
15
|
+
ast (~> 2.4.0)
|
16
|
+
rainbow (3.0.0)
|
17
|
+
rake (12.3.3)
|
18
|
+
rmagick (4.0.0)
|
19
|
+
rspec (3.9.0)
|
20
|
+
rspec-core (~> 3.9.0)
|
21
|
+
rspec-expectations (~> 3.9.0)
|
22
|
+
rspec-mocks (~> 3.9.0)
|
23
|
+
rspec-core (3.9.0)
|
24
|
+
rspec-support (~> 3.9.0)
|
25
|
+
rspec-expectations (3.9.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.9.0)
|
28
|
+
rspec-mocks (3.9.0)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-support (3.9.0)
|
32
|
+
rubocop (0.78.0)
|
33
|
+
jaro_winkler (~> 1.5.1)
|
34
|
+
parallel (~> 1.10)
|
35
|
+
parser (>= 2.6)
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
ruby-progressbar (~> 1.7)
|
38
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
39
|
+
ruby-progressbar (1.10.1)
|
40
|
+
unicode-display_width (1.6.0)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
magick_canvas!
|
47
|
+
rake (~> 12.0)
|
48
|
+
rspec (~> 3.0)
|
49
|
+
rubocop (~> 0.78)
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 tnantoka
|
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,40 @@
|
|
1
|
+
# MagickCanvas
|
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/magick_canvas`. 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 'magick_canvas'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install magick_canvas
|
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 spec` 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]/magick_canvas.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'magick_canvas'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MagickCanvas
|
4
|
+
class Base
|
5
|
+
include Magick
|
6
|
+
extend ::Forwardable
|
7
|
+
|
8
|
+
delegate %i[
|
9
|
+
app width height columns rows
|
10
|
+
number_of_frames background_color directory
|
11
|
+
] => :options_with_defaults
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
self.image_list = ImageList.new
|
15
|
+
self.center = Point.new(width * 0.5, height * 0.5)
|
16
|
+
end
|
17
|
+
|
18
|
+
def open
|
19
|
+
write
|
20
|
+
`hash open > /dev/null 2>&1 && open -a #{app} #{path}`
|
21
|
+
end
|
22
|
+
|
23
|
+
def write
|
24
|
+
draw_frames
|
25
|
+
image_list.write(path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def radians(degrees)
|
29
|
+
degrees * Math::PI / 180
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_accessor :image_list, :center
|
35
|
+
|
36
|
+
def options
|
37
|
+
{}
|
38
|
+
end
|
39
|
+
|
40
|
+
def options_with_defaults
|
41
|
+
OpenStruct.new(default_options.merge(options)).tap do |merged|
|
42
|
+
merged.columns = merged.width
|
43
|
+
merged.rows = merged.height
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_options
|
48
|
+
{
|
49
|
+
app: 'Safari',
|
50
|
+
width: 300,
|
51
|
+
height: 300,
|
52
|
+
number_of_frames: 1,
|
53
|
+
background_color: 'black',
|
54
|
+
directory: Dir.tmpdir
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def new_image
|
59
|
+
bg_color = background_color
|
60
|
+
image_list.new_image(columns, rows) { self.background_color = bg_color }
|
61
|
+
end
|
62
|
+
|
63
|
+
def gif?
|
64
|
+
number_of_frames > 1
|
65
|
+
end
|
66
|
+
|
67
|
+
def filename
|
68
|
+
extname = gif? ? 'gif' : 'png'
|
69
|
+
"magick_canvas.#{extname}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def path
|
73
|
+
"#{directory}/#{filename}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def draw(image, frame_count); end
|
77
|
+
|
78
|
+
def draw_frames
|
79
|
+
number_of_frames.times do |i|
|
80
|
+
draw(new_image, i)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/magick_canvas/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'magick_canvas'
|
7
|
+
spec.version = MagickCanvas::VERSION
|
8
|
+
spec.authors = ['tnantoka']
|
9
|
+
spec.email = ['tnantoka@bornneet.com']
|
10
|
+
|
11
|
+
spec.summary = 'Creative coding with RMagick.'
|
12
|
+
spec.description = 'Easily generate PNG and GIF images drawn as you like.'
|
13
|
+
spec.homepage = 'https://tnantoka.github.io/magick_canvas'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/tnantoka/magick_canvas'
|
19
|
+
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
22
|
+
end
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'rmagick', '~> 4.0.0'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magick_canvas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tnantoka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rmagick
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
description: Easily generate PNG and GIF images drawn as you like.
|
28
|
+
email:
|
29
|
+
- tnantoka@bornneet.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".circleci/config.yml"
|
35
|
+
- ".gitignore"
|
36
|
+
- ".rspec"
|
37
|
+
- ".rubocop.yml"
|
38
|
+
- ".ruby-version"
|
39
|
+
- ".travis.yml"
|
40
|
+
- Gemfile
|
41
|
+
- Gemfile.lock
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- bin/console
|
46
|
+
- bin/setup
|
47
|
+
- lib/magick_canvas.rb
|
48
|
+
- lib/magick_canvas/base.rb
|
49
|
+
- lib/magick_canvas/version.rb
|
50
|
+
- magick_canvas.gemspec
|
51
|
+
homepage: https://tnantoka.github.io/magick_canvas
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
metadata:
|
55
|
+
homepage_uri: https://tnantoka.github.io/magick_canvas
|
56
|
+
source_code_uri: https://github.com/tnantoka/magick_canvas
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.3.0
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubygems_version: 3.0.3
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Creative coding with RMagick.
|
76
|
+
test_files: []
|