685 | 685 |
|
686 | 686 |
=head1 PATH CONSTRUCTION (DRAWING)
|
687 | 687 |
|
688 | |
=over
|
689 | |
|
690 | |
=item $content->move($x, $y)
|
|
688 |
Note that paths will not appear until a path painting method is called
|
|
689 |
(L</"stroke">, L</"fill">, or L</"paint">).
|
|
690 |
|
|
691 |
=head2 move
|
|
692 |
|
|
693 |
$content = $content->move($x, $y);
|
691 | 694 |
|
692 | 695 |
Starts a new path at the specified coordinates.
|
693 | 696 |
|
|
715 | 718 |
return $self;
|
716 | 719 |
}
|
717 | 720 |
|
718 | |
=item $content->line($x, $y)
|
|
721 |
=head2 line
|
|
722 |
|
|
723 |
$content = $content->line($x, $y);
|
719 | 724 |
|
720 | 725 |
Extends the path in a line from the current coordinates to the specified
|
721 | |
coordinates, and updates the current position to be the new coordinates.
|
722 | |
|
723 | |
Note: The line will not appear until you call C<stroke>.
|
|
726 |
coordinates.
|
724 | 727 |
|
725 | 728 |
=cut
|
726 | 729 |
|
|
746 | 749 |
return $self;
|
747 | 750 |
}
|
748 | 751 |
|
749 | |
=item $content->hline($x)
|
750 | |
|
751 | |
=item $content->vline($y)
|
752 | |
|
753 | |
Shortcut for drawing horizontal and vertical lines from the current position.
|
|
752 |
=head2 hline
|
|
753 |
|
|
754 |
$content = $content->hline($x);
|
|
755 |
|
|
756 |
Extends the path in a horizontal line from the current position to the specified
|
|
757 |
x coordinate.
|
754 | 758 |
|
755 | 759 |
=cut
|
756 | 760 |
|
|
766 | 770 |
return $self;
|
767 | 771 |
}
|
768 | 772 |
|
|
773 |
=head2 vline
|
|
774 |
|
|
775 |
$content = $content->vline($x);
|
|
776 |
|
|
777 |
Extends the path in a vertical line from the current position to the specified y
|
|
778 |
coordinate.
|
|
779 |
|
|
780 |
=cut
|
|
781 |
|
769 | 782 |
sub vline {
|
770 | 783 |
my ($self, $y) = @_;
|
771 | 784 |
if ($self->_in_text_object()) {
|
|
778 | 791 |
return $self;
|
779 | 792 |
}
|
780 | 793 |
|
781 | |
=item $content->poly($x1, $y1, ..., $xn, $yn)
|
782 | |
|
783 | |
Shortcut for creating a polyline path. Moves to C<[$x1, $y1]>, and then extends
|
784 | |
the path in lines along the specified coordinates.
|
785 | |
|
786 | |
=cut
|
787 | |
|
|
794 |
=head2 polyline
|
|
795 |
|
|
796 |
$content = $content->polyline($x1, $y1, $x2, $y2, ...);
|
|
797 |
|
|
798 |
Extends the path from the current position in one or more straight lines.
|
|
799 |
|
|
800 |
=cut
|
|
801 |
|
|
802 |
sub polyline {
|
|
803 |
my $self = shift();
|
|
804 |
unless (@_ % 2 == 0) {
|
|
805 |
croak 'polyline requires pairs of coordinates';
|
|
806 |
}
|
|
807 |
|
|
808 |
while (@_) {
|
|
809 |
my $x = shift();
|
|
810 |
my $y = shift();
|
|
811 |
$self->line($x, $y);
|
|
812 |
}
|
|
813 |
|
|
814 |
return $self;
|
|
815 |
}
|
|
816 |
|
|
817 |
# Deprecated; replace with move and polyline. Deprecated because poly breaks
|
|
818 |
# the convention followed by every other path-drawing method (other than
|
|
819 |
# enclosed shapes) of extending the path from the current position.
|
788 | 820 |
sub poly {
|
789 | 821 |
my $self = shift();
|
790 | 822 |
my $x = shift();
|
|
794 | 826 |
return $self;
|
795 | 827 |
}
|
796 | 828 |
|
797 | |
=item $content->curve($cx1, $cy1, $cx2, $cy2, $x, $y)
|
|
829 |
=head2 curve
|
|
830 |
|
|
831 |
$content = $content->curve($cx1, $cy1, $cx2, $cy2, $x, $y);
|
798 | 832 |
|
799 | 833 |
Extends the path in a curve from the current point to C<($x, $y)>, using the two
|
800 | |
specified points to create a cubic Bezier curve, and updates the current
|
801 | |
position to be the new point.
|
802 | |
|
803 | |
Note: The curve will not appear until you call C<stroke>.
|
|
834 |
specified points to create a cubic Bezier curve.
|
804 | 835 |
|
805 | 836 |
=cut
|
806 | 837 |
|
|
825 | 856 |
return $self;
|
826 | 857 |
}
|
827 | 858 |
|
828 | |
=item $content->spline($cx1, $cy1, $x, $y)
|
829 | |
|
830 | |
Extends the path in a curve from the current point to C<($x, $y)>,
|
831 | |
using the two specified points to create a spline, and updates the
|
832 | |
current position to be the new point.
|
833 | |
|
834 | |
Note: The curve will not appear until you call C<stroke>.
|
|
859 |
=head2 spline
|
|
860 |
|
|
861 |
$content = $content->spline($cx1, $cy1, $x, $y);
|
|
862 |
|
|
863 |
Extends the path in a curve from the current point to C<($x, $y)>, using the two
|
|
864 |
specified points to create a spline.
|
835 | 865 |
|
836 | 866 |
=cut
|
837 | 867 |
|
|
851 | 881 |
}
|
852 | 882 |
}
|
853 | 883 |
|
854 | |
=item $content->arc($x, $y, $a, $b, $alpha, $beta, $move)
|
855 | |
|
856 | |
Extends the path along an arc of an ellipse centered at C<[x, y]>. The major
|
857 | |
and minor axes of the ellipse are C<$a> and C<$b>, respectively, and the arc
|
858 | |
moves from C<$alpha> degrees to C<$beta> degrees. The current position is then
|
859 | |
set to the endpoint of the arc.
|
860 | |
|
861 | |
Set C<$move> to a true value if this arc is the beginning of a new path instead
|
862 | |
of the continuation of an existing path.
|
|
884 |
=head2 arc
|
|
885 |
|
|
886 |
$content = $content->arc($x, $y, $major, $minor, $a, $b);
|
|
887 |
|
|
888 |
Extends the path along an arc of an ellipse centered at C<[$x, $y]>. C<$major>
|
|
889 |
and C<$minor> represent the axes of the ellipse, and the arc moves from C<$a>
|
|
890 |
degrees to C<$b> degrees.
|
863 | 891 |
|
864 | 892 |
=cut
|
865 | 893 |
|
|
903 | 931 |
$p0_x = $x + shift(@points);
|
904 | 932 |
$p0_y = $y + shift(@points);
|
905 | 933 |
|
|
934 |
# Deprecated
|
906 | 935 |
$self->move($p0_x, $p0_y) if $move;
|
907 | 936 |
|
908 | 937 |
while (scalar @points) {
|
|
921 | 950 |
return $self;
|
922 | 951 |
}
|
923 | 952 |
|
924 | |
=item $content->bogen($x1, $y1, $x2, $y2, $radius, $move, $outer, $reverse)
|
925 | |
|
926 | |
Extends the path along an arc of a circle of the specified radius between
|
927 | |
C<[x1,y1]> to C<[x2,y2]>. The current position is then set to the endpoint of
|
928 | |
the arc.
|
929 | |
|
930 | |
Set C<$move> to a true value if this arc is the beginning of a new path instead
|
931 | |
of the continuation of an existing path.
|
932 | |
|
933 | |
Set C<$outer> to a true value to draw the larger arc between the two points
|
934 | |
instead of the smaller one.
|
935 | |
|
936 | |
Set C<$reverse> to a true value to draw the mirror image of the specified arc.
|
937 | |
|
938 | |
C<$radius * 2> cannot be smaller than the distance from C<[x1,y1]> to
|
939 | |
C<[x2,y2]>.
|
940 | |
|
941 | |
Note: The curve will not appear until you call C<stroke>.
|
942 | |
|
943 | |
=cut
|
944 | |
|
|
953 |
# Extends the path along an arc of a circle of the specified radius from
|
|
954 |
# C<[x1,y1]> to C<[x2,y2]>.
|
|
955 |
#
|
|
956 |
# Set C<$move> to a true value if this arc is the beginning of a new path
|
|
957 |
# instead of the continuation of an existing path.
|
|
958 |
#
|
|
959 |
# Set C<$outer> to a true value to draw the larger arc between the two points
|
|
960 |
# instead of the smaller one.
|
|
961 |
#
|
|
962 |
# Set C<$reverse> to a true value to draw the mirror image of the specified arc.
|
|
963 |
#
|
|
964 |
# C<$radius * 2> cannot be smaller than the distance from C<[x1,y1]> to
|
|
965 |
# C<[x2,y2]>.
|
|
966 |
|
|
967 |
# Deprecated; recreate using arc (Bogen is German for arc)
|
945 | 968 |
sub bogen {
|
946 | 969 |
my ($self, $x1, $y1, $x2, $y2, $r, $move, $larc, $spf) = @_;
|
947 | 970 |
my ($p0_x, $p0_y, $p1_x, $p1_y, $p2_x, $p2_y, $p3_x, $p3_y);
|
|
1004 | 1027 |
return $self;
|
1005 | 1028 |
}
|
1006 | 1029 |
|
1007 | |
=item $content->close()
|
1008 | |
|
1009 | |
Closes and ends the current path by extending a line from the current position
|
1010 | |
to the starting position.
|
|
1030 |
=head2 close
|
|
1031 |
|
|
1032 |
$content = $content->close();
|
|
1033 |
|
|
1034 |
Closes the current path by extending a line from the current position to the
|
|
1035 |
starting position.
|
1011 | 1036 |
|
1012 | 1037 |
=cut
|
1013 | 1038 |
|
|
1019 | 1044 |
return $self;
|
1020 | 1045 |
}
|
1021 | 1046 |
|
1022 | |
=item $content->endpath()
|
1023 | |
|
1024 | |
Ends the current path without explicitly enclosing it.
|
1025 | |
|
1026 | |
=cut
|
1027 | |
|
1028 | |
sub endpath {
|
1029 | |
my $self = shift;
|
|
1047 |
=head2 end
|
|
1048 |
|
|
1049 |
$content = $content->end();
|
|
1050 |
|
|
1051 |
Ends the current path without filling or stroking.
|
|
1052 |
|
|
1053 |
=cut
|
|
1054 |
|
|
1055 |
# Deprecated (renamed)
|
|
1056 |
sub endpath { return end(@_) }
|
|
1057 |
|
|
1058 |
sub end {
|
|
1059 |
my $self = shift();
|
1030 | 1060 |
$self->add('n');
|
1031 | 1061 |
return $self;
|
1032 | 1062 |
}
|
1033 | 1063 |
|
1034 | |
=item $content->ellipse($x, $y, $a, $b)
|
1035 | |
|
1036 | |
Creates an elliptical path centered on C<[$x,$y]>, with major and minor axes
|
1037 | |
specified by C<$a> and C<$b>, respectively.
|
1038 | |
|
1039 | |
Note: The ellipse will not appear until you call C<stroke> or C<fill>.
|
|
1064 |
=head1 SHAPE CONSTRUCTION (DRAWING)
|
|
1065 |
|
|
1066 |
The following are convenience methods for drawing closed paths.
|
|
1067 |
|
|
1068 |
Note that shapes will not appear until a path painting method is called
|
|
1069 |
(L</"stroke">, L</"fill">, or L</"paint">).
|
|
1070 |
|
|
1071 |
=head2 rectangle
|
|
1072 |
|
|
1073 |
$content = $content->rectangle($x, $y, $width, $height);
|
|
1074 |
|
|
1075 |
Creates a new rectangle-shaped path, with the lower left point at C<[$x, $y]>
|
|
1076 |
and the specified width and height.
|
|
1077 |
|
|
1078 |
=cut
|
|
1079 |
|
|
1080 |
sub rectangle {
|
|
1081 |
my ($self, $x, $y, $w, $h) = @_;
|
|
1082 |
|
|
1083 |
$self->add(floats($x, $y, $w, $h), 're');
|
|
1084 |
$self->{' x'} = $x;
|
|
1085 |
$self->{' y'} = $y;
|
|
1086 |
|
|
1087 |
return $self;
|
|
1088 |
}
|
|
1089 |
|
|
1090 |
# Deprecated; replace with individual calls to rectangle
|
|
1091 |
sub rect {
|
|
1092 |
my $self = shift();
|
|
1093 |
my ($x, $y, $w, $h);
|
|
1094 |
while (defined($x = shift())) {
|
|
1095 |
$y = shift();
|
|
1096 |
$w = shift();
|
|
1097 |
$h = shift();
|
|
1098 |
$self->add(floats($x, $y, $w, $h), 're');
|
|
1099 |
}
|
|
1100 |
$self->{' x'} = $x;
|
|
1101 |
$self->{' y'} = $y;
|
|
1102 |
return $self;
|
|
1103 |
}
|
|
1104 |
|
|
1105 |
# Deprecated; replace with rectangle, converting x2/y2 to w/h.
|
|
1106 |
sub rectxy {
|
|
1107 |
my ($self, $x, $y, $x2, $y2) = @_;
|
|
1108 |
$self->rect($x, $y, ($x2 - $x), ($y2 - $y));
|
|
1109 |
return $self;
|
|
1110 |
}
|
|
1111 |
|
|
1112 |
=head2 circle
|
|
1113 |
|
|
1114 |
$content = $content->circle($x, $y, $radius);
|
|
1115 |
|
|
1116 |
Creates a new circular path centered on C<[$x, $y]> with the specified radius.
|
|
1117 |
|
|
1118 |
=cut
|
|
1119 |
|
|
1120 |
sub circle {
|
|
1121 |
my ($self, $x, $y, $r) = @_;
|
|
1122 |
$self->arc($x, $y, $r, $r, 0, 360, 1);
|
|
1123 |
$self->close();
|
|
1124 |
return $self;
|
|
1125 |
}
|
|
1126 |
|
|
1127 |
=head2 ellipse
|
|
1128 |
|
|
1129 |
$content = $content->ellipse($x, $y, $major, $minor);
|
|
1130 |
|
|
1131 |
Creates a new elliptical path centered on C<[$x, $y]> with the specified major
|
|
1132 |
and minor axes.
|
1040 | 1133 |
|
1041 | 1134 |
=cut
|
1042 | 1135 |
|
|
1047 | 1140 |
return $self;
|
1048 | 1141 |
}
|
1049 | 1142 |
|
1050 | |
=item $content->circle($x, $y, $radius)
|
1051 | |
|
1052 | |
Creates a circular path centered on C<[$x, $y]> with the specified
|
1053 | |
radius.
|
1054 | |
|
1055 | |
Note: The circle will not appear until you call C<stroke> or C<fill>.
|
1056 | |
|
1057 | |
=cut
|
1058 | |
|
1059 | |
sub circle {
|
1060 | |
my ($self, $x, $y, $r) = @_;
|
1061 | |
$self->arc($x, $y, $r, $r, 0, 360, 1);
|
1062 | |
$self->close();
|
1063 | |
return $self;
|
1064 | |
}
|
1065 | |
|
1066 | |
=item $content->pie($x, $y, $a, $b, $alpha, $beta)
|
1067 | |
|
1068 | |
Creates a pie-shaped path from an ellipse centered on C<[$x,$y]>. The major and
|
1069 | |
minor axes of the ellipse are C<$a> and C<$b>, respectively, and the arc moves
|
1070 | |
from C<$alpha> degrees to C<$beta> degrees.
|
1071 | |
|
1072 | |
Note: The pie will not appear until you call C<stroke> or C<fill>.
|
|
1143 |
=head2 pie
|
|
1144 |
|
|
1145 |
$content = $content->pie($x, $y, $major, $minor, $a, $b);
|
|
1146 |
|
|
1147 |
Creates a new wedge-shaped path from an ellipse centered on C<[$x, $y]> with the
|
|
1148 |
specified major and minor axes, extending from C<$a> degrees to C<$b> degrees.
|
1073 | 1149 |
|
1074 | 1150 |
=cut
|
1075 | 1151 |
|
|
1083 | 1159 |
$self->close();
|
1084 | 1160 |
}
|
1085 | 1161 |
|
1086 | |
=item $content->rect($x1, $y1, $w1, $h1, ..., $xn, $yn, $wn, $hn)
|
1087 | |
|
1088 | |
Creates paths for one or more rectangles, with their lower left points at
|
1089 | |
C<[$x,$y]> and with the specified widths and heights.
|
1090 | |
|
1091 | |
Note: The rectangles will not appear until you call C<stroke> or C<fill>.
|
1092 | |
|
1093 | |
=cut
|
1094 | |
|
1095 | |
sub rect {
|
1096 | |
my $self = shift();
|
1097 | |
my ($x, $y, $w, $h);
|
1098 | |
while (defined($x = shift())) {
|
1099 | |
$y = shift();
|
1100 | |
$w = shift();
|
1101 | |
$h = shift();
|
1102 | |
$self->add(floats($x, $y, $w, $h), 're');
|
1103 | |
}
|
1104 | |
$self->{' x'} = $x;
|
1105 | |
$self->{' y'} = $y;
|
1106 | |
return $self;
|
1107 | |
}
|
1108 | |
|
1109 | |
=item $content->rectxy($x1, $y1, $x2, $y2)
|
1110 | |
|
1111 | |
Creates a rectangular path, with C<[$x1,$y1]> and and C<[$x2,$y2]> specifying
|
1112 | |
opposite corners.
|
1113 | |
|
1114 | |
Note: The rectangle will not appear until you call C<stroke> or C<fill>.
|
1115 | |
|
1116 | |
=cut
|
1117 | |
|
1118 | |
sub rectxy {
|
1119 | |
my ($self, $x, $y, $x2, $y2) = @_;
|
1120 | |
$self->rect($x, $y, ($x2 - $x), ($y2 - $y));
|
1121 | |
return $self;
|
1122 | |
}
|
1123 | |
|
1124 | |
=back
|
1125 | |
|
1126 | 1162 |
=head1 PATH PAINTING (DRAWING)
|
1127 | 1163 |
|
1128 | |
=over
|
1129 | |
|
1130 | |
=item $content->stroke
|
1131 | |
|
1132 | |
Strokes the current path.
|
1133 | |
|
1134 | |
=cut
|
1135 | |
|
1136 | |
sub _stroke {
|
1137 | |
return 'S';
|
1138 | |
}
|
1139 | |
|
1140 | |
sub stroke {
|
1141 | |
my $self = shift();
|
1142 | |
$self->add(_stroke());
|
1143 | |
return $self;
|
1144 | |
}
|
1145 | |
|
1146 | |
=item $content->fill($use_even_odd_fill)
|
1147 | |
|
1148 | |
Fills the current path.
|
1149 | |
|
1150 | |
If the path intersects with itself, the nonzero winding rule will be used to
|
1151 | |
determine which part of the path is filled in. If you would prefer to use the
|
1152 | |
even-odd rule, pass a true argument.
|
1153 | |
|
1154 | |
See the PDF Specification, section 8.5.3.3, for more details on filling.
|
1155 | |
|
1156 | |
=cut
|
1157 | |
|
1158 | |
sub fill {
|
1159 | |
my $self = shift();
|
1160 | |
$self->add(shift() ? 'f*' : 'f');
|
1161 | |
return $self;
|
1162 | |
}
|
1163 | |
|
1164 | |
=item $content->fillstroke($use_even_odd_fill)
|
1165 | |
|
1166 | |
Fills and then strokes the current path.
|
1167 | |
|
1168 | |
=cut
|
1169 | |
|
1170 | |
sub fillstroke {
|
1171 | |
my $self = shift();
|
1172 | |
$self->add(shift() ? 'B*' : 'B');
|
1173 | |
return $self;
|
1174 | |
}
|
1175 | |
|
1176 | |
=item $content->clip($use_even_odd_fill)
|
1177 | |
|
1178 | |
Modifies the current clipping path by intersecting it with the current path.
|
1179 | |
|
1180 | |
=cut
|
1181 | |
|
1182 | |
sub clip {
|
1183 | |
my $self = shift();
|
1184 | |
$self->add(shift() ? 'W*' : 'W');
|
1185 | |
return $self;
|
1186 | |
}
|
1187 | |
|
1188 | |
=back
|
1189 | |
|
1190 | |
=head1 COLORS
|
1191 | |
|
1192 | |
=over
|
1193 | |
|
1194 | |
=item $content->fillcolor($color)
|
1195 | |
|
1196 | |
=item $content->strokecolor($color)
|
1197 | |
|
1198 | |
Sets the fill or stroke color.
|
|
1164 |
=head2 stroke_color
|
|
1165 |
|
|
1166 |
$content = $content->stroke_color($color, @arguments);
|
|
1167 |
|
|
1168 |
Sets the stroke color, which is black by default.
|
1199 | 1169 |
|
1200 | 1170 |
# Use a named color
|
1201 | |
$content->fillcolor('blue');
|
|
1171 |
$content->stroke_color('blue');
|
1202 | 1172 |
|
1203 | 1173 |
# Use an RGB color (start with '#')
|
1204 | |
$content->fillcolor('#FF0000');
|
|
1174 |
$content->stroke_color('#FF0000');
|
1205 | 1175 |
|
1206 | 1176 |
# Use a CMYK color (start with '%')
|
1207 | |
$content->fillcolor('%FF000000');
|
1208 | |
|
1209 | |
RGB and CMYK colors can have one-byte, two-byte, three-byte, or
|
1210 | |
four-byte values for each color. For instance, cyan can be given as
|
1211 | |
C<%F000> or C<%FFFF000000000000>.
|
|
1177 |
$content->stroke_color('%FF000000');
|
|
1178 |
|
|
1179 |
# Use a spot color with 100% coverage.
|
|
1180 |
my $spot = $pdf->colorspace('spot', 'PANTONE Red 032 C', '#EF3340');
|
|
1181 |
$content->stroke_color($spot, 1.0);
|
|
1182 |
|
|
1183 |
RGB and CMYK colors can have one-byte, two-byte, three-byte, or four-byte values
|
|
1184 |
for each color, depending on the level of precision needed. For instance, cyan
|
|
1185 |
can be given as C<%F000> or C<%FFFF000000000000>.
|
|
1186 |
|
|
1187 |
=head2 fill_color
|
|
1188 |
|
|
1189 |
$content = $content->fill_color($color, @arguments);
|
|
1190 |
|
|
1191 |
Sets the fill color, which is black by default. Arguments are the same as in
|
|
1192 |
L</"stroke_color">.
|
1212 | 1193 |
|
1213 | 1194 |
=cut
|
1214 | 1195 |
|
|
1220 | 1201 |
#
|
1221 | 1202 |
# legacy greylevel
|
1222 | 1203 |
# ... only one value
|
1223 | |
#
|
1224 | |
#
|
1225 | |
|
1226 | 1204 |
sub _makecolor {
|
1227 | 1205 |
my ($self, $sf, @clr) = @_;
|
1228 | 1206 |
|
|
1323 | 1301 |
return @{$self->{' strokecolor'}};
|
1324 | 1302 |
}
|
1325 | 1303 |
|
|
1304 |
=head2 stroke
|
|
1305 |
|
|
1306 |
$content = $content->stroke();
|
|
1307 |
|
|
1308 |
Strokes the current path.
|
|
1309 |
|
|
1310 |
=cut
|
|
1311 |
|
|
1312 |
sub _stroke {
|
|
1313 |
return 'S';
|
|
1314 |
}
|
|
1315 |
|
|
1316 |
sub stroke {
|
|
1317 |
my $self = shift();
|
|
1318 |
$self->add(_stroke());
|
|
1319 |
return $self;
|
|
1320 |
}
|
|
1321 |
|
|
1322 |
=head2 fill
|
|
1323 |
|
|
1324 |
$content = $content->fill(rule => $rule);
|
|
1325 |
|
|
1326 |
Fills the current path.
|
|
1327 |
|
|
1328 |
C<$rule> describes which areas are filled in when the path intersects with itself.
|
|
1329 |
|
|
1330 |
=over
|
|
1331 |
|
|
1332 |
=item * nonzero (default)
|
|
1333 |
|
|
1334 |
Use the nonzero winding number rule. This tends to mean that the entire area
|
|
1335 |
enclosed by the path is filled in, with some exceptions depending on the
|
|
1336 |
direction of the path.
|
|
1337 |
|
|
1338 |
=item * even-odd
|
|
1339 |
|
|
1340 |
Use the even-odd rule. This tends to mean that the presence of fill alternates
|
|
1341 |
each time the path is intersected.
|
|
1342 |
|
|
1343 |
=back
|
|
1344 |
|
|
1345 |
See PDF specification 1.7 section 8.5.3.3, Filling, for more details.
|
|
1346 |
|
|
1347 |
=cut
|
|
1348 |
|
|
1349 |
sub fill {
|
|
1350 |
my $self = shift();
|
|
1351 |
|
|
1352 |
my $even_odd;
|
|
1353 |
if (@_ == 2) {
|
|
1354 |
my %options = @_;
|
|
1355 |
if (($options{'rule'} // 'nonzero') eq 'even-odd') {
|
|
1356 |
$even_odd = 1;
|
|
1357 |
}
|
|
1358 |
}
|
|
1359 |
else {
|
|
1360 |
# Deprecated
|
|
1361 |
$even_odd = shift();
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
$self->add($even_odd ? 'f*' : 'f');
|
|
1365 |
|
|
1366 |
return $self;
|
|
1367 |
}
|
|
1368 |
|
|
1369 |
=head2 paint
|
|
1370 |
|
|
1371 |
$content = $content->paint(rule => $rule);
|
|
1372 |
|
|
1373 |
Fills and strokes the current path. C<$rule> is as described in L</"fill">.
|
|
1374 |
|
|
1375 |
=cut
|
|
1376 |
|
|
1377 |
# Deprecated (renamed)
|
|
1378 |
sub fillstroke { return paint(@_) }
|
|
1379 |
|
|
1380 |
sub paint {
|
|
1381 |
my $self = shift();
|
|
1382 |
|
|
1383 |
my $even_odd;
|
|
1384 |
if (@_ == 2) {
|
|
1385 |
my %options = @_;
|
|
1386 |
if (($options{'rule'} // 'nonzero') eq 'even-odd') {
|
|
1387 |
$even_odd = 1;
|
|
1388 |
}
|
|
1389 |
}
|
|
1390 |
else {
|
|
1391 |
# Deprecated
|
|
1392 |
$even_odd = shift();
|
|
1393 |
}
|
|
1394 |
|
|
1395 |
$self->add($even_odd ? 'B*' : 'B');
|
|
1396 |
|
|
1397 |
return $self;
|
|
1398 |
}
|
|
1399 |
|
|
1400 |
=head2 clip
|
|
1401 |
|
|
1402 |
$content = $content->clip(rule => $rule);
|
|
1403 |
|
|
1404 |
Modifies the current clipping path (initially the entire page) by intersecting
|
|
1405 |
it with the current path following the next path-painting command. C<$rule> is
|
|
1406 |
as described in L</"fill">.
|
|
1407 |
|
|
1408 |
=cut
|
|
1409 |
|
|
1410 |
sub clip {
|
|
1411 |
my $self = shift();
|
|
1412 |
|
|
1413 |
my $even_odd;
|
|
1414 |
if (@_ == 2) {
|
|
1415 |
my %options = @_;
|
|
1416 |
if (($options{'rule'} // 'nonzero') eq 'even-odd') {
|
|
1417 |
$even_odd = 1;
|
|
1418 |
}
|
|
1419 |
}
|
|
1420 |
else {
|
|
1421 |
# Deprecated
|
|
1422 |
$even_odd = shift();
|
|
1423 |
}
|
|
1424 |
|
|
1425 |
$self->add($even_odd ? 'W*' : 'W');
|
|
1426 |
|
|
1427 |
return $self;
|
|
1428 |
}
|
|
1429 |
|
1326 | 1430 |
sub shade {
|
1327 | 1431 |
my ($self, $shade, @cord) = @_;
|
1328 | 1432 |
|
|
1341 | 1445 |
return $self;
|
1342 | 1446 |
}
|
1343 | 1447 |
|
1344 | |
=back
|
1345 | |
|
1346 | 1448 |
=head1 EXTERNAL OBJECTS
|
1347 | 1449 |
|
1348 | |
=over
|
1349 | |
|
1350 | |
=item $content->object($object, $x, $y, $scale_x, $scale_y)
|
|
1450 |
=head2 object
|
|
1451 |
|
|
1452 |
$content = $content->object($object, $x, $y, $scale_x, $scale_y);
|
1351 | 1453 |
|
1352 | 1454 |
Places an image or other external object (a.k.a. XObject) on the page in the
|
1353 | 1455 |
specified location.
|
|
1440 | 1542 |
$self->resource('XObject', $img->name(), $img);
|
1441 | 1543 |
return $self;
|
1442 | 1544 |
}
|
1443 | |
|
1444 | |
=back
|
1445 | 1545 |
|
1446 | 1546 |
=head1 TEXT STATE
|
1447 | 1547 |
|