pdf-writer 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +23 -1
- data/README +2 -2
- data/demo/colornames.rb +19 -823
- data/demo/demo.rb +2 -2
- data/demo/pac.rb +12 -12
- data/demo/pagenumber.rb +16 -12
- data/lib/pdf/charts/stddev.rb +10 -10
- data/lib/pdf/quickref.rb +5 -4
- data/lib/pdf/simpletable.rb +16 -16
- data/lib/pdf/techbook.rb +11 -11
- data/lib/pdf/writer.rb +136 -134
- data/lib/pdf/writer/graphics.rb +3 -3
- data/lib/pdf/writer/lang/en.rb +2 -1
- data/lib/pdf/writer/object/contents.rb +3 -2
- data/lib/pdf/writer/object/image.rb +150 -10
- data/manual.pwd +470 -117
- metadata +3 -4
- data/lib/pdf/grid.rb +0 -135
data/lib/pdf/writer/graphics.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: graphics.rb,v 1.12 2005/
|
9
|
+
# $Id: graphics.rb,v 1.12.2.1 2005/08/25 03:38:05 austin Exp $
|
10
10
|
#++
|
11
11
|
# Points for use in the drawing of polygons.
|
12
12
|
class PDF::Writer::PolygonPoint
|
@@ -726,7 +726,7 @@ module PDF::Writer::Graphics
|
|
726
726
|
|
727
727
|
if border
|
728
728
|
border = {} if true == border
|
729
|
-
border[:color] ||= Color::Grey50
|
729
|
+
border[:color] ||= Color::RGB::Grey50
|
730
730
|
border[:style] ||= PDF::Writer::StrokeStyle::DEFAULT
|
731
731
|
|
732
732
|
save_state
|
@@ -808,6 +808,6 @@ module PDF::Writer::Graphics
|
|
808
808
|
# * Y axis skewing uses [ 1 tan(a) 0 1 0 0 ] where a is the angle,
|
809
809
|
# measured in radians.
|
810
810
|
def transform_matrix(a, b, c, d, e, f)
|
811
|
-
add_content("\n%.3f %.3f %.3f %.3f
|
811
|
+
add_content("\n%.3f %.3f %.3f %.3f %.3f %.3f cm" % [ a, b, c, d, e, f ])
|
812
812
|
end
|
813
813
|
end
|
data/lib/pdf/writer/lang/en.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: en.rb,v 1.9 2005/
|
9
|
+
# $Id: en.rb,v 1.9.2.1 2005/08/25 03:38:06 austin Exp $
|
10
10
|
#++
|
11
11
|
# PDF::Writer::Lang::EN is the English-language output module. It contains a
|
12
12
|
# hash, @message, that contains the messages that may be reported by any
|
@@ -44,6 +44,7 @@ code. Please change it.
|
|
44
44
|
:png_unsupp_filter => "Unsupported PNG filter method.",
|
45
45
|
:png_header_missing => "PNG information header is missing.",
|
46
46
|
:png_8bit_colour => "Only PNG colour depths of 8 bits or less are supported.",
|
47
|
+
:png_interlace => "Interlaced PNG images are not currently supported.",
|
47
48
|
:png_alpha_trans => "PNG alpha channel transparency is not supported; only palette transparency is supported.",
|
48
49
|
:data_must_be_array => "The table data is not an Array. (Temporary limitation.)",
|
49
50
|
:columns_unspecified => "Columns are unspecified. They must be data[0] and be an array.",
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: contents.rb,v 1.2 2005/
|
9
|
+
# $Id: contents.rb,v 1.2.2.1 2005/08/25 03:38:06 austin Exp $
|
10
10
|
#++
|
11
11
|
# The contents objects hold all of the content which appears on pages
|
12
12
|
class PDF::Writer::Object::Contents < PDF::Writer::Object
|
@@ -25,7 +25,8 @@ class PDF::Writer::Object::Contents < PDF::Writer::Object
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
attr_reader
|
28
|
+
attr_reader :on_page
|
29
|
+
attr_accessor :data
|
29
30
|
|
30
31
|
def size
|
31
32
|
@data.size
|
@@ -6,11 +6,150 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: image.rb,v 1.2 2005/
|
9
|
+
# $Id: image.rb,v 1.2.2.1 2005/08/25 03:38:06 austin Exp $
|
10
10
|
#++
|
11
11
|
require 'pdf/writer/oreader'
|
12
12
|
|
13
|
-
|
13
|
+
# An image object. This will be an /XObject dictionary in the document. This
|
14
|
+
# includes description and data. The diectionary includes:
|
15
|
+
#
|
16
|
+
# Type:: (name, Optional) The type of PDF object that this
|
17
|
+
# dictionary describes; if present, must be /XObject for
|
18
|
+
# an image XObject.
|
19
|
+
# Subtype:: (name, Required) The type of XObject that this
|
20
|
+
# dictionary describes; must be /Image for an image
|
21
|
+
# /XObject.
|
22
|
+
# Width:: (integer, Required) The width of the image, in samples.
|
23
|
+
# Height:: (integer, Required) The height of the image, in samples.
|
24
|
+
# ColorSpace:: (name or array, Required for images, except those that
|
25
|
+
# use the /JPXDecode filter; not allowed for image
|
26
|
+
# masks) The color space in which image samples are
|
27
|
+
# specified; it can be any type of color space except
|
28
|
+
# /Pattern. If the image uses the JPXDecode filter, this
|
29
|
+
# entry is optional: * If /ColorSpace is present, any
|
30
|
+
# color space specifications in the JPEG2000 data are
|
31
|
+
# ignored. * If /ColorSpace is absent, the color space
|
32
|
+
# specifications in the JPEG2000 data are used. The
|
33
|
+
# /Decode array is also ignored unless /ImageMask is
|
34
|
+
# true.
|
35
|
+
# BitsPerComponent:: (integer, Required except for image masks and images
|
36
|
+
# that use the JPXDecode filter) The number of bits used
|
37
|
+
# to represent each color component. Only a single value
|
38
|
+
# may be specified; the number of bits is the same for
|
39
|
+
# all color components. Valid values are 1, 2, 4, 8, and
|
40
|
+
# (in PDF 1.5) 16. If /ImageMask is true, this entry is
|
41
|
+
# optional, and if specified, its value must be 1. If
|
42
|
+
# the image stream uses a filter, the value of
|
43
|
+
# BitsPerComponent must be consistent with the size of
|
44
|
+
# the data samples that the filter delivers. In
|
45
|
+
# particular, a CCITTFaxDecode or JBIG2Decode filter
|
46
|
+
# always delivers 1-bit samples, a RunLengthDecode or
|
47
|
+
# DCTDecode filter delivers 8-bit samples, and an
|
48
|
+
# LZWDecode or FlateDecode filter delivers samples of a
|
49
|
+
# specified size if a predictor function is used. If the
|
50
|
+
# image stream uses the JPXDecode filter, this entry is
|
51
|
+
# optional and ignored if present. The bit depth is
|
52
|
+
# determined in the process of decoding the JPEG2000
|
53
|
+
# image.
|
54
|
+
# Intent:: (name, Optional; PDF 1.1) The name of a color
|
55
|
+
# rendering intent to be used in rendering the image
|
56
|
+
# (see �Rendering Intents� on page 230). Default value:
|
57
|
+
# the current rendering intent in the graphics state.
|
58
|
+
# ImageMask:: (boolean, Optional) A flag indicating whether the
|
59
|
+
# image is to be treated as an image mask (see Section
|
60
|
+
# 4.8.5, �Masked Images�). If this flag is true, the
|
61
|
+
# value of /BitsPerComponent must be 1 and Mask and
|
62
|
+
# /ColorSpace should not be specified; unmasked areas
|
63
|
+
# are painted using the current nonstroking color.
|
64
|
+
# Default value: false.
|
65
|
+
# Mask:: (stream or array, Optional except for image masks; not
|
66
|
+
# allowed for image masks; PDF 1.3) An image XObject
|
67
|
+
# defining an image mask to be applied to this image
|
68
|
+
# (see �Explicit Masking� on page 321), or an array
|
69
|
+
# specifying a range of colors to be applied to it as a
|
70
|
+
# color key mask (see �Color Key Masking� on page 321).
|
71
|
+
# If ImageMask is true, this entry must not be present.
|
72
|
+
# (See implementation note 51 in Appendix H.)
|
73
|
+
# Decode:: (array, Optional) An array of numbers describing how
|
74
|
+
# to map image samples into the range of values
|
75
|
+
# appropriate for the image�s color space (see �Decode
|
76
|
+
# Arrays� on page 314). If ImageMask is true, the array
|
77
|
+
# must be either [0 1] or [1 0]; otherwise, its length
|
78
|
+
# must be twice the number of color components required
|
79
|
+
# by ColorSpace. If the image uses the JPXDecode filter
|
80
|
+
# and ImageMask is false, Decode is ignored. Default
|
81
|
+
# value: see �Decode Arrays� on page 314.
|
82
|
+
# Interpolate:: (boolean, Optional) A flag indicating whether image
|
83
|
+
# interpolation is to be performed (see �Image
|
84
|
+
# Interpolation� on page 316). Default value: false.
|
85
|
+
# Alternates:: (array, Optional; PDF 1.3) An array of alternate image
|
86
|
+
# dictionaries for this image (see �Alternate Images� on
|
87
|
+
# page 317). The order of elements within the array has
|
88
|
+
# no significance. This entry may not be present in an
|
89
|
+
# image XObject that is itself an alternate image.
|
90
|
+
# SMask:: (stream, Optional; PDF 1.4) A subsidiary image XObject
|
91
|
+
# defining a soft-mask image (see �Soft-Mask Images� on
|
92
|
+
# page 522) to be used as a source of mask shape or mask
|
93
|
+
# opacity values in the transparent imaging model. The
|
94
|
+
# alpha source parameter in the graphics state
|
95
|
+
# determines whether the mask values are interpreted as
|
96
|
+
# shape or opacity. If present, this entry overrides the
|
97
|
+
# current soft mask in the graphics state, as well as
|
98
|
+
# the image�s Mask entry, if any. (However, the other
|
99
|
+
# transparency related graphics state parameters�blend
|
100
|
+
# mode and alpha constant�remain in effect.) If SMask is
|
101
|
+
# absent, the image has no associated soft mask
|
102
|
+
# (although the current soft mask in the graphics state
|
103
|
+
# may still apply).
|
104
|
+
# SMaskInData:: (integer, Optional for images that use the JPXDecode
|
105
|
+
# filter, meaningless otherwise; PDF 1.5) A code
|
106
|
+
# specifying how soft-mask information (see �Soft-Mask
|
107
|
+
# Images� on page 522) encoded with image samples should
|
108
|
+
# be used: (0) If present, encoded soft-mask image
|
109
|
+
# information should be ignored. (1) The image�s data
|
110
|
+
# stream includes encoded soft-mask values. An
|
111
|
+
# application can create a soft-mask image from the
|
112
|
+
# information to be used as a source of mask shape or
|
113
|
+
# mask opacity in the transparency imaging model. (2)
|
114
|
+
# The image�s data stream includes color channels that
|
115
|
+
# have been preblended with a background; the image data
|
116
|
+
# also includes an opacity channel. An application can
|
117
|
+
# create a soft-mask image with a Matte entry from the
|
118
|
+
# opacity channel information to be used as a source of
|
119
|
+
# mask shape or mask opacity in the transparency model.
|
120
|
+
# * If this entry has a nonzero value, SMask should not
|
121
|
+
# be specified. See also Section 3.3.8, �JPXDecode
|
122
|
+
# Filter.� Default value: 0.
|
123
|
+
# Name:: (name, Required in PDF 1.0; optional otherwise) The
|
124
|
+
# name by which this image XObject is referenced in the
|
125
|
+
# XObject subdictionary of the current resource
|
126
|
+
# dictionary (see Section 3.7.2, �Resource
|
127
|
+
# Dictionaries�). Note: This entry is obsolescent and
|
128
|
+
# its use is no longer recommended. (See implementation
|
129
|
+
# note 52 in Appendix H.)
|
130
|
+
# StructParent:: (integer, Required if the image is a structural
|
131
|
+
# content item; PDF 1.3) The integer key of the image�s
|
132
|
+
# entry in the structural parent tree (see �Finding
|
133
|
+
# Structure Elements from Content Items� on page 797).
|
134
|
+
# ID:: (string, Optional; PDF 1.3; indirect reference
|
135
|
+
# preferred) The digital identifier of the image�s
|
136
|
+
# parent Web Capture content set (see Section 10.9.5,
|
137
|
+
# �Object Attributes Related to Web Capture�).
|
138
|
+
# OPI:: (dictionary, Optional; PDF 1.2) An OPI version
|
139
|
+
# dictionary for the image (see Section 10.10.6, �Open
|
140
|
+
# Prepress Interface (OPI)�). If ImageMask is true, this
|
141
|
+
# entry is ignored.
|
142
|
+
# Metadata:: (stream, Optional; PDF 1.4) A metadata stream
|
143
|
+
# containing metadata for the image (see Section 10.2.2,
|
144
|
+
# �Metadata Streams�).
|
145
|
+
# OC:: (dictionary, Optional; PDF 1.5) An optional content
|
146
|
+
# group or optional content membership dictionary (see
|
147
|
+
# Section 4.10, �Optional Content�), specifying the
|
148
|
+
# optional content properties for this image XObject.
|
149
|
+
# Before the image is processed, its visibility is
|
150
|
+
# determined based on this entry. If it is determined to
|
151
|
+
# be invisible, the entire image is skipped, as if there
|
152
|
+
# were no Do operator to invoke it.
|
14
153
|
class PDF::Writer::External::Image < PDF::Writer::External
|
15
154
|
attr_reader :label
|
16
155
|
attr_reader :image_info
|
@@ -46,11 +185,11 @@ class PDF::Writer::External::Image < PDF::Writer::External
|
|
46
185
|
@info['BitsPerComponent'] = 8
|
47
186
|
when "PNG"
|
48
187
|
if image.info[:compression_method] != 0
|
49
|
-
raise TypeError, PDF::Writer::
|
188
|
+
raise TypeError, PDF::Writer::Lang[:png_unsupp_compres]
|
50
189
|
end
|
51
190
|
|
52
191
|
if image.info[:filter_method] != 0
|
53
|
-
raise TypeError, PDF::Writer::
|
192
|
+
raise TypeError, PDF::Writer::Lang[:png_unsupp_filter]
|
54
193
|
end
|
55
194
|
|
56
195
|
data = data.dup
|
@@ -88,7 +227,7 @@ class PDF::Writer::External::Image < PDF::Writer::External
|
|
88
227
|
# Grey is two bytes, range 0 .. (2 ^ bit-depth) - 1
|
89
228
|
trans[:grayscale] = data.read_o(2).unpack("n")
|
90
229
|
trans[:type] = 'indexed'
|
91
|
-
|
230
|
+
# trans[:data] = data.read_o.unpack("C")
|
92
231
|
when 2
|
93
232
|
# True colour with proper alpha channel.
|
94
233
|
trans[:rgb] = data.read_o(6).unpack("nnn")
|
@@ -97,16 +236,16 @@ class PDF::Writer::External::Image < PDF::Writer::External
|
|
97
236
|
data.offset += chunk_size
|
98
237
|
end
|
99
238
|
|
100
|
-
ok = section != "IEND"
|
239
|
+
ok = (section != "IEND")
|
101
240
|
|
102
241
|
data.read_o(4) # Skip the CRC
|
103
242
|
end
|
104
243
|
|
105
244
|
if image.bits > 8
|
106
|
-
raise TypeError, PDF::Writer::
|
245
|
+
raise TypeError, PDF::Writer::Lang[:png_8bit_colour]
|
107
246
|
end
|
108
247
|
if image.info[:interlace_method] != 0
|
109
|
-
raise TypeError, PDF::Writer::
|
248
|
+
raise TypeError, PDF::Writer::Lang[:png_interlace]
|
110
249
|
end
|
111
250
|
|
112
251
|
ncolor = 1
|
@@ -119,7 +258,7 @@ class PDF::Writer::External::Image < PDF::Writer::External
|
|
119
258
|
when 0
|
120
259
|
colour = 'DeviceGray'
|
121
260
|
else
|
122
|
-
raise TypeError, PDF::Writer::
|
261
|
+
raise TypeError, PDF::Writer::Lang[:png_alpha_trans]
|
123
262
|
end
|
124
263
|
|
125
264
|
@info['Filter'] = '[/FlateDecode]'
|
@@ -128,7 +267,8 @@ class PDF::Writer::External::Image < PDF::Writer::External
|
|
128
267
|
|
129
268
|
unless palette.empty?
|
130
269
|
@info['ColorSpace'] = " [ /Indexed /DeviceRGB #{(palette.size / 3) - 1} "
|
131
|
-
contents = PDF::Writer::Contents.new
|
270
|
+
contents = PDF::Writer::Object::Contents.new(parent,
|
271
|
+
self)
|
132
272
|
contents.data = palette
|
133
273
|
@info['ColorSpace'] << "#{contents.oid} 0 R ]"
|
134
274
|
|
data/manual.pwd
CHANGED
@@ -98,7 +98,7 @@
|
|
98
98
|
# Use .eval to do encoding configuration.
|
99
99
|
.eval {{{
|
100
100
|
pdf.techbook_encoding = {
|
101
|
-
:encoding =>
|
101
|
+
:encoding => "WinAnsiEncoding",
|
102
102
|
:differences => {
|
103
103
|
169 => "copyright",
|
104
104
|
215 => "multiply",
|
@@ -111,7 +111,7 @@ pdf.select_font "Helvetica", pdf.techbook_encoding
|
|
111
111
|
# Put a heading on all pages.
|
112
112
|
pdf.open_object do |heading|
|
113
113
|
pdf.save_state
|
114
|
-
pdf.stroke_color! Color::Black
|
114
|
+
pdf.stroke_color! Color::RGB::Black
|
115
115
|
pdf.stroke_style! PDF::Writer::StrokeStyle::DEFAULT
|
116
116
|
|
117
117
|
s = 6
|
@@ -134,7 +134,7 @@ end
|
|
134
134
|
# Put a footing on all pages.
|
135
135
|
pdf.open_object do |footing|
|
136
136
|
pdf.save_state
|
137
|
-
pdf.stroke_color! Color::Black
|
137
|
+
pdf.stroke_color! Color::RGB::Black
|
138
138
|
pdf.stroke_style! PDF::Writer::StrokeStyle::DEFAULT
|
139
139
|
|
140
140
|
s = 6
|
@@ -172,11 +172,11 @@ size = 72
|
|
172
172
|
fh = pdf.font_height(size) * 1.01
|
173
173
|
fd = pdf.font_descender(size) * 1.01
|
174
174
|
pdf.save_state
|
175
|
-
pdf.fill_color Color::Red
|
176
|
-
pdf.stroke_color Color::Red
|
175
|
+
pdf.fill_color Color::RGB::Red
|
176
|
+
pdf.stroke_color Color::RGB::Red
|
177
177
|
pdf.rectangle(pdf.absolute_left_margin, 0, fh, pdf.page_height).fill
|
178
|
-
pdf.fill_color Color::White
|
179
|
-
pdf.stroke_color Color::White
|
178
|
+
pdf.fill_color Color::RGB::White
|
179
|
+
pdf.stroke_color Color::RGB::White
|
180
180
|
pdf.add_text(pdf.absolute_left_margin + fh + fd, 70, title, size, 90)
|
181
181
|
pdf.restore_state
|
182
182
|
|
@@ -199,12 +199,15 @@ Copyright
|
|
199
199
|
INFO
|
200
200
|
|
201
201
|
pdf.text(info, :font_size => 18, :justification => :right)
|
202
|
-
pdf.open_here(
|
202
|
+
pdf.open_here("Fit")
|
203
203
|
|
204
|
-
pdf.start_page_numbering(pnx, pny, 6, :right, "<PAGENUM>", 1)
|
205
204
|
pdf.techbook_fontsize = 12
|
206
205
|
.endeval }}}
|
207
206
|
.newpage
|
207
|
+
.eval {{{
|
208
|
+
pnx = pdf.absolute_right_margin
|
209
|
+
pdf.start_page_numbering(pnx, 36, 6, :right, "<PAGENUM>", 1)
|
210
|
+
.endeval }}}
|
208
211
|
# The main document.
|
209
212
|
1<Introduction to PDF::Writer for Ruby>Introduction
|
210
213
|
|
@@ -264,7 +267,7 @@ centered at the top of the page in 72-point (1
|
|
264
267
|
|
265
268
|
.code {{{
|
266
269
|
# This code is demo/hello.rb
|
267
|
-
require
|
270
|
+
require "pdf/writer"
|
268
271
|
|
269
272
|
pdf = PDF::Writer.new
|
270
273
|
pdf.select_font "Times-Roman"
|
@@ -278,7 +281,7 @@ that the images are JPEG and PNG
|
|
278
281
|
|
279
282
|
.code {{{
|
280
283
|
# This code is demo/chunkybacon.rb
|
281
|
-
require
|
284
|
+
require "pdf/writer"
|
282
285
|
|
283
286
|
pdf = PDF::Writer.new
|
284
287
|
pdf.select_font "Times-Roman"
|
@@ -529,13 +532,13 @@ pdf.select_font("Times-Roman", { :encoding => "MacExpertEncoding" })
|
|
529
532
|
# Set up the Helvetica font for use with German characters as an offset
|
530
533
|
# of the WinAnsiEncoding.
|
531
534
|
diff= {
|
532
|
-
196 =>
|
533
|
-
228 =>
|
534
|
-
214 =>
|
535
|
-
246 =>
|
536
|
-
220 =>
|
537
|
-
252 =>
|
538
|
-
223 =>
|
535
|
+
196 => "Adieresis",
|
536
|
+
228 => "adieresis",
|
537
|
+
214 => "Odieresis",
|
538
|
+
246 => "odieresis",
|
539
|
+
220 => "Udieresis",
|
540
|
+
252 => "udieresis",
|
541
|
+
223 => "germandbls"
|
539
542
|
}
|
540
543
|
pdf.select_font("Helvetica", { :encoding => "WinAnsiEncoding", :differences => diff })
|
541
544
|
.endcode }}}
|
@@ -558,10 +561,10 @@ pdf = PDF::Writer.new
|
|
558
561
|
# different font than "ib" (<i><b>).
|
559
562
|
pdf.font_families["Helvetica"] =
|
560
563
|
{
|
561
|
-
"b" =>
|
562
|
-
"i" =>
|
563
|
-
"bi" =>
|
564
|
-
"ib" =>
|
564
|
+
"b" => "Helvetica-Bold",
|
565
|
+
"i" => "Helvetica-Oblique",
|
566
|
+
"bi" => "Helvetica-BoldOblique",
|
567
|
+
"ib" => "Helvetica-BoldOblique"
|
565
568
|
}
|
566
569
|
.endcode }}}
|
567
570
|
|
@@ -624,7 +627,7 @@ built-in fonts as well).
|
|
624
627
|
|
625
628
|
.code {{{
|
626
629
|
encoding = {
|
627
|
-
:encoding =>
|
630
|
+
:encoding => "WinAnsiEncoding",
|
628
631
|
:differences => {
|
629
632
|
215 => "multiply",
|
630
633
|
148 => "copyright",
|
@@ -687,7 +690,7 @@ are standard US Letter (8
|
|
687
690
|
named parameters, <b>:paper</b>, <b>:version</b>, and <b>:orientation</b>.
|
688
691
|
|
689
692
|
.code {{{
|
690
|
-
require
|
693
|
+
require "pdf/writer"
|
691
694
|
|
692
695
|
# US Letter, portrait, 1.3
|
693
696
|
PDF::Writer.new
|
@@ -806,7 +809,7 @@ points).
|
|
806
809
|
Prepress marks will appear on all pages.
|
807
810
|
|
808
811
|
.code {{{
|
809
|
-
require
|
812
|
+
require "pdf/writer"
|
810
813
|
|
811
814
|
PDF::Writer.prepress # US Letter, portrait, 1.3, prepress
|
812
815
|
.endcode }}}
|
@@ -1119,7 +1122,7 @@ encountered.
|
|
1119
1122
|
The example below is the �bullet� tag from PDF::Writer.
|
1120
1123
|
.code {{{
|
1121
1124
|
class TagBullet
|
1122
|
-
DEFAULT_COLOR = Color::Black
|
1125
|
+
DEFAULT_COLOR = Color::RGB::Black
|
1123
1126
|
|
1124
1127
|
class << self
|
1125
1128
|
attr_accessor :color
|
@@ -1274,8 +1277,8 @@ The callback object is <b>PDF::Writer::TagAlink</b>. The display style of
|
|
1274
1277
|
linking and link underlining may be modified through
|
1275
1278
|
<b>TagAlink.style</b>, which is a hash of five keys:
|
1276
1279
|
.blist {{{
|
1277
|
-
<b>:color</b> is colour of the link underline. The default is Color::Blue. If nil, the current stroke colour will be maintained.
|
1278
|
-
<b>:text_color</b> is the colour of the text. The default is Color::Blue. If nil, the current fill colour will be maintained.
|
1280
|
+
<b>:color</b> is colour of the link underline. The default is Color::RGB::Blue. If nil, the current stroke colour will be maintained.
|
1281
|
+
<b>:text_color</b> is the colour of the text. The default is Color::RGB::Blue. If nil, the current fill colour will be maintained.
|
1279
1282
|
<b>:factor</b> is the size of the line, as a multiplier of the text height. The default is 5% of the line height (0.05).
|
1280
1283
|
<b>:line_style</b> is a style modification hash provided to PDF::Writer::StrokeStyle.new. The default is a solid line with normal cap, join, and miter limit values. See �<r:xref name="StrokeStyleClass" label="title" />� for more information.
|
1281
1284
|
<b>:draw_line</b> indicates whether the underline should be drawn or not.
|
@@ -1321,14 +1324,14 @@ linking and link underlining may be modified through
|
|
1321
1324
|
The <C:bullet> tag inserts a solid circular bullet, like this:
|
1322
1325
|
� <C:bullet />�. Bullets are implemented in <b>PDF::Writer::TagBullet</b>. The
|
1323
1326
|
bullet display colour may be modified through <b>TagBullet.color</b>, which
|
1324
|
-
defaults to <b>Color::Black</b>.
|
1327
|
+
defaults to <b>Color::RGB::Black</b>.
|
1325
1328
|
|
1326
1329
|
5<<C:disc>>
|
1327
1330
|
The <C:disc> tag inserts a hollow circular bullet, like this: � <C:disc
|
1328
1331
|
/>�. Bullets are implemented in <b>PDF::Writer::TagDisc</b>. The disc display
|
1329
1332
|
colours may be modified throguh <b>TagDisc.foreground</b> and
|
1330
|
-
<b>TagDisc.background</b>, which default to <b>Color::Black</b> and
|
1331
|
-
<b>Color::White</b>, respectively.
|
1333
|
+
<b>TagDisc.background</b>, which default to <b>Color::RGB::Black</b> and
|
1334
|
+
<b>Color::RGB::White</b>, respectively.
|
1332
1335
|
|
1333
1336
|
5<<C:tocdots ...>>
|
1334
1337
|
This is a stand-alone callback that draws a dotted line over to the right and
|
@@ -1677,8 +1680,8 @@ Returns <b>true</b> if columns are turned on.
|
|
1677
1680
|
2<Page Numbering>PageNumbering
|
1678
1681
|
PDF::Writer supports automatic page numbering. The current page numbering
|
1679
1682
|
system does not support anything except standard Arabic numbering (e.g., 1,
|
1680
|
-
2, 3). <b>The page numbering mechanism will be changing in a
|
1681
|
-
PDF::Writer to be far more flexible.</b>
|
1683
|
+
2, 3). <b>The page numbering mechanism will be changing in a future version
|
1684
|
+
of PDF::Writer to be far more flexible.</b>
|
1682
1685
|
|
1683
1686
|
4<PDF::Writer#start_page_numbering(x, y, size, pos = nil, pattern = nil, starting = nil)>
|
1684
1687
|
Prepares the placement of page numbers on pages from the current page. Place
|
@@ -1705,8 +1708,8 @@ page (labelled
|
|
1705
1708
|
pdf = PDF::Writer.new
|
1706
1709
|
pdf.select_font "Helvetica"
|
1707
1710
|
# page 1, blank
|
1708
|
-
pdf.start_page_numbering(300, 500, 20, nil, nil, 1)
|
1709
1711
|
pdf.start_new_page # page 2, 1 of 9
|
1712
|
+
pdf.start_page_numbering(300, 500, 20, nil, nil, 1)
|
1710
1713
|
pdf.start_new_page # page 3, 2 of 9
|
1711
1714
|
pdf.start_new_page # page 4, 3 of 9
|
1712
1715
|
pdf.start_new_page # page 5, 4 of 9
|
@@ -2013,12 +2016,12 @@ y = pdf.y + 90
|
|
2013
2016
|
|
2014
2017
|
pdf.select_font "Times-Roman"
|
2015
2018
|
|
2016
|
-
pdf.fill_color Color::Grey70
|
2017
|
-
pdf.stroke_color! Color::Black
|
2019
|
+
pdf.fill_color Color::RGB::Grey70
|
2020
|
+
pdf.stroke_color! Color::RGB::Black
|
2018
2021
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2019
2022
|
pdf.rectangle(pdf.absolute_left_margin, y + 64, pdf.margin_width, -100).fill_stroke
|
2020
2023
|
|
2021
|
-
pdf.fill_color Color::Black
|
2024
|
+
pdf.fill_color Color::RGB::Black
|
2022
2025
|
|
2023
2026
|
(0..7).each do |style|
|
2024
2027
|
pdf.add_text(pdf.absolute_left_margin + 20 + (60 * style), y + 48,
|
@@ -2412,7 +2415,7 @@ pdf.line(100, pdf.y - 5, 400, pdf.y + 5)
|
|
2412
2415
|
.eval {{{
|
2413
2416
|
pdf.move_pointer(20, true)
|
2414
2417
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2415
|
-
pdf.stroke_color Color::Black
|
2418
|
+
pdf.stroke_color Color::RGB::Black
|
2416
2419
|
pdf.line(100, pdf.y - 15, 400, pdf.y - 5).stroke
|
2417
2420
|
.endeval }}}
|
2418
2421
|
|
@@ -2428,7 +2431,7 @@ pdf.curve(100, pdf.y - 5, 200, pdf.y + 5, 300, pdf.y - 5, 400, pdf.y + 5
|
|
2428
2431
|
.eval {{{
|
2429
2432
|
pdf.move_pointer(20, true)
|
2430
2433
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2431
|
-
pdf.stroke_color Color::Black
|
2434
|
+
pdf.stroke_color Color::RGB::Black
|
2432
2435
|
pdf.curve(100, pdf.y - 15, 200, pdf.y - 5, 300, pdf.y - 15, 400, pdf.y - 5)
|
2433
2436
|
pdf.stroke
|
2434
2437
|
.endeval }}}
|
@@ -2445,7 +2448,7 @@ pdf.scurve(100, pdf.y - 5, 300, pdf.y + 5, 400, pdf.y - 5)
|
|
2445
2448
|
.eval {{{
|
2446
2449
|
pdf.move_pointer(20, true)
|
2447
2450
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2448
|
-
pdf.stroke_color Color::Black
|
2451
|
+
pdf.stroke_color Color::RGB::Black
|
2449
2452
|
pdf.scurve(100, pdf.y - 15, 300, pdf.y - 5, 400, pdf.y - 15).stroke
|
2450
2453
|
.endeval }}}
|
2451
2454
|
|
@@ -2461,7 +2464,7 @@ pdf.ecurve(100, pdf.y - 5, 200, pdf.y + 5, 400, pdf.y - 5)
|
|
2461
2464
|
.eval {{{
|
2462
2465
|
pdf.move_pointer(20, true)
|
2463
2466
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2464
|
-
pdf.stroke_color Color::Black
|
2467
|
+
pdf.stroke_color Color::RGB::Black
|
2465
2468
|
pdf.ecurve(100, pdf.y - 15, 200, pdf.y - 5, 400, pdf.y - 15)
|
2466
2469
|
pdf.stroke
|
2467
2470
|
.endeval }}}
|
@@ -2476,7 +2479,7 @@ pdf.circle_at(250, pdf.y, 10)
|
|
2476
2479
|
.eval {{{
|
2477
2480
|
pdf.move_pointer(30, true)
|
2478
2481
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2479
|
-
pdf.stroke_color Color::Black
|
2482
|
+
pdf.stroke_color Color::RGB::Black
|
2480
2483
|
pdf.circle_at(250, pdf.y + 15, 10)
|
2481
2484
|
pdf.stroke
|
2482
2485
|
.endeval }}}
|
@@ -2492,7 +2495,7 @@ pdf.ellipse_at(250, pdf.y, 20, 10)
|
|
2492
2495
|
.eval {{{
|
2493
2496
|
pdf.move_pointer(30, true)
|
2494
2497
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2495
|
-
pdf.stroke_color Color::Black
|
2498
|
+
pdf.stroke_color Color::RGB::Black
|
2496
2499
|
pdf.ellipse_at(250, pdf.y + 15, 20, 10)
|
2497
2500
|
pdf.stroke
|
2498
2501
|
.endeval }}}
|
@@ -2512,7 +2515,7 @@ pdf.ellipse2_at(250, pdf.y, 20, 10)
|
|
2512
2515
|
.eval {{{
|
2513
2516
|
pdf.move_pointer(30, true)
|
2514
2517
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2515
|
-
pdf.stroke_color Color::Black
|
2518
|
+
pdf.stroke_color Color::RGB::Black
|
2516
2519
|
pdf.ellipse2_at(250, pdf.y + 15, 20, 10).stroke
|
2517
2520
|
.endeval }}}
|
2518
2521
|
|
@@ -2522,7 +2525,7 @@ pdf.ellipse2_at(250, pdf.y, 20, 10, 135, -45)
|
|
2522
2525
|
.eval {{{
|
2523
2526
|
pdf.move_pointer(30, true)
|
2524
2527
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2525
|
-
pdf.stroke_color Color::Black
|
2528
|
+
pdf.stroke_color Color::RGB::Black
|
2526
2529
|
pdf.ellipse2_at(250, pdf.y + 15, 20, 10, 135, -45).stroke
|
2527
2530
|
.endeval }}}
|
2528
2531
|
|
@@ -2531,11 +2534,11 @@ ss = PDF::Writer::StrokeStyle.new(2)
|
|
2531
2534
|
ss.cap = :round
|
2532
2535
|
|
2533
2536
|
pdf.stroke_style ss
|
2534
|
-
pdf.fill_color! Color::BlueViolet
|
2537
|
+
pdf.fill_color! Color::RGB::BlueViolet
|
2535
2538
|
pdf.translate_axis(300, pdf.y + 25)
|
2536
2539
|
pdf.circle_at(0, 0, 38).fill
|
2537
2540
|
pdf.rotate_axis(10)
|
2538
|
-
pdf.stroke_color! Color::Grey30
|
2541
|
+
pdf.stroke_color! Color::RGB::Grey30
|
2539
2542
|
pdf.ellipse2_at(0, 0, 81, 20, 65.5, -245.5).stroke
|
2540
2543
|
pdf.ellipse2_at(0, 0, 85, 22, 67.5, -247.5).stroke
|
2541
2544
|
pdf.ellipse2_at(0, 0, 89, 25, 70.5, -250.5).stroke
|
@@ -2547,11 +2550,11 @@ ss = PDF::Writer::StrokeStyle.new(2)
|
|
2547
2550
|
ss.cap = :round
|
2548
2551
|
|
2549
2552
|
pdf.stroke_style ss
|
2550
|
-
pdf.fill_color! Color::BlueViolet
|
2553
|
+
pdf.fill_color! Color::RGB::BlueViolet
|
2551
2554
|
pdf.translate_axis(300, pdf.y + 25)
|
2552
2555
|
pdf.circle_at(0, 0, 38).fill
|
2553
2556
|
pdf.rotate_axis(10)
|
2554
|
-
pdf.stroke_color! Color::Grey30
|
2557
|
+
pdf.stroke_color! Color::RGB::Grey30
|
2555
2558
|
pdf.ellipse2_at(0, 0, 81, 20, 65.5, -245.5).stroke
|
2556
2559
|
pdf.ellipse2_at(0, 0, 85, 22, 67.5, -247.5).stroke
|
2557
2560
|
pdf.ellipse2_at(0, 0, 89, 25, 70.5, -250.5).stroke
|
@@ -2568,7 +2571,7 @@ pdf.segment_at(250, pdf.y, 20, 10, 45, -45)
|
|
2568
2571
|
.eval {{{
|
2569
2572
|
pdf.move_pointer(30, true)
|
2570
2573
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2571
|
-
pdf.stroke_color Color::Black
|
2574
|
+
pdf.stroke_color Color::RGB::Black
|
2572
2575
|
pdf.segment_at(250, pdf.y + 15, 20, 10, 45, -45)
|
2573
2576
|
pdf.stroke
|
2574
2577
|
.endeval }}}
|
@@ -2676,7 +2679,7 @@ pdf.rounded_rectangle(100, pdf.y, 300, 30, 5)
|
|
2676
2679
|
.eval {{{
|
2677
2680
|
pdf.move_pointer(40, true)
|
2678
2681
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2679
|
-
pdf.stroke_color Color::Black
|
2682
|
+
pdf.stroke_color Color::RGB::Black
|
2680
2683
|
pdf.rounded_rectangle(100, pdf.y + 35, 100, 30, 10)
|
2681
2684
|
pdf.stroke
|
2682
2685
|
pdf.move_pointer(5, true)
|
@@ -2699,7 +2702,7 @@ pdf.star(430, pdf.y, 20, 8).stroke
|
|
2699
2702
|
.eval {{{
|
2700
2703
|
pdf.move_pointer(40, true)
|
2701
2704
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2702
|
-
pdf.stroke_color Color::Black
|
2705
|
+
pdf.stroke_color Color::RGB::Black
|
2703
2706
|
pdf.star(166, pdf.y + 15, 20, 4).stroke
|
2704
2707
|
pdf.star(232, pdf.y + 15, 20, 5).stroke
|
2705
2708
|
pdf.star(298, pdf.y + 15, 20, 6).stroke
|
@@ -2781,7 +2784,7 @@ winding number fill rule, it is hollow.
|
|
2781
2784
|
.eval {{{
|
2782
2785
|
pdf.move_pointer(60, true)
|
2783
2786
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2784
|
-
pdf.stroke_color Color::Black
|
2787
|
+
pdf.stroke_color Color::RGB::Black
|
2785
2788
|
y0 = pdf.y + 50 # top
|
2786
2789
|
y1 = y0 - 10 # top-middle
|
2787
2790
|
y2 = y1 - 20 # bottom-middle
|
@@ -2816,7 +2819,7 @@ filled using the even-odd rule. They appear the same.
|
|
2816
2819
|
.eval {{{
|
2817
2820
|
pdf.move_pointer(60, true)
|
2818
2821
|
pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
|
2819
|
-
pdf.stroke_color Color::Black
|
2822
|
+
pdf.stroke_color Color::RGB::Black
|
2820
2823
|
y0 = pdf.y + 50 # top
|
2821
2824
|
y1 = y0 - 10 # top-middle
|
2822
2825
|
y2 = y1 - 20 # bottom-middle
|
@@ -3556,13 +3559,13 @@ The font size of the heading cells, in points. Defaults to 12 points.
|
|
3556
3559
|
The font size of the #title, in points. Defaults to 12 points.
|
3557
3560
|
|
3558
3561
|
4<SimpleTable#title_color, SimpleTable#title_color=>
|
3559
|
-
The text colour of the #title. Defaults to Color::Black.
|
3562
|
+
The text colour of the #title. Defaults to Color::RGB::Black.
|
3560
3563
|
|
3561
3564
|
4<SimpleTable#heading_color, SimpleTable#heading_color=>
|
3562
|
-
The text colour of the heading. Defaults to Color::Black.
|
3565
|
+
The text colour of the heading. Defaults to Color::RGB::Black.
|
3563
3566
|
|
3564
3567
|
4<SimpleTable#text_color, SimpleTable#text_color=>
|
3565
|
-
The text colour of the body cells. Defaults to Color::Black.
|
3568
|
+
The text colour of the body cells. Defaults to Color::RGB::Black.
|
3566
3569
|
|
3567
3570
|
4<SimpleTable#bold_headings, SimpleTable#bold_headings=>
|
3568
3571
|
Makes the heading text bold if <b>true</b>. The default is <b>false</b>.
|
@@ -3599,16 +3602,16 @@ colour.
|
|
3599
3602
|
4<SimpleTable#shade_color2, SimpleTable#shade_color2=>
|
3600
3603
|
|
3601
3604
|
The main and alternate shading colours. #shade_color defaults to
|
3602
|
-
Color::Grey80; #shade_color2 defaults to Color::Grey70.
|
3605
|
+
Color::RGB::Grey80; #shade_color2 defaults to Color::RGB::Grey70.
|
3603
3606
|
|
3604
3607
|
4<SimpleTable#shade_headings, SimpleTable#shade_headings=>
|
3605
3608
|
4<SimpleTable#shade_heading_color, SimpleTable#shade_heading_color=>
|
3606
3609
|
If #shade_headings is <b>true</b>, heading rows will be shaded with the value
|
3607
|
-
of #shade_heading_color (Color::Grey90 by default). Headings are not
|
3608
|
-
by default.
|
3610
|
+
of #shade_heading_color (Color::RGB::Grey90 by default). Headings are not
|
3611
|
+
shaded by default.
|
3609
3612
|
|
3610
3613
|
4<SimpleTable#line_color, SimpleTable#line_color=>
|
3611
|
-
The colour of table lines, defaultting to Color::Black.
|
3614
|
+
The colour of table lines, defaultting to Color::RGB::Black.
|
3612
3615
|
|
3613
3616
|
4<SimpleTable#inner_line_style, SimpleTable#inner_line_style=>
|
3614
3617
|
4<SimpleTable#outer_line_style, SimpleTable#outer_line_style=>
|
@@ -4099,7 +4102,7 @@ PDF::Charts::StdDev::Scale.new do |scale|
|
|
4099
4102
|
scale.show_labels = false
|
4100
4103
|
PDF::Charts::StdDev::Label.new do |label|
|
4101
4104
|
label.text_size = 8
|
4102
|
-
label.text_color = Color::Black
|
4105
|
+
label.text_color = Color::RGB::Black
|
4103
4106
|
label.pad = 2
|
4104
4107
|
label.decimal_precision = 1
|
4105
4108
|
scale.label = label
|
@@ -4133,8 +4136,8 @@ StdDev::Label object.
|
|
4133
4136
|
# This is the default chart label style.
|
4134
4137
|
Label.new do |label|
|
4135
4138
|
label.height = 25
|
4136
|
-
label.background_color = Color::Black
|
4137
|
-
label.text_color = Color::White
|
4139
|
+
label.background_color = Color::RGB::Black
|
4140
|
+
label.text_color = Color::RGB::White
|
4138
4141
|
label.text_size = 12
|
4139
4142
|
chart.label = label
|
4140
4143
|
end
|
@@ -4149,7 +4152,7 @@ drawn. If set, they must be PDF::Charts::StdDev::Marker objects.
|
|
4149
4152
|
# These are the defaults.
|
4150
4153
|
PDF::Charts::StdDev::Marker.new do |marker|
|
4151
4154
|
marker.style = PDF::Writer::StrokeStyle.new(1.5)
|
4152
|
-
marker.color = Color::Black
|
4155
|
+
marker.color = Color::RGB::Black
|
4153
4156
|
chart.outer_borders = marker
|
4154
4157
|
end
|
4155
4158
|
chart.inner_borders = nil
|
@@ -4173,22 +4176,22 @@ as it is thick.
|
|
4173
4176
|
# These are the defaults.
|
4174
4177
|
PDF::Charts::StdDev::Marker.new do |marker|
|
4175
4178
|
marker.style = PDF::Writer::StrokeStyle.new(5)
|
4176
|
-
marker.color = Color::Black
|
4179
|
+
marker.color = Color::RGB::Black
|
4177
4180
|
chart.dot = marker
|
4178
4181
|
end
|
4179
4182
|
PDF::Charts::StdDev::Marker.new do |marker|
|
4180
4183
|
marker.style = PDF::Writer::StrokeStyle.new(0.5)
|
4181
|
-
marker.color = Color::Black
|
4184
|
+
marker.color = Color::RGB::Black
|
4182
4185
|
chart.bar = marker
|
4183
4186
|
end
|
4184
4187
|
PDF::Charts::StdDev::Marker.new do |marker|
|
4185
4188
|
marker.style = PDF::Writer::StrokeStyle.new(1)
|
4186
|
-
marker.color = Color::Black
|
4189
|
+
marker.color = Color::RGB::Black
|
4187
4190
|
chart.upper_crossbar = marker
|
4188
4191
|
end
|
4189
4192
|
PDF::Charts::StdDev::Marker.new do |marker|
|
4190
4193
|
marker.style = PDF::Writer::StrokeStyle.new(1)
|
4191
|
-
marker.color = Color::Black
|
4194
|
+
marker.color = Color::RGB::Black
|
4192
4195
|
chart.lower_crossbar = marker
|
4193
4196
|
end
|
4194
4197
|
.endcode }}}
|
@@ -4351,13 +4354,13 @@ pdf.move_pointer(150, true)
|
|
4351
4354
|
_y = pdf.y + 140
|
4352
4355
|
|
4353
4356
|
pdf.save_state
|
4354
|
-
pdf.stroke_color! Color::Black
|
4357
|
+
pdf.stroke_color! Color::RGB::Black
|
4355
4358
|
pdf.stroke_style! PDF::Writer::StrokeStyle::DEFAULT
|
4356
4359
|
|
4357
4360
|
pdf.rectangle(100, _y, 75, -50).line(125, _y, 125, _y - 50)
|
4358
4361
|
pdf.line(150, _y, 150, _y - 50).stroke
|
4359
4362
|
|
4360
|
-
pdf.fill_color Color::Grey60
|
4363
|
+
pdf.fill_color Color::RGB::Grey60
|
4361
4364
|
pdf.add_text(105, _y - 36, "1", 36)
|
4362
4365
|
pdf.add_text(130, _y - 36, "2", 36)
|
4363
4366
|
pdf.add_text(155, _y - 36, "3", 36)
|
@@ -4365,12 +4368,12 @@ pdf.add_text(155, _y - 36, "3", 36)
|
|
4365
4368
|
pdf.rectangle(215, _y - 15, 25, -50).stroke
|
4366
4369
|
pdf.add_text(220, _y - 51, "3", 36)
|
4367
4370
|
pdf.line(225, _y, 215, _y - 15).line(225, _y - 50, 215, _y - 65).stroke
|
4368
|
-
pdf.fill_color Color::White
|
4371
|
+
pdf.fill_color Color::RGB::White
|
4369
4372
|
pdf.rectangle(200, _y, 25, -50).fill_stroke
|
4370
|
-
pdf.fill_color Color::Grey60
|
4373
|
+
pdf.fill_color Color::RGB::Grey60
|
4371
4374
|
pdf.add_text(205, _y - 36, "1", 36)
|
4372
4375
|
|
4373
|
-
pdf.fill_color Color::Black
|
4376
|
+
pdf.fill_color Color::RGB::Black
|
4374
4377
|
pdf.line(200, _y + 5, 225, _y + 5).stroke
|
4375
4378
|
pdf.move_to(227, _y + 5).line_to(220, _y + 7.5).line_to(220, _y + 2.5)
|
4376
4379
|
pdf.close_fill
|
@@ -4402,12 +4405,12 @@ pdf.move_pointer(150, true)
|
|
4402
4405
|
_y = pdf.y + 140
|
4403
4406
|
pdf.save_state
|
4404
4407
|
|
4405
|
-
pdf.stroke_color! Color::Black
|
4408
|
+
pdf.stroke_color! Color::RGB::Black
|
4406
4409
|
pdf.stroke_style! PDF::Writer::StrokeStyle::DEFAULT
|
4407
4410
|
pdf.rectangle(100, _y, 75, -50).line(125, _y, 125, _y - 50)
|
4408
4411
|
pdf.line(150, _y, 150, _y - 50).stroke
|
4409
4412
|
|
4410
|
-
pdf.fill_color Color::Grey60
|
4413
|
+
pdf.fill_color Color::RGB::Grey60
|
4411
4414
|
pdf.add_text(103, _y - 36, "1", 36)
|
4412
4415
|
pdf.add_text(128, _y - 36, "2", 36)
|
4413
4416
|
pdf.add_text(153, _y - 36, "3", 36)
|
@@ -4420,7 +4423,7 @@ pdf.line(255, _y - 40, 250, _y - 50).stroke
|
|
4420
4423
|
pdf.add_text(228, _y - 36, "2", 36)
|
4421
4424
|
|
4422
4425
|
pdf.save_state
|
4423
|
-
pdf.fill_color Color::Black
|
4426
|
+
pdf.fill_color Color::RGB::Black
|
4424
4427
|
pdf.line(250, _y - 60, 275, _y - 60).stroke
|
4425
4428
|
pdf.move_to(248, _y - 60).line_to(255, _y - 57.5).line_to(255, _y - 62.5)
|
4426
4429
|
pdf.close_fill
|
@@ -4432,7 +4435,7 @@ pdf.line(320, _y - 40, 325, _y - 50).stroke
|
|
4432
4435
|
pdf.add_text(328, _y - 36, "4", 36)
|
4433
4436
|
pdf.save_state
|
4434
4437
|
pdf.line(300, _y - 60, 325, _y - 60).stroke
|
4435
|
-
pdf.fill_color Color::Black
|
4438
|
+
pdf.fill_color Color::RGB::Black
|
4436
4439
|
pdf.move_to(327, _y - 60).line_to(320, _y - 57.5).line_to(320, _y - 62.5)
|
4437
4440
|
pdf.close_fill
|
4438
4441
|
pdf.restore_state
|
@@ -4541,7 +4544,7 @@ platform dependent). The text will be placed with full justification.
|
|
4541
4544
|
3<QuickRef#pre(text)>
|
4542
4545
|
Writes code text. Newlines and spaces will be preserved.
|
4543
4546
|
|
4544
|
-
3<QuickRef#hline(style = PDF::Writer::StrokeStyle::DEFAULT, color = Color::Black)>
|
4547
|
+
3<QuickRef#hline(style = PDF::Writer::StrokeStyle::DEFAULT, color = Color::RGB::Black)>
|
4545
4548
|
Draws a horizontal line with the specified style and colour across the width
|
4546
4549
|
of the column.
|
4547
4550
|
|
@@ -5089,18 +5092,27 @@ must be understood. Transaction::Simple:
|
|
5089
5092
|
2<color-tools>ColorTools
|
5090
5093
|
The color-tools package was created to abstract out the colour needs for
|
5091
5094
|
PDF::Writer and make them available for other uses as well (such as web
|
5092
|
-
pages). There are
|
5095
|
+
pages). There are several main components to color-tools in version 1.3.0:
|
5093
5096
|
.blist {{{
|
5094
5097
|
Named colours: more than 150 named RGB colours so that the exact colour representation does not need to be remembered.
|
5095
5098
|
Color::RGB: a colour class that encapsulates operations on RGB (red, green, blue) colours.
|
5096
5099
|
Color::CMYK: a colour class that encapsulates operations on CMYK (cyan, magenta, yellow, black) colours, mostly used for printing.
|
5100
|
+
Color::GrayScale: a colour class that encapsulates operations on greyscale colours, mostly used for PDF operations.
|
5101
|
+
Color::YIQ: a colour class that encapsulates the NTSC/YIQ video colour space.
|
5102
|
+
Color::HSL: a colour class that encapsulates the HSL (hue, saturation, luminance) colour space.
|
5097
5103
|
Color::Palette::MonoContrast: an RGB colour palette generator.
|
5098
|
-
Color::Palette::
|
5104
|
+
Color::Palette::Gimp: a class to read Gimp (GNU Image Manipulation Program) colour palettes and make them available for access.
|
5105
|
+
Color::CSS: An interface for interpreting named CSS3 colours.
|
5099
5106
|
.endblist }}}
|
5100
5107
|
|
5101
5108
|
3<Named Colors>
|
5102
|
-
There are more than 150 named colours available in the Color
|
5103
|
-
demo program demo/colornames.rb
|
5109
|
+
There are more than 150 named colours available in the Color::RGB and
|
5110
|
+
Color::RGB::Metallic namespaces. The demo program demo/colornames.rb shows
|
5111
|
+
these colours. The colours in Color::RGB used to be part of the Color
|
5112
|
+
namespace. If a colour like Color::Black is used, there will be a single
|
5113
|
+
warning printed. Future versions of color-tools will see a warning printed on
|
5114
|
+
every use (1.4.x) and ultimately the constants will be completely removed
|
5115
|
+
(1.5.x or 2.x).
|
5104
5116
|
|
5105
5117
|
3<Color::RGB>
|
5106
5118
|
This class encapsulates RGB colours and offers some operations on them. Other
|
@@ -5139,9 +5151,18 @@ fed = Color::RGB.from_html("fed")
|
|
5139
5151
|
cabbed = Color::RGB.from_html("#cabbed;")
|
5140
5152
|
.endcode }}}
|
5141
5153
|
|
5154
|
+
4<Color::RGB#==(other)>
|
5155
|
+
Compares the other colour to this one. The other colour will be converted to
|
5156
|
+
RGB before comparison, so the comparison between a RGB colour and a non-RGB
|
5157
|
+
colour will be approximate and based on the other colour�s default #to_rgb
|
5158
|
+
conversion. If there is no #to_rgb conversion, this will raise an exception.
|
5159
|
+
This will report that two RGB colours are equivalent if all component values
|
5160
|
+
are within 1e-4 (0.0001) of each other.
|
5161
|
+
|
5142
5162
|
4<Color::RGB#pdf_fill>
|
5143
5163
|
4<Color::RGB#pdf_stroke>
|
5144
|
-
Renders the colour as a string suitable for PDF colour changes.
|
5164
|
+
Renders the colour as a string suitable for PDF colour changes. These two
|
5165
|
+
methods will be removed from the color-tools base package in version 2.0.
|
5145
5166
|
.code {{{
|
5146
5167
|
cabbed.pdf_fill
|
5147
5168
|
blue.pdf_stroke
|
@@ -5161,17 +5182,56 @@ experts strongly suggest that this is a <b>bad</b> idea. CMYK colours
|
|
5161
5182
|
represent percentages of inks on paper, not mixed colour intensities like
|
5162
5183
|
RGB. The CMYK versions of RGB colours will usually be darker than the
|
5163
5184
|
original RGB.
|
5185
|
+
|
5164
5186
|
.code {{{
|
5165
5187
|
cabbed.to_cmyk
|
5166
5188
|
.endcode }}}
|
5167
5189
|
|
5190
|
+
The method used is as follows:
|
5191
|
+
|
5192
|
+
5<1. RGB-<CMY>
|
5193
|
+
Convert the R, G, and B components to C, M, and Y components.
|
5194
|
+
.code {{{
|
5195
|
+
c = 1.0 � r
|
5196
|
+
m = 1.0 � g
|
5197
|
+
y = 1.0 � b
|
5198
|
+
.endcode }}}
|
5199
|
+
|
5200
|
+
5<2. Minimum Black Calculation>
|
5201
|
+
Compute the minimum amount of black (K) required to smooth the colour in
|
5202
|
+
inks.
|
5203
|
+
.code {{{
|
5204
|
+
k = min(c, m, y)
|
5205
|
+
.endcode }}}
|
5206
|
+
|
5207
|
+
5<3. Undercolour Removal>
|
5208
|
+
Perform undercolour removal on the C, M, and Y components of the colours
|
5209
|
+
because less of each colour is needed for each bit of black. Also, regenerate
|
5210
|
+
the black (K) based on the undercolour removal so that the colour is more
|
5211
|
+
accurately represented in ink.
|
5212
|
+
.code {{{
|
5213
|
+
c = min(1.0, max(0.0, c � UCR(k)))
|
5214
|
+
m = min(1.0, max(0.0, m � UCR(k)))
|
5215
|
+
y = min(1.0, max(0.0, y � UCR(k)))
|
5216
|
+
k = min(1.0, max(0.0, BG(k)))
|
5217
|
+
.endcode }}}
|
5218
|
+
|
5219
|
+
The undercolour removal function and the black generation functions return a
|
5220
|
+
value based on the brightness of the RGB colour.
|
5221
|
+
|
5222
|
+
4<Color::RGB#to_rgb(ignored = nil)>
|
5223
|
+
Returns the existing colour object.
|
5224
|
+
|
5225
|
+
4<Color::RGB#to_hsl>
|
5226
|
+
Converts the colour to the HSL colour space.
|
5227
|
+
|
5168
5228
|
4<Color::RGB#lighten_by(percent)>
|
5169
|
-
|
5170
|
-
|
5229
|
+
Mix the RGB hue with White so that the RGB hue is the specified percentage of
|
5230
|
+
the resulting colour. Strictly speaking, this isn�t a lighten_by operation.
|
5171
5231
|
|
5172
5232
|
4<Color::RGB#darken_by(percent)>
|
5173
|
-
|
5174
|
-
|
5233
|
+
Mix the RGB hue with Black so that the RGB hue is the specified percentage of
|
5234
|
+
the resulting colour. Strictly speaking, this isn�t a darken_by operation.
|
5175
5235
|
|
5176
5236
|
4<Color::RGB#mix_with(mask, opacity)>
|
5177
5237
|
Mixes the mask colour (which must be an RGB object) with the current colour
|
@@ -5187,10 +5247,42 @@ keys of :y, :i, and :q.
|
|
5187
5247
|
Returns the perceived brightness value for a colour on a scale of 0 .. 1.
|
5188
5248
|
This is based on the Y (luminosity) value of YIQ colour encoding.
|
5189
5249
|
|
5250
|
+
4<Color::RGB#to_grayscale>
|
5251
|
+
4<Color::RGB#to_greyscale>
|
5252
|
+
Converts the color to a GrayScale colour based on the HSL luminance.
|
5253
|
+
|
5254
|
+
4<Color::RGB#adjust_brightness(percent)>
|
5255
|
+
Returns a new colour with the brightness adjusted by the specified
|
5256
|
+
percentage. Negative percentages will darken the colour; positive percentages
|
5257
|
+
will brighten the colour.
|
5258
|
+
.code {{{
|
5259
|
+
Color::RGB::DarkBlue.adjust_brightness(10)
|
5260
|
+
Color::RGB::DarkBlue.adjust_brightness(-10)
|
5261
|
+
.endcode }}}
|
5262
|
+
|
5263
|
+
4<Color::RGB#adjust_saturation(percent)>
|
5264
|
+
Returns a new colour with the saturation adjusted by the specified
|
5265
|
+
percentage. Negative percentages will reduce the saturation; positive
|
5266
|
+
percentages will increase the saturation.
|
5267
|
+
.code {{{
|
5268
|
+
Color::RGB::DarkBlue.adjust_saturation(10)
|
5269
|
+
Color::RGB::DarkBlue.adjust_saturation(-10)
|
5270
|
+
.endcode }}}
|
5271
|
+
|
5272
|
+
4<Color::RGB#adjust_hue(percent)>
|
5273
|
+
Returns a new colour with the hue adjusted by the specified percentage.
|
5274
|
+
Negative percentages will reduce the hue; positive percentages will increase
|
5275
|
+
the hue.
|
5276
|
+
.code {{{
|
5277
|
+
Color::RGB::DarkBlue.adjust_hue(10)
|
5278
|
+
Color::RGB::DarkBlue.adjust_hue(-10)
|
5279
|
+
.endcode }}}
|
5280
|
+
|
5190
5281
|
4<Color::RGB#r, Color::RGB#r=>
|
5191
5282
|
4<Color::RGB#g, Color::RGB#g=>
|
5192
5283
|
4<Color::RGB#b, Color::RGB#b=>
|
5193
|
-
Read and set the independent components of the RGB colour.
|
5284
|
+
Read and set the independent components of the RGB colour. The colour values
|
5285
|
+
will be in the range (0..1).
|
5194
5286
|
|
5195
5287
|
3<Color::CMYK>
|
5196
5288
|
This class encapsulates CMYK colours and offers some operations on them.
|
@@ -5203,31 +5295,256 @@ black = Color::CMYK.new(0, 0, 0, 100)
|
|
5203
5295
|
.endcode }}}
|
5204
5296
|
|
5205
5297
|
4<Color::CMYK.from_fraction(c = 0, m = 0, y = 0, k = 0)>
|
5206
|
-
Creates a CMYK colour object from fractional values.
|
5298
|
+
Creates a CMYK colour object from fractional values (0..1).
|
5207
5299
|
.code {{{
|
5208
5300
|
black = Color::CMYK.new(0, 0, 0, 1)
|
5209
5301
|
.endcode }}}
|
5210
5302
|
|
5303
|
+
4<Color::CMYK#==(other)>
|
5304
|
+
Compares the other colour to this one. The other colour will be converted to
|
5305
|
+
CMYK before comparison, so the comparison between a CMYK colour and a
|
5306
|
+
non-CMYK colour will be approximate and based on the other colour�s #to_cmyk
|
5307
|
+
conversion. If there is no #to_cmyk conversion, this will raise an exception.
|
5308
|
+
This will report that two CMYK colours are equivalent if all component values
|
5309
|
+
are within 1e-4 (0.0001) of each other.
|
5310
|
+
|
5211
5311
|
4<Color::CMYK#pdf_fill>
|
5212
5312
|
4<Color::CMYK#pdf_stroke>
|
5213
|
-
Renders the colour as a string suitable for PDF colour changes.
|
5313
|
+
Renders the colour as a string suitable for PDF colour changes. These two
|
5314
|
+
methods will be removed from the color-tools base package in version 2.0.
|
5214
5315
|
.code {{{
|
5215
5316
|
black.pdf_fill
|
5216
5317
|
black.pdf_stroke
|
5217
5318
|
.endcode }}}
|
5218
5319
|
|
5219
5320
|
4<Color::CMYK#html>
|
5220
|
-
|
5321
|
+
Present the colour as an RGB HTML/CSS colour string. Note that this will
|
5322
|
+
perform a #to_rgb operation using the default conversion formula.
|
5323
|
+
|
5324
|
+
4<Color::CMYK#to_rgb(use_adobe_method = false)>
|
5325
|
+
Converts the CMYK colour to RGB. Most colour experts strongly suggest that
|
5326
|
+
this is not a good idea (some even suggesting that it�s a very bad idea).
|
5327
|
+
CMYK represents additive percentages of inks on white paper, whereas RGB
|
5328
|
+
represents mixed colour intensities on a black screen.
|
5329
|
+
|
5330
|
+
However, the colour conversion can be done, and there are two different
|
5331
|
+
methods for the conversion that provide slightly different results. Adobe PDF
|
5332
|
+
conversions are done with the first form.
|
5333
|
+
|
5334
|
+
.code {{{
|
5335
|
+
# Adobe PDF Display Formula
|
5336
|
+
r = 1.0 - min(1.0, c + k)
|
5337
|
+
g = 1.0 - min(1.0, m + k)
|
5338
|
+
b = 1.0 - min(1.0, y + k)
|
5339
|
+
|
5340
|
+
# Other
|
5341
|
+
r = 1.0 - (c * (1.0 - k) + k)
|
5342
|
+
g = 1.0 - (m * (1.0 - k) + k)
|
5343
|
+
b = 1.0 - (y * (1.0 - k) + k)
|
5344
|
+
.endcode }}}
|
5221
5345
|
|
5222
|
-
|
5223
|
-
|
5224
|
-
|
5346
|
+
If we have a CMYK colour of [33% 66% 83% 25%], the first method will give an
|
5347
|
+
approximate RGB colour of (107, 23, 0) or #6b1700. The second method will
|
5348
|
+
give an approximate RGB colour of (128, 65, 33) or #804121. Which is correct?
|
5349
|
+
Although the colours may seem to be drastically different in the RGB colour
|
5350
|
+
space, they are very similar colours, differing mostly in intensity. The
|
5351
|
+
first is a darker, slightly redder brown; the second is a lighter brown.
|
5352
|
+
|
5353
|
+
Because of this subtlety, both methods are now offered for conversion in
|
5354
|
+
color-tools 1.2 or later. The Adobe method is not used by default; to enable
|
5355
|
+
it, pass <b>true</b> to #to_rgb.
|
5356
|
+
|
5357
|
+
Future versions of color-tools may offer other conversion mechanisms that
|
5358
|
+
offer greater colour fidelity.
|
5359
|
+
|
5360
|
+
4<Color::CMYK#to_grayscale>
|
5361
|
+
4<Color::CMYK#to_greyscale>
|
5362
|
+
Converts the CMYK colour to a single greyscale value. There are undoubtedly
|
5363
|
+
multiple methods for this conversion, but only a minor variant of the Adobe
|
5364
|
+
conversion method will be used:
|
5365
|
+
|
5366
|
+
.code {{{
|
5367
|
+
g = 1.0 - min(1.0, 0.299 * c + 0.587 * m + 0.114 * y + k)
|
5368
|
+
.endcode }}}
|
5369
|
+
|
5370
|
+
This treats the CMY values similarly to YIQ (NTSC) values and then adds the
|
5371
|
+
level of black. This is a variant of the Adobe version because it uses the
|
5372
|
+
more precise YIQ (NTSC) conversion values for Y (intensity) rather than the
|
5373
|
+
approximates provided by Adobe (0.3, 0.59, and 0.11).
|
5374
|
+
|
5375
|
+
4<Color::CMYK#to_cmyk>
|
5376
|
+
Returns the current CMYK colour object.
|
5377
|
+
|
5378
|
+
4<Color::CMYK#to_yiq>
|
5379
|
+
4<Color::CMYK#to_hsl>
|
5380
|
+
Converts to RGB and then HSL. Uses only the default RGB conversion method.
|
5225
5381
|
|
5226
5382
|
4<Color::CMYK#c, Color::CMYK#c=>
|
5227
5383
|
4<Color::CMYK#m, Color::CMYK#m=>
|
5228
5384
|
4<Color::CMYK#y, Color::CMYK#y=>
|
5229
5385
|
4<Color::CMYK#k, Color::CMYK#k=>
|
5230
|
-
Read and set the independent components of the CMYK colour.
|
5386
|
+
Read and set the independent components of the CMYK colour. The colour values
|
5387
|
+
will be in the range (0..1).
|
5388
|
+
|
5389
|
+
3<Color::GrayScale>
|
5390
|
+
Also know as Color::GreyScale, this is to provide colours representing
|
5391
|
+
continuous shades of grey.
|
5392
|
+
|
5393
|
+
4<Color::GrayScale.from_fraction(g = 0)>
|
5394
|
+
Creates a greyscale colour object from fractional (0..1).
|
5395
|
+
.code {{{
|
5396
|
+
Color::GreyScale.from_fraction(0.5)
|
5397
|
+
.endcode }}}
|
5398
|
+
|
5399
|
+
4<Color::GrayScale.new(g = 0)
|
5400
|
+
Creates a greyscale colour object from percentages (0..100).
|
5401
|
+
.code {{{
|
5402
|
+
Color::GrayScale.new(50)
|
5403
|
+
.endcode }}}
|
5404
|
+
|
5405
|
+
4<Color::GrayScale#==(other)>
|
5406
|
+
Compares the other colour to this one. The other colour will be converted to
|
5407
|
+
GreyScale before comparison, so the comparison between a GreyScale colour and
|
5408
|
+
a non-GreyScale colour will be approximate and based on the other colour�s
|
5409
|
+
#to_greyscale conversion. If there is no #to_greyscale conversion, this will
|
5410
|
+
raise an exception. This will report that two GreyScale values are equivalent
|
5411
|
+
if they are within 1e-4 (0.0001) of each other.
|
5412
|
+
|
5413
|
+
4<Color::GrayScale#pdf_fill>
|
5414
|
+
4<Color::GrayScale#pdf_stroke>
|
5415
|
+
Present the colour as a string suitable for PDF colour changes with
|
5416
|
+
DeviceGray. These two methods will be removed from the color-tools base
|
5417
|
+
package in version 2.0.
|
5418
|
+
|
5419
|
+
4<Color::GrayScale#html>
|
5420
|
+
Presents the colour as an RGB HTML/CSS colour string.
|
5421
|
+
|
5422
|
+
4<Color::GrayScale#to_cmyk>
|
5423
|
+
Convert the greyscale colour to CMYK.
|
5424
|
+
|
5425
|
+
4<Color::GrayScale#to_rgb(ignored = true)>
|
5426
|
+
Convert the greyscale colour to RGB.
|
5427
|
+
|
5428
|
+
4<Color::GrayScale#to_grayscale>
|
5429
|
+
4<Color::GrayScale#to_greyscale>
|
5430
|
+
Returns the current greyscale colour object.
|
5431
|
+
|
5432
|
+
4<Color::GrayScale#lighten_by>
|
5433
|
+
Lightens the greyscale colour by the stated percent.
|
5434
|
+
|
5435
|
+
4<Color::GrayScale#darken_by>
|
5436
|
+
Darkens the greyscale colour by the stated percent.
|
5437
|
+
|
5438
|
+
4<Color::GrayScale#to_yiq>
|
5439
|
+
Returns the YIQ (NTSC) colour encoding of the greyscale value. This is an
|
5440
|
+
approximation, as the values for I and Q are calculated by treating the
|
5441
|
+
greyscale value as an RGB value. The Y (intensity or brightness) value is the
|
5442
|
+
same as the greyscale value.
|
5443
|
+
|
5444
|
+
4<Color::GrayScale#to_hsl>
|
5445
|
+
Returns the HSL colour encoding of the greyscale value.
|
5446
|
+
|
5447
|
+
4<Color::GrayScale#brightness>
|
5448
|
+
Returns the brightness value for this greyscale value; this is the percentage
|
5449
|
+
of grey.
|
5450
|
+
|
5451
|
+
4<Color::GrayScale#g, Color::GrayScale#g=>
|
5452
|
+
Read and set the grayscale value. The colour values will be in the range
|
5453
|
+
(0..1).
|
5454
|
+
|
5455
|
+
3<Color::HSL>
|
5456
|
+
An HSL colour object. Internally, the hue (#h), saturation (#s), and
|
5457
|
+
luminosity (#l) values are dealt with as fractional values in the range
|
5458
|
+
(0..1).
|
5459
|
+
|
5460
|
+
4<Color::HSL.from_fraction(h = 0.0, s = 0.0, l = 0.0)>
|
5461
|
+
Creates an HSL colour object from fractional values 0..1.
|
5462
|
+
|
5463
|
+
4<Color::HSL.new(h = 0, s = 0, l = 0)>
|
5464
|
+
Creates an HSL colour object from the standard values of degrees and
|
5465
|
+
percentages (e.g., 145�, 30%, 50%).
|
5466
|
+
|
5467
|
+
4<Color::HSL#==(other)>
|
5468
|
+
Compares the other colour to this one. The other colour will be converted to
|
5469
|
+
HSL before comparison, so the comparison between a HSL colour and a non-HSL
|
5470
|
+
colour will be approximate and based on the other colour�s #to_hsl
|
5471
|
+
conversion. If there is no #to_hsl conversion, this will raise an exception.
|
5472
|
+
This will report that two HSL values are equivalent if all component values
|
5473
|
+
are within 1e-4 (0.0001) of each other.
|
5474
|
+
|
5475
|
+
4<Color::HSL#html>
|
5476
|
+
Present the colour as an HTML/CSS colour string.
|
5477
|
+
|
5478
|
+
4<Color::HSL#to_rgb(ignored = nil)>
|
5479
|
+
Converting to HSL as adapted from Foley and Van-Dam from
|
5480
|
+
<c:alink
|
5481
|
+
uri="http://www.bobpowell.net/RGBHSB.htm">http://www.bobpowell.net/RGBHSB.htm</c:alink>.
|
5482
|
+
|
5483
|
+
4<Color::HSL#to_yiq>
|
5484
|
+
4<Color::HSL#to_cmyk>
|
5485
|
+
Converts to RGB and then YIQ and CMYK, respectively.
|
5486
|
+
|
5487
|
+
4<Color::HSL#brightness>
|
5488
|
+
Returns the luminosity (#l) of the colour.
|
5489
|
+
|
5490
|
+
4<Color::HSL#to_greyscale>
|
5491
|
+
4<Color::HSL#to_grayscale>
|
5492
|
+
Converts the HSL colour to Color::GrayScale.
|
5493
|
+
|
5494
|
+
4<Color::HSL#h, Color::HSL#h=>
|
5495
|
+
4<Color::HSL#s, Color::HSL#s=>
|
5496
|
+
4<Color::HSL#l, Color::HSL#l=>
|
5497
|
+
Read and set the independent components of the HSL colour. The colour values
|
5498
|
+
will be in the range (0..1).
|
5499
|
+
|
5500
|
+
3<Color::YIQ>
|
5501
|
+
A colour object representing YIQ (NTSC) colour encoding.
|
5502
|
+
|
5503
|
+
4<Color::YIQ.from_fraction(y = 0.0, i = 0.0, q = 0.0)>
|
5504
|
+
Creates a YIQ colour object from fractional values (0..1).
|
5505
|
+
.code {{{
|
5506
|
+
Color::YIQ.new(0.3, 0.2, 0.1)
|
5507
|
+
.endcode }}}
|
5508
|
+
|
5509
|
+
4<Color::YIQ.new(y = 0, i = 0, q = 0)>
|
5510
|
+
Creates a YIQ colour object from percentages (0..100).
|
5511
|
+
.code {{{
|
5512
|
+
Color::YIQ.new(10, 20, 30)
|
5513
|
+
.endcode }}}
|
5514
|
+
|
5515
|
+
4<Color::YIQ#==(other)>
|
5516
|
+
Compares the other colour to this one. The other colour will be converted to
|
5517
|
+
YIQ before comparison, so the comparison between a YIQ colour and a non-YIQ
|
5518
|
+
colour will be approximate and based on the other colour�s #to_yiq
|
5519
|
+
conversion. If there is no #to_yiq conversion, this will raise an exception.
|
5520
|
+
This will report that two YIQ values are equivalent if all component colours
|
5521
|
+
are within 1e-4 (0.0001) of each other.
|
5522
|
+
|
5523
|
+
4<Color::YIQ#to_yiq>
|
5524
|
+
Returns the current YIQ colour.
|
5525
|
+
|
5526
|
+
4<Color::YIQ#brightness>
|
5527
|
+
Returns the brightness (#y) of the current colour.
|
5528
|
+
|
5529
|
+
4<Color::YIQ#to_grayscale>
|
5530
|
+
4<Color::YIQ#to_greyscale>
|
5531
|
+
Converts the current YIQ colour to Color::GrayScale based on the #y version.
|
5532
|
+
|
5533
|
+
4<Color::YIQ#y, Color::YIQ#y=>
|
5534
|
+
4<Color::YIQ#i, Color::YIQ#i=>
|
5535
|
+
4<Coqor::YIQ#q, Coqor::YIQ#q=>
|
5536
|
+
Read and set the independent components of the HSL colour. The colour values
|
5537
|
+
will be in the range (0..1).
|
5538
|
+
|
5539
|
+
3<Color::CSS>
|
5540
|
+
This namespace contains some CSS colour names.
|
5541
|
+
|
5542
|
+
4<Color::CSS[name]>
|
5543
|
+
Returns the RGB colour for name or +nil+ if the name is not valid. This is
|
5544
|
+
based on the constants from the Color::RGB namespace.
|
5545
|
+
|
5546
|
+
Future versions of this will be extended to recognise other valid CSS colour
|
5547
|
+
specifications, including <b>hsl()</b>, <b>hsv()</b>, and <b>rgb()</b>.
|
5231
5548
|
|
5232
5549
|
3<Color::Palette::MonoContrast>
|
5233
5550
|
Generates a monochromatic constrasting colour palette for background and
|
@@ -5265,15 +5582,18 @@ values.
|
|
5265
5582
|
.endblist }}}
|
5266
5583
|
|
5267
5584
|
4<Color::Palette::MonoContrast#minimum_brightness_diff>
|
5268
|
-
|
5269
|
-
|
5270
|
-
|
5271
|
-
The default value for this is
|
5585
|
+
4<Color::Palette::MonoContrast#minimum_brightness_diff=>
|
5586
|
+
The minimum brightness difference between the background and the foreground,
|
5587
|
+
and must be between (0..1). Setting this value will regenerate the palette
|
5588
|
+
based on the base colours. The default value for this is 125 / 255.0. If this
|
5589
|
+
value is set to <b>nil</b>, it will be restored to the default.
|
5272
5590
|
|
5273
5591
|
4<Color::Palette::MonoContrast#minimum_color_diff>
|
5274
|
-
|
5275
|
-
|
5276
|
-
|
5592
|
+
4<Color::Palette::MonoContrast#minimum_color_diff=>
|
5593
|
+
The minimum colour difference between the background and the foreground, and
|
5594
|
+
must be between 0..3. Setting this value will regenerate the palette based on
|
5595
|
+
the base colours. The default value for this is about 1.96 (500 / 255). If
|
5596
|
+
this value is set to <b>nil</b>, it will be restored to the default.
|
5277
5597
|
|
5278
5598
|
4<Color::Palette::MonoContrast#regenerate(background, foreground = nil)
|
5279
5599
|
Regenerates the palette based on new background and foreground values. If
|
@@ -5298,28 +5618,50 @@ contrast</c:alink> suggest that this value be at least approximately 0.49
|
|
5298
5618
|
Returns the contrast between to colours, a decimal value between 0 and 3.
|
5299
5619
|
Accessibility guidelines from the W3C for <c:alink
|
5300
5620
|
uri="http://www.w3.org/TR/AERT#color-contrast">colour contrast</c:alink>
|
5301
|
-
suggest that this value be at least approximately 1.96 (500 /
|
5621
|
+
suggest that this value be at least approximately 1.96 (500 / 255.0) for
|
5302
5622
|
proper contrast.
|
5303
5623
|
|
5304
|
-
3<Color::Palette::
|
5305
|
-
|
5306
|
-
|
5307
|
-
|
5624
|
+
3<Color::Palette::Gimp>
|
5625
|
+
A class that can read a Gimp (GNU Image Manipulation Program) palette file
|
5626
|
+
and provide a Hash-like interface to the contents. Gimp colour palettes are
|
5627
|
+
RGB values only.
|
5628
|
+
|
5629
|
+
Because two or more entries in a Gimp palette may have the same name, all
|
5630
|
+
named entries are returned as an array.
|
5631
|
+
|
5632
|
+
.code {{{
|
5633
|
+
pal = Color::Palette::Gimp.from_file(my_gimp_palette)
|
5634
|
+
pal[0] => Color::RGB<...>
|
5635
|
+
pal["white"] => [ Color::RGB<...> ]
|
5636
|
+
pal["unknown"] => [ Color::RGB<...>, Color::RGB<...>, ... ]
|
5637
|
+
.endcode }}}
|
5638
|
+
|
5639
|
+
Gimp Palettes are always indexable by insertion order (an integer key).
|
5308
5640
|
|
5309
|
-
4<Color::Palette::
|
5310
|
-
Iterates through the data of the
|
5641
|
+
4<Color::Palette::Gimp.new(palette)>
|
5642
|
+
Iterates through the data of the Gimp palette and interprets it.
|
5311
5643
|
|
5312
|
-
4<Color::Palette::
|
5644
|
+
4<Color::Palette::Gimp.from_file(filename)>
|
5313
5645
|
Reads the palette data from the filename.
|
5314
5646
|
|
5315
|
-
4<Color::Palette::
|
5647
|
+
4<Color::Palette::Gimp.from_io(io)>
|
5316
5648
|
Reads the palette data from the IO or IO-like object (depends on #read).
|
5317
5649
|
|
5318
|
-
4<Color::Palette::
|
5319
|
-
Access the colours by name.
|
5650
|
+
4<Color::Palette::Gimp#[](key)>
|
5651
|
+
Access the colours by name or numeric index.
|
5320
5652
|
|
5321
|
-
4<Color::Palette::
|
5322
|
-
Loops through the palette�s colours.
|
5653
|
+
4<Color::Palette::Gimp#each>
|
5654
|
+
Loops through the palette�s colours, yielding each colour in turn.
|
5655
|
+
|
5656
|
+
4<Color::Palette::Gimp#each_name>
|
5657
|
+
Loops through the named colours, yielding the colour name and an Array of
|
5658
|
+
colours.
|
5659
|
+
|
5660
|
+
4<Color::Palette::Gimp#valid?>
|
5661
|
+
Returns true if this is believed to be a valid GIMP palette.
|
5662
|
+
|
5663
|
+
4<Color::Palette::Gimp#name>
|
5664
|
+
Returns the name of the GIMP palette.
|
5323
5665
|
.newpage
|
5324
5666
|
1<PDF::Writer Demos>
|
5325
5667
|
|
@@ -5391,6 +5733,17 @@ Unicode support
|
|
5391
5733
|
.newpage
|
5392
5734
|
1<Revision History>
|
5393
5735
|
|
5736
|
+
2<PDF::Writer 1.1.2: August 25, 2005>
|
5737
|
+
.blist {{{
|
5738
|
+
Thomas Gantner <thomas.gantner@gmx.net> found a problem with the interpretation of the placement of page numbers and provided a patch. Thanks!
|
5739
|
+
Thomas also reported a problem with an inability to place page numbering on the first page of a document, as well as strange results from not providing a starting page number. This has been fixed. Also reported as #2204.
|
5740
|
+
Modified PDF::Writer requirements to require color-tools version 1.3.0 or later. This necessitates that Color constants be changed to Color::RGB constants.
|
5741
|
+
Updated supporting library documentation to include information on color-tools version 1.3.
|
5742
|
+
Fixed a bug with Graphics#transform_matrix truncating one of the transform parameters.
|
5743
|
+
Applied a fix to PDF::SimpleTable submitted by Mike Leddy in #2129 on the RubyForge tracker.
|
5744
|
+
Applied a partial fix for PNG with index-transparency provided by Marc Vleugels in #2245 on the RubyForge tracker. NOTE: This does not solve the transparency problem; at this point, PDF::Writer cannot be said to support PNGs with transparency. This will be fixed in a later version of PDF::Writer.
|
5745
|
+
.endblist }}}
|
5746
|
+
|
5394
5747
|
2<Version 1.1.1: July 1, 2005>
|
5395
5748
|
.blist {{{
|
5396
5749
|
Fixed the packaging process; the .tar.gz files will no longer corrupt the images.
|
@@ -5602,6 +5955,6 @@ pdf.stop_page_numbering(true, :current)
|
|
5602
5955
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
5603
5956
|
# for full licensing information.
|
5604
5957
|
#
|
5605
|
-
# $Id: manual.pwd,v 1.51 2005/
|
5958
|
+
# $Id: manual.pwd,v 1.51.2.2 2005/08/25 03:43:59 austin Exp $
|
5606
5959
|
# vim: sts=2 sw=2 ts=4 et ai tw=77 foldmethod=marker foldcolumn=2
|
5607
5960
|
#++
|