Module: Postsvg::Visitors::PsVisitor::Color
- Included in:
- Postsvg::Visitors::PsVisitor
- Defined in:
- lib/postsvg/visitors/ps_visitor/color.rb
Overview
Color operator handlers. Each updates the current GraphicsContext; the next paint operator reads the new colors.
Instance Method Summary collapse
- #visit_setcmykcolor(op, _ctx) ⇒ Object
- #visit_setgray(op, _ctx) ⇒ Object
- #visit_sethsbcolor(op, _ctx) ⇒ Object
- #visit_setrgbcolor(op, _ctx) ⇒ Object
Instance Method Details
#visit_setcmykcolor(op, _ctx) ⇒ Object
19 20 21 22 |
# File 'lib/postsvg/visitors/ps_visitor/color.rb', line 19 def visit_setcmykcolor(op, _ctx) color = Postsvg::Color.cmyk(op.cyan.to_f, op.magenta.to_f, op.yellow.to_f, op.key.to_f) @graphics.update(fill_color: color, stroke_color: color) end |
#visit_setgray(op, _ctx) ⇒ Object
9 10 11 12 |
# File 'lib/postsvg/visitors/ps_visitor/color.rb', line 9 def visit_setgray(op, _ctx) color = Postsvg::Color.gray(op.gray.to_f) @graphics.update(fill_color: color, stroke_color: color) end |
#visit_sethsbcolor(op, _ctx) ⇒ Object
24 25 26 27 |
# File 'lib/postsvg/visitors/ps_visitor/color.rb', line 24 def visit_sethsbcolor(op, _ctx) color = hsb_to_color(op.hue.to_f, op.saturation.to_f, op.brightness.to_f) @graphics.update(fill_color: color, stroke_color: color) end |