Colour pinstripe/Printer

From Rosetta Code
Revision as of 19:37, 14 July 2011 by rosettacode>Markhobley ({{omit from|GUISS}})
Task
Colour pinstripe/Printer
You are encouraged to solve this task according to the task description, using any language you may know.

The task is to create 1 point wide colour vertical pinstripes with a sufficient number of pinstripes to span the entire width of the colour graphics printer. The pinstripes should alternate between each individual cartridge ink and ink pair and black and white pinstripes should be included. A typical pinstripe sequence woud be black, red, green, blue, magenta,cyan, yellow, white.

After the first inch of printing, we switch to a wider 2 pixel wide vertical pinstripe pattern. and to 3 point wide vertical for the next inch, and then 4 point wide, etc. This trend continues for the entire length of the page (or for 12 inches of run length in the case of a printer using continuous roll stationery). After printing the test pattern the page is ejected (or the test pattern is rolled clear of the printer enclosure, in the case of continuous roll printers).

Note that it is an acceptable solution to use the smallest marks that the language provides, rather than working at native printer resolution, where this is not achievable from within the language.

Optionally, on systems where the printer resolution cannot be determined, it is permissible to prompt the user for printer resolution, and to calculate point size based on user input, enabling fractional point sizes to be used.

PicoLisp

<lang PicoLisp>(load "@lib/ps.l")

  1. Using circular lists for an endless supply of colors
  2. (black red green blue magenta cyan yellow white)

(setq

  Red   (0    100    0     0    100    0    100   100 .)
  Green (0     0    100    0     0    100   100   100 .)
  Blue  (0     0     0    100   100   100    0    100 .) )

(call 'lpr

  (pdf "pinstripes"
     (a4)  # 595 x 842 dots
     (let (I 0  Step 1)
        (for X 595
           (color (car Red) (car Green) (car Blue)
              (vline X 0 842) )
           (when (= Step (inc 'I))
              (zero I)
              (pop 'Red)
              (pop 'Green)
              (pop 'Blue) )
           (when (=0 (% X 72))  # 1 inch
              (zero I)
              (inc 'Step) ) ) )
     (page) ) )</lang>