module Magick::RVG::Stretchable
def add_viewbox_primitives(width, height, gc)
def add_viewbox_primitives(width, height, gc) @vbx_width ||= width @vbx_height ||= height @vbx_x ||= 0.0 @vbx_y ||= 0.0 if @align == 'none' sx, sy = set_viewbox_none(width, height) tx, ty = 0, 0 elsif @meet_or_slice == 'meet' sx, sy = set_viewbox_meet(width, height) tx, ty = align_to_viewport(width, height, sx, sy) else sx, sy = set_viewbox_slice(width, height) tx, ty = align_to_viewport(width, height, sx, sy) end # Establish clipping path around the current viewport name = __id__.to_s gc.define_clip_path(name) do gc.path("M0,0 l#{width},0 l0,#{height} l-#{width},0 l0,-#{height}z") end gc.clip_path(name) # Add a non-scaled translation if meet or slice gc.translate(tx, ty) if tx.abs > 1.0e-10 || ty.abs > 1.0e-10 # Scale viewbox as necessary gc.scale(sx, sy) if sx != 1.0 || sy != 1.0 # Add a scaled translation if non-0 origin gc.translate(-@vbx_x, -@vbx_y) if @vbx_x.abs != 0.0 || @vbx_y.abs != 0 end