#!/usr/bin/perl -w

#############################################################################
# Texture - a texture
#
# Copyright (C) 1999-2000 by Tels. All rights reserved.
#############################################################################

package CoW::Texture;
use vars qw($VERSION);
$VERSION = 1.00;    # Current version of this package
require  5.005;     # requires this Perl version or later

use base CoW::Item;
#@EXPORT_OK	= qw( );
#@EXPORT	= qw( );
use strict;
use vars qw($AUTOLOAD);

use CoW::Misc qw/range/;
use CoW::Angle;

#############################################################################
# private, initialize self 

sub _init
  {
  my $self = shift;
  my $args = shift;

  $self->SUPER::_init($args);
  $self->SUPER::_default( {
   u  => 0, v  => 0, r  => 0,
   name  => 'jorge', family => '',
   s => 16,
   } );
  $self->angle($self->{r}); 	# confine to 0..360
  return $self;
  }

#############################################################################
# public

sub scale
  {
  # set/get the texture scale
  my $self = shift;
  my $scale = shift;
  $self->{s} = range(1,24,$scale) if (defined $scale);
  return $self->{s};
  }

sub angle
  {
  # set/get the texture rotation angle
  my $self = shift;
  my $angle = shift;
  if (defined $angle)
    {
    $angle = new CoW::Angle ( val => $angle ) if !ref($angle);
    $self->{r} = $angle;
    }
  return $self->{r};
  }

1; 

__END__

#############################################################################

=pod

=head1 NAME

Texture - a texture. A child of L<Item|Item>.

=head1 SYNOPSIS

	use Texture;

=head1 REQUIRES

perl5.005, Exporter, L<Item|Item>, L<Angle|Angle>

=head1 EXPORTS

Exports nothing.

=head1 DESCRIPTION

This module defines a texture, which is used to texture brushes.

See also L<Brush|Brush>.

=head1 METHODS

=head2 scale

Set the scale of the texture;

	$texture->scale (5); 	# scale should be between 1 and 24
	print $thing->scale(); 	# print it

=head2 rotate

Rotate the texture around the acis that sticks trough its center.
	
	$texture->rotate (+25); 	# rotate clockwise by 25 degrees
	$texture->rotate (-25); 	# rotate back
	$texture->{r} = 0;		# set rotation angle to 0
	$texture->angle (380);		# set rotation angle to 20 (mod 360)

=head1 BUGS

None known yet.

=head1 AUTHOR

Tels http://bloodgate.com in late 2000.

=cut

