Another RMagick and rotation question

Hello there all,

i have an RMagick image of a circle with a line through it ( in png)
i would like to rotate the image, but whenever i use rotate to do
this, it makes a smaller image because the image is actually a cirlce
on a square transparent background.

It will not make the image smaller if it is rotated angles of 90, 180,
270 or 0 degrees, but as it approaches angles between those ( like 45
and so on) the image is smaller and smaller.

Has anyone got a good idea or workaround for this. I would love to
rotate the image but keep the circle part of the image the same size.

thanks for any tips

sk

shawn bright wrote:

Has anyone got a good idea or workaround for this. I would love to
rotate the image but keep the circle part of the image the same size.

thanks for any tips

sk

Can you post some code?

ok, here we go…

def circle_image(zoom)
site = self.site
zoomhash = {13 => 0.5, 14 => 1, 15 => 2, 16 => 4}
r = (self.radius.to_f * zoomhash[zoom.to_i].to_f)
canvas = Magick::Image.new((2 * r), (2*r),
Magick::HatchFill.new(‘transparent’, ‘transparent’))
gc = Magick::Draw.new

# for the outside perimeter of the circle
gc.stroke('red')
gc.stroke_width(1)

# fill in the inside
gc.fill('red')
gc.fill_opacity(0.3)
gc.circle(r, r, 0, r)
image = gc.draw(canvas)

# place the line for gps
if site.has_gps_sensor?
  # fetch the image of a line
  gps_image = self.gps_image(site, r)
  canvas.composite!(gps_image, 0, 0, Magick::OverCompositeOp)
  angle = site.gps_sensor.projected_position # will be between 1

and 360 degrees
canvas.rotate!(angle)
end
end

then there is the code to canvas.write(‘image.png’) or whatever.
Basic idea is to draw a circle, then draw the line from the center to
the edge of the circle, this is done with another image
that is just a line that gets superimposed over the circle image.

thanks so much for looking at this,.

sk

then it all gets rotated and that is where it gets shortened.

shawn bright wrote:

ok, here we go…

I’m sorry, Shawn. I’m too stupid too figure out what you’re wanting to
do just from this. I tried to fill out the example but I get a
“undefined method `site’” message.

In general, the rotate method results in a larger image, not smaller.

Can you post a complete, working, example on the RMagick help forum on
RubyForge?

ok, will do
thanks