lib/rvg/rvg.rb in rmagick-1.8.3 vs lib/rvg/rvg.rb in rmagick-1.9.0
- old
+ new
@@ -1,7 +1,7 @@
#--############################################################################
-# $Id: rvg.rb,v 1.3 2005/04/19 23:27:01 rmagick Exp $
+# $Id: rvg.rb,v 1.5 2005/07/15 21:11:38 rmagick Exp $
#
# Copyright (C) 2005 by Timothy P. Hunter
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -59,46 +59,46 @@
# background_fill defaults to 'none'. If background_fill has been set to something
# else, combine it with the background_fill_opacity.
def bgfill()
if @background_fill.nil?
- color = Pixel.new(0,0,0,TransparentOpacity)
+ color = Magick::Pixel.new(0,0,0,Magick::TransparentOpacity)
else
color = @background_fill
- color.opacity = (1.0 - @background_fill_opacity) * ::Magick::TransparentOpacity
+ color.opacity = (1.0 - @background_fill_opacity) * Magick::TransparentOpacity
end
return color
end
def new_canvas
if @background_pattern
- canvas = ::Magick::Image.new(@width, @height, @background_pattern)
+ canvas = Magick::Image.new(@width, @height, @background_pattern)
elsif @background_image
if @width != @background_image.columns || @height != @background_image.rows
canvas = case @background_position
when :scaled
@background_image.resize(@width, @height)
when :tiled
- ::Magick::Image.new(@width, @height, TextureFill.new(@background_image))
+ Magick::Image.new(@width, @height, Magick::TextureFill.new(@background_image))
when :fit
width, height = @width, @height
bgcolor = bgfill()
- @background_image.change_geometry(Geometry.new(width, height)) do |new_cols, new_rows|
+ @background_image.change_geometry(Magick::Geometry.new(width, height)) do |new_cols, new_rows|
bg_image = @background_image.resize(new_cols, new_rows)
if bg_image.columns != width || bg_image.rows != height
- bg = ::Magick::Image.new(width, height) { self.background_color = bgcolor }
- bg_image = bg.composite!(bg_image, CenterGravity, OverCompositeOp)
+ bg = Magick::Image.new(width, height) { self.background_color = bgcolor }
+ bg_image = bg.composite!(bg_image, Magick::CenterGravity, Magick::OverCompositeOp)
end
bg_image
end
end
else
canvas = @background_image.copy
end
else
bgcolor = bgfill()
- canvas = ::Magick::Image.new(Integer(@width), Integer(@height)) { self.background_color = bgcolor }
+ canvas = Magick::Image.new(Integer(@width), Integer(@height)) { self.background_color = bgcolor }
end
canvas[:desc] = @desc if @desc
canvas[:title] = @title if @title
canvas[:metadata] = @metadata if @metadata
return canvas
@@ -137,11 +137,11 @@
attr_reader :width, :height
# Sets an image to use as the canvas background. See background_position= for layout options.
def background_image=(bg_image)
warn "background_image= has no effect in nested RVG objects" if @nested
- if bg_image && ! bg_image.kind_of?(::Magick::Image)
+ if bg_image && ! bg_image.kind_of?(Magick::Image)
raise ArgumentError, "background image must be an Image (got #{bg_image.class})"
end
@background_image = bg_image
end
@@ -170,13 +170,13 @@
# Sets the canvas background color. Either a Magick::Pixel or a color name.
# The default fill is "none", that is, transparent black.
def background_fill=(color)
warn "background_fill= has no effect in nested RVG objects" if @nested
- if ! color.kind_of?(Pixel)
+ if ! color.kind_of?(Magick::Pixel)
begin
- @background_fill = Pixel.from_color(color)
+ @background_fill = Magick::Pixel.from_color(color)
rescue Magick::ImageMagickError
raise ArgumentError, "unknown color `#{color}'"
rescue TypeError
raise TypeError, "cannot convert #{color.class} into Pixel"
rescue
@@ -245,10 +245,10 @@
translate(x, y) if (x != 0 || y != 0)
@width = rw if rw
@height = rh if rh
end
- # Used by ::Magick::Embellishable.rvg to set non-0 x- and y-coordinates
+ # Used by Magick::Embellishable.rvg to set non-0 x- and y-coordinates
def corner(x, y) #:nodoc:
@nested = true
@x, @y = Float(x), Float(y)
translate(@x, @y) if (@x != 0.0 || @y != 0.0)
end