glimmer-cp-bevel 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/LICENSE.txt +20 -0
- data/README.md +93 -0
- data/VERSION +1 -0
- data/glimmer-cp-bevel.gemspec +58 -0
- data/lib/glimmer-cp-bevel.rb +4 -0
- data/lib/views/glimmer/bevel.rb +60 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3b067e71639dba1551298912b12b995b16050196015d9d31f7fc99f0281d9103
|
4
|
+
data.tar.gz: 2221be15315e361b00165848b06fada2b230d0c83f3fd2f6b4c31eec7169b396
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1116677f45d31ddd5597c91471b024bd1993f6c83d32ae9348fe334323c22ec16deead3f1ed43f4f1833e590f0b7095fb328ff5042079bdfde3cadcb673c13a2
|
7
|
+
data.tar.gz: 6acbe0ae2c0e2db80b52b529a16ced3083229928559e16f1a9cf47cadca2d42811c63c0d4df56b5d3eeeae2add1084006b2de882b88d3e02ef25f574293e0629
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2021 Andy Maleh
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Bevel 0.1.0
|
2
|
+
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Shape](https://github.com/AndyObtiva/glimmer-dsl-swt/docs/reference/GLIMMER_COMMAND.md#custom-shape-gem)
|
3
|
+
|
4
|
+
[Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) Bevel Custom Shape.
|
5
|
+
|
6
|
+
`bevel` is the [Glimmer GUI DSL](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-gui-dsl-syntax) keyword provided by this [gem](https://rubygems.org/gems/glimmer-cp-bevel).
|
7
|
+
|
8
|
+
### Screenshot
|
9
|
+
|
10
|
+
Every square is a `bevel` custom shape instance with a varying base color.
|
11
|
+
|
12
|
+
![bevel screenshot](https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/images/glimmer-example-image-shape-dsl.png)
|
13
|
+
|
14
|
+
### Actual Use
|
15
|
+
|
16
|
+
It is used in [Glimmer Tetris](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_SAMPLES.md#glimmer-tetris).
|
17
|
+
|
18
|
+
![Glimmer Tetris](https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/images/glimmer-tetris.png)
|
19
|
+
|
20
|
+
## API
|
21
|
+
|
22
|
+
`bevel(options)`
|
23
|
+
|
24
|
+
Options (keyword args) are:
|
25
|
+
- `:base_color` (required): base background color to produce bevel effect for
|
26
|
+
- `:size` (required): size in pixels for width and height (resulting in bevel squares having that size)
|
27
|
+
- `:bevel_pixel_size` (optional): adjusts the bevel area
|
28
|
+
- `:x` (default: 0) (optional): starting location x coordinate within parent
|
29
|
+
- `:y` (default: 0) (optional): starting location y coordinate within parent
|
30
|
+
|
31
|
+
## Example
|
32
|
+
|
33
|
+
[Glimmer GUI DSL](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#glimmer-gui-dsl-syntax) code snippet:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
require 'glimmer-cp-bevel'
|
37
|
+
|
38
|
+
include Glimmer
|
39
|
+
|
40
|
+
shell {
|
41
|
+
text 'Glimmer Tetris Icon'
|
42
|
+
label {
|
43
|
+
text 'Check out the application icon!'
|
44
|
+
font height: 20
|
45
|
+
}
|
46
|
+
icon_block_size = 64
|
47
|
+
icon_bevel_size = icon_block_size.to_f / 25.to_f
|
48
|
+
icon_bevel_pixel_size = 0.16*icon_block_size.to_f
|
49
|
+
icon_size = 8
|
50
|
+
icon_pixel_size = icon_block_size * icon_size
|
51
|
+
image(icon_pixel_size, icon_pixel_size) {
|
52
|
+
icon_size.times { |row|
|
53
|
+
icon_size.times { |column|
|
54
|
+
colored = row >= 1 && column.between?(1, 6)
|
55
|
+
color = colored ? color(([:white] + [:cyan, :blue, :dark_yellow, :yellow, :green, :magenta, :red]).sample) : color(:white)
|
56
|
+
x = column * icon_block_size
|
57
|
+
y = row * icon_block_size
|
58
|
+
bevel(x: x, y: y, base_color: color, size: icon_block_size)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}.open
|
63
|
+
```
|
64
|
+
|
65
|
+
Produces this [Glimmer Tetris](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_SAMPLES.md#glimmer-tetris) icon [image](https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md#image):
|
66
|
+
|
67
|
+
![Tetris Icon](https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/images/glimmer-tetris-icon.png)
|
68
|
+
|
69
|
+
## Contributing to glimmer-cp-bevel
|
70
|
+
|
71
|
+
- Check out the latest master to make sure the feature hasn't been
|
72
|
+
implemented or the bug hasn't been fixed yet.
|
73
|
+
- Check out the issue tracker to make sure someone already hasn't
|
74
|
+
requested it and/or contributed it.
|
75
|
+
- Fork the project.
|
76
|
+
- Start a feature/bugfix branch.
|
77
|
+
- Commit and push until you are happy with your contribution.
|
78
|
+
- Make sure to add tests for it. This is important so I don't break it
|
79
|
+
in a future version unintentionally.
|
80
|
+
- Please try not to mess with the Rakefile, version, or history. If
|
81
|
+
you want to have your own version, or is otherwise necessary, that
|
82
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
83
|
+
around it.
|
84
|
+
|
85
|
+
## License
|
86
|
+
|
87
|
+
[MIT](LICENSE.txt)
|
88
|
+
|
89
|
+
Copyright (c) 2021 - Andy Maleh.
|
90
|
+
|
91
|
+
--
|
92
|
+
|
93
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built for [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Framework).
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: glimmer-cp-bevel 0.1.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "glimmer-cp-bevel".freeze
|
9
|
+
s.version = "0.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Andy Maleh".freeze]
|
14
|
+
s.date = "2021-03-10"
|
15
|
+
s.description = "Bevel - Glimmer Custom Shape".freeze
|
16
|
+
s.email = "andy.am@gmail.com".freeze
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.md",
|
24
|
+
"VERSION",
|
25
|
+
"glimmer-cp-bevel.gemspec",
|
26
|
+
"lib/glimmer-cp-bevel.rb",
|
27
|
+
"lib/views/glimmer/bevel.rb"
|
28
|
+
]
|
29
|
+
s.homepage = "http://github.com/AndyObtiva/glimmer-cp-bevel".freeze
|
30
|
+
s.licenses = ["MIT".freeze]
|
31
|
+
s.rubygems_version = "3.0.6".freeze
|
32
|
+
s.summary = "Bevel - Glimmer Custom Shape".freeze
|
33
|
+
|
34
|
+
if s.respond_to? :specification_version then
|
35
|
+
s.specification_version = 4
|
36
|
+
|
37
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
38
|
+
s.add_runtime_dependency(%q<glimmer-dsl-swt>.freeze, ["~> 4.18.7.4"])
|
39
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
40
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["= 2.4.9"])
|
41
|
+
s.add_development_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
42
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<glimmer-dsl-swt>.freeze, ["~> 4.18.7.4"])
|
45
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
46
|
+
s.add_dependency(%q<juwelier>.freeze, ["= 2.4.9"])
|
47
|
+
s.add_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
48
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<glimmer-dsl-swt>.freeze, ["~> 4.18.7.4"])
|
52
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
53
|
+
s.add_dependency(%q<juwelier>.freeze, ["= 2.4.9"])
|
54
|
+
s.add_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
55
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Bevel
|
3
|
+
include Glimmer::UI::CustomShape
|
4
|
+
|
5
|
+
BEVEL_CONSTANT = 20
|
6
|
+
|
7
|
+
options :base_color, :size, :bevel_pixel_size
|
8
|
+
option :x, default: 0
|
9
|
+
option :y, default: 0
|
10
|
+
|
11
|
+
before_body {
|
12
|
+
self.bevel_pixel_size = 0.16*size.to_f if bevel_pixel_size.nil?
|
13
|
+
}
|
14
|
+
|
15
|
+
body {
|
16
|
+
rectangle(x, y, size, size) {
|
17
|
+
background bind(self, :base_color)
|
18
|
+
polygon(0, 0, size, 0, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
19
|
+
background bind(self, :base_color) { |color_value|
|
20
|
+
unless color_value.nil?
|
21
|
+
color = color(color_value)
|
22
|
+
rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
|
23
|
+
end
|
24
|
+
}
|
25
|
+
}
|
26
|
+
polygon(size, 0, size - bevel_pixel_size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size, size) {
|
27
|
+
background bind(self, :base_color) { |color_value|
|
28
|
+
unless color_value.nil?
|
29
|
+
color = color(color_value)
|
30
|
+
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
31
|
+
end
|
32
|
+
}
|
33
|
+
}
|
34
|
+
polygon(size, size, 0, size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size) {
|
35
|
+
background bind(self, :base_color) { |color_value|
|
36
|
+
unless color_value.nil?
|
37
|
+
color = color(color_value)
|
38
|
+
rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
|
39
|
+
end
|
40
|
+
}
|
41
|
+
}
|
42
|
+
polygon(0, 0, 0, size, bevel_pixel_size, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
43
|
+
background bind(self, :base_color) { |color_value|
|
44
|
+
unless color_value.nil?
|
45
|
+
color = color(color_value)
|
46
|
+
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
47
|
+
end
|
48
|
+
}
|
49
|
+
}
|
50
|
+
rectangle(0, 0, size, size) {
|
51
|
+
foreground bind(self, :base_color) { |color_value|
|
52
|
+
# use gray instead of white for the :white color border
|
53
|
+
color_value == :white ? :gray : color_value
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glimmer-cp-bevel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Maleh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 4.18.7.4
|
19
|
+
name: glimmer-dsl-swt
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.18.7.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.5.0
|
33
|
+
name: rspec
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.4.9
|
47
|
+
name: juwelier
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.4.9
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.0.5
|
61
|
+
name: warbler
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.0.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
name: simplecov
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Bevel - Glimmer Custom Shape
|
84
|
+
email: andy.am@gmail.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
files:
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.md
|
93
|
+
- VERSION
|
94
|
+
- glimmer-cp-bevel.gemspec
|
95
|
+
- lib/glimmer-cp-bevel.rb
|
96
|
+
- lib/views/glimmer/bevel.rb
|
97
|
+
homepage: http://github.com/AndyObtiva/glimmer-cp-bevel
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.0.6
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Bevel - Glimmer Custom Shape
|
120
|
+
test_files: []
|