Class: Ray::Effect::BlackAndWhite
- Inherits:
-
Ray::Effect
- Object
- Ray::Effect
- Ray::Effect::BlackAndWhite
- Defined in:
- lib/ray/effect/black_and_white.rb
Overview
A black and white effect. It considers the grayscale level of the image, and sets pixels that are darker than a given value to black, and the others to white.
Instance Attribute Summary collapse
-
#ratio ⇒ Ray::Vector3
Ratio.
Instance Method Summary collapse
- #code ⇒ Object
- #defaults ⇒ Object
-
#initialize(value = 0.5, ratio = [0.299, 0.587, 0.114]) ⇒ BlackAndWhite
constructor
A new instance of BlackAndWhite.
Methods inherited from Ray::Effect
#apply_defaults, attribute, attributes, effect_name, #header, #name, #struct
Constructor Details
#initialize(value = 0.5, ratio = [0.299, 0.587, 0.114]) ⇒ BlackAndWhite
Returns a new instance of BlackAndWhite.
13 14 15 16 |
# File 'lib/ray/effect/black_and_white.rb', line 13 def initialize(value = 0.5, ratio = [0.299, 0.587, 0.114]) @ratio = ratio @value = value end |
Instance Attribute Details
#ratio ⇒ Ray::Vector3
Returns ratio.
19 20 21 |
# File 'lib/ray/effect/black_and_white.rb', line 19 def ratio @ratio end |
Instance Method Details
#code ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ray/effect/black_and_white.rb', line 25 def code return <<code vec4 do_black_and_white(ray_black_and_white args, vec4 color) { float gray = dot(color.rgb, args.ratio); if (gray > args.value) return vec4(1, 1, 1, color.a); else return vec4(0, 0, 0, color.a); } code end |
#defaults ⇒ Object
21 22 23 |
# File 'lib/ray/effect/black_and_white.rb', line 21 def defaults {:ratio => @ratio, :value => @value} end |