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

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
    options = args.pop
    excluded_types = [options[: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, options = {})
  @transforms << [:rotate, [angle, options]]
end

#scale(x, y, options = {}) ⇒ Object



84
85
86
# File 'lib/glimmer/gtk/transformable.rb', line 84

def scale(x, y, options = {})
  @transforms << [:scale, [x, y, options]]
end

#translate(x, y, options = {}) ⇒ Object



80
81
82
# File 'lib/glimmer/gtk/transformable.rb', line 80

def translate(x, y, options = {})
  @transforms << [:translate, [x, y, options]]
end