[magick-users] Fill pattern in rectangle using PerlMagickDraw('primitive' => 'rectangle', ..)

Ramsden, John John.Ramsden at lorien.co.uk
Wed Jul 19 02:26:58 PDT 2006


Many thanks for your prompt reply Ron, but I'm utterly mystified how
your code (suitably adapted obviously) relates to specifying a pattern
within a rectangle.

My code (simplified, e.g. 'my's omitted) opens a fresh canvas by using:

  $image = Image::Magick->new
  (
     'magick' => $image_format,  # 'png'
     'size'   => "${pixel_width}x${pixel_height}",
  );

  $ret = $image->ReadImage('xc:white');  # Create blank canvas

Then it calls Draw() to draw lines and rectangles, e.g.:

        my $ret = $x_image->Draw
        (
           'primitive' => 'rectangle',
           'points'    => "$x1,$y1,$x2,$y2",
           'fill' => $colour_background,
        );

So my question is what extra code must I add to tile a rectangle
I am plotting as above by a pattern such as 'pattern:crosshatch'.

I understand, or think I do, that with ImageMagick's approach
tiling is via an image. So the code must open/read this pattern
like an image (although I gather it is a 'pseudo-image', i.e.
generated internally rather than being read from a file). So
what I need to know is the code to plug this image into my
image to tile the rectangle.

> Free software + free help => You should be grateful :-)

I'm grateful for these, but the PerlMagick documentation for
Draw() seems pretty sketchy.


Cheers

John R Ramsden


-----Original Message-----
From: Ron Savage [mailto:ron at savage.net.au]
Sent: 18 July 2006 23:24
To: List - ImageMagick Users
Subject: Re: [magick-users] Fill pattern in rectangle using
PerlMagickDraw('primitive' => 'rectangle', ..)


On Tue, 18 Jul 2006 15:19:46 +0100, Ramsden, John wrote:

Hi John

> but I can't for the life of me figure out how to get ImageMagick to
> tile a rectangle with one of the built-in patterns detailed at:
> http://www.imagemagick.org/script/formats.php#builtin-patterns

Here's a tested program:

#!/usr/bin/perl

use strict;
use warnings;

use Image::Magick;

# ----------------

my($image)	= Image::Magick -> new(size => '200x100');
my($result)	= $image -> Read('pattern:circles');

die $result if $result;

$result = $image -> Write('circles.png');

die $result if $result;

> Seems like all available ImageMagick documentation concentrates on
> the "flash" image transformation stuff, and practically ignores the
> humble "draw" vector-graphic functionality.

Free software + free help => You should be grateful :-).
-- 
Cheers
Ron Savage, ron at savage.net.au on 19/07/2006
http://savage.net.au/index.html
Let the record show: Microsoft is not an Australian company



_______________________________________________
Magick-users mailing list
Magick-users at imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick-users

**********************************************************************
The information contained in this email is confidential and is intended for the recipient only. If you have received it in error, please notify us immediately by reply email and then delete it from your system. Please do not copy it or use it for any purposes, or disclose its contents to any other person or store or copy this information in any medium. The views contained in this email are those of the author and not necessarily those of Lorien plc.

Thank you for your co-operation.
**********************************************************************



More information about the Magick-users mailing list