class CTioga2::Graphics::Styles::ScopeStyle

This style represents a scope, ie something that translates (first) and scales (second) figure coordinates.

Public Class Methods

new() click to toggle source
# File lib/ctioga2/graphics/styles/scope.rb, line 36
def initialize
end

Public Instance Methods

apply_to_figure(t) click to toggle source

applies the transformation to the current figure coordinates

# File lib/ctioga2/graphics/styles/scope.rb, line 40
def apply_to_figure(t)
  bl = t.bounds_left
  br = t.bounds_right
  bt = t.bounds_top
  bb = t.bounds_bottom

  if @xshift
    dx = @xshift.to_figure(t,:x)
    bl -= dx
    br -= dx
  end

  if @yshift
    dy = @yshift.to_figure(t,:y)
    bt -= dy
    bb -= dy
  end

  if @xscale
    bl, br = *Utils::scale_segment(bl, br, 1/@xscale)
  end
  if @yscale
    bt, bb = *Utils::scale_segment(bt, bb, 1/@yscale)
  end

  t.set_bounds([bl, br, bt, bb])
end