Module: Glimmer::Gtk::Transformable
- Included in:
- Shape, WidgetProxy::DrawingAreaProxy
- Defined in:
- lib/glimmer/gtk/transformable.rb
Overview
Represents transformable view elements like shapes and drawing_area
Instance Method Summary collapse
-
#apply_transforms(cairo_context, target:) ⇒ Object
applies transform on target type (:shape, :drawing_area, :fill, :stroke, :clip).
- #initialize(keyword, parent, args, &block) ⇒ Object
- #rotate(angle, options = {}) ⇒ Object
- #scale(x, y, options = {}) ⇒ Object
- #translate(x, y, options = {}) ⇒ Object
Instance Method Details
#apply_transforms(cairo_context, target:) ⇒ Object
applies transform on target type (:shape, :drawing_area, :fill, :stroke, :clip)
70 71 72 73 74 75 76 77 78 |
# File 'lib/glimmer/gtk/transformable.rb', line 70 def apply_transforms(cairo_context, target: ) @transforms.each do |transform| operation = transform.first args = transform.last.dup = args.pop excluded_types = [[:exclude]].flatten cairo_context.send(operation, *args) if !excluded_types.include?(target) end end |
#initialize(keyword, parent, args, &block) ⇒ Object
64 65 66 67 |
# File 'lib/glimmer/gtk/transformable.rb', line 64 def initialize(keyword, parent, args, &block) @transforms = [] super end |
#rotate(angle, options = {}) ⇒ Object
88 89 90 |
# File 'lib/glimmer/gtk/transformable.rb', line 88 def rotate(angle, = {}) @transforms << [:rotate, [angle, ]] end |
#scale(x, y, options = {}) ⇒ Object
84 85 86 |
# File 'lib/glimmer/gtk/transformable.rb', line 84 def scale(x, y, = {}) @transforms << [:scale, [x, y, ]] end |
#translate(x, y, options = {}) ⇒ Object
80 81 82 |
# File 'lib/glimmer/gtk/transformable.rb', line 80 def translate(x, y, = {}) @transforms << [:translate, [x, y, ]] end |