home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_PICT / Source / CommentedPSCode / RCS / Patterns,v < prev    next >
Encoding:
Text File  |  1995-06-12  |  3.6 KB  |  209 lines

  1. head     1.4;
  2. branch   ;
  3. access   ;
  4. symbols  beta10:1.3;
  5. locks    death:1.4;
  6. comment  @# @;
  7.  
  8.  
  9. 1.4
  10. date     93.04.04.23.30.54;  author death;  state Exp;
  11. branches ;
  12. next     1.3;
  13.  
  14. 1.3
  15. date     93.01.09.21.07.34;  author death;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     93.01.01.11.51.40;  author death;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     92.12.31.15.35.08;  author death;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 1.4
  35. log
  36. @Sun Apr  4 23:30:54 PDT 1993
  37. @
  38. text
  39. @%BEGIN Patterns
  40.  
  41. %%%%%%%%%%%%%
  42. %    Notes:
  43. %        qdpat is an 8 byte hex string, like <AA55AA55AA55AA55>
  44. %        clut-info is a hex string of RGB byte triples for color lookup
  45. %        pict2pat is either of:
  46. %            qdpat [r g b] 2
  47. %            qdpat num clut-info bitdepth left top width height
  48. %                destwidth destheight packedflag bitmap-string 1
  49. %        See the common routine usePattern for how much of this is used
  50. %%%%%%%%%%%%%
  51.  
  52.  
  53. %%%%%%%%%%%%%
  54. %    Name:    GetPatGrey
  55. %    Syntax:    qdpat GetPatGrey  num
  56. %    About:    Given a hex string representing 8 bytes of data, assume it is a
  57. %            quickdraw B&W pattern. Calculate what percentage of the pixels
  58. %            are black, and return the % grey
  59. %%%%%%%%%%%%%
  60. /GetPatGrey
  61. {
  62.     /QDpattern exch def
  63.     /darkness 0 def
  64.     %
  65.     %     for each byte of pattern, convert to value between 0 and 1 and sum
  66.     %    This is not completely accurate, but works well enough (it counts #'s, not bits)
  67.     %
  68.     0 1 7
  69.     {
  70.         /patByte exch def
  71.         /darkness
  72.             QDpattern patByte get
  73.             255 div darkness add
  74.         def
  75.     }
  76.     for
  77.     %
  78.     %    Compute the average shade and push
  79.     %
  80.     darkness 8 div
  81. }
  82. def
  83.  
  84. %%%%%%%%%%%%%
  85. %    Name:    FillQDPatDict
  86. %    Syntax:    qdpat 0 FillQDPatDict -
  87. %            pict2pat FillQDPatDict -
  88. %    About:    Store pattern info we are passed.  This assumes an appropriate
  89. %            dictionary has been opened and is on the stack.
  90. %%%%%%%%%%%%%
  91. /FillQDPatDict
  92. {
  93.     begin
  94.         /QDPatType exch def
  95.         QDPatType 0 eq
  96.         {
  97.             /QDPatData exch def
  98.             /QDPatGrey QDPatData GetPatGrey def
  99.         }
  100.         {
  101.             QDPatType 2 eq
  102.             {
  103.                 /QDColorValue exch def
  104.                 pop % B&W pattern not needed. color will suffice.
  105.             }
  106.             {
  107.                 /QDPatBitmap exch def
  108.                 /QDisPacked exch def
  109.                 /QDDestHeight exch def
  110.                 /QDDestWidth exch def
  111.                 /Height exch def
  112.                 /Width exch def
  113.                 /QDTop exch def
  114.                 /QDLeft exch def
  115.                 /BitsPerComponent exch def
  116.                 /QDColorTable exch def
  117.                 /QDNumColors exch def
  118.                 /QDPatData exch def
  119.                 /QDPatGrey QDPatData GetPatGrey def
  120.             }
  121.             ifelse
  122.         }
  123.         ifelse
  124.     end
  125. }
  126. def
  127.  
  128. %%%%%%%%%%%%%
  129. %    Name:    bkPat        [0002]
  130. %    Syntax:    qdpat 0 bkPat -
  131. %    About:    Stores the pattern info in the backPattern dict.
  132. %%%%%%%%%%%%%
  133. /bkPat
  134.     {backPattern FillQDPatDict}
  135. def
  136.  
  137. %%%%%%%%%%%%%
  138. %    Name:    pnPat        [0009]
  139. %    Syntax:    qdpat 0 pnPat -
  140. %    About:    Stores the pattern info in the penPattern dict.
  141. %%%%%%%%%%%%%
  142. /pnPat
  143.     {penPattern FillQDPatDict}
  144. def
  145.  
  146. %%%%%%%%%%%%%
  147. %    Name:    fillPat        [000A]
  148. %    Syntax:    qdpat 0 fillPat -
  149. %    About:    Stores the pattern info in the fillPattern dict.
  150. %%%%%%%%%%%%%
  151. /fillPat
  152.     {fillPattern FillQDPatDict}
  153. def
  154.  
  155. %%%%%%%%%%%%%
  156. %    Name:    bkPixPat    [0012]
  157. %    Syntax:    pict2pat bkPixPat -
  158. %    About:    Stores the pattern info in the backPattern dict.
  159. %%%%%%%%%%%%%
  160. /bkPixPat
  161.     {backPattern FillQDPatDict}
  162. def
  163.  
  164. %%%%%%%%%%%%%
  165. %    Name:    pnPixPat    [0013]
  166. %    Syntax:    pict2pat pnPixPat -
  167. %    About:    Stores the pattern info in the penPattern dict.
  168. %%%%%%%%%%%%%
  169. /pnPixPat
  170.     {penPattern FillQDPatDict}
  171. def
  172.  
  173. %%%%%%%%%%%%%
  174. %    Name:    fillPixPat    [0014]
  175. %    Syntax:    pict2pat fillPixPat -
  176. %    About:    Stores the pattern info in the fillPattern dict.
  177. %%%%%%%%%%%%%
  178. /fillPixPat
  179.     {fillPattern FillQDPatDict}
  180. def
  181.  
  182. %END Patterns
  183. @
  184.  
  185.  
  186. 1.3
  187. log
  188. @Sat Jan  9 21:07:33 PST 1993
  189. @
  190. text
  191. @@
  192.  
  193.  
  194. 1.2
  195. log
  196. @Fri Jan  1 11:51:40 PST 1993
  197. @
  198. text
  199. @d28 1
  200. @
  201.  
  202.  
  203. 1.1
  204. log
  205. @Thu Dec 31 15:35:07 PST 1992
  206. @
  207. text
  208. @@
  209.