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

  1. head     1.8;
  2. branch   ;
  3. access   ;
  4. symbols  beta10:1.7;
  5. locks    death:1.8;
  6. comment  @# @;
  7.  
  8.  
  9. 1.8
  10. date     93.04.04.23.31.09;  author death;  state Exp;
  11. branches ;
  12. next     1.7;
  13.  
  14. 1.7
  15. date     93.01.09.21.07.41;  author death;  state Exp;
  16. branches ;
  17. next     1.6;
  18.  
  19. 1.6
  20. date     93.01.01.11.51.47;  author death;  state Exp;
  21. branches ;
  22. next     1.5;
  23.  
  24. 1.5
  25. date     92.12.31.15.35.32;  author death;  state Exp;
  26. branches ;
  27. next     1.4;
  28.  
  29. 1.4
  30. date     92.12.05.23.07.41;  author death;  state Exp;
  31. branches ;
  32. next     1.3;
  33.  
  34. 1.3
  35. date     92.12.03.18.02.14;  author death;  state Exp;
  36. branches ;
  37. next     1.2;
  38.  
  39. 1.2
  40. date     92.11.27.19.38.20;  author death;  state Exp;
  41. branches ;
  42. next     1.1;
  43.  
  44. 1.1
  45. date     92.11.08.09.29.03;  author death;  state Exp;
  46. branches ;
  47. next     ;
  48.  
  49.  
  50. desc
  51. @@
  52.  
  53.  
  54. 1.8
  55. log
  56. @Sun Apr  4 23:31:09 PDT 1993
  57. @
  58. text
  59. @%BEGIN Rectangles
  60.  
  61. %%%%%%%%%%%%%
  62. %    Name:    rectpath
  63. %    Syntax:    t l b r rectpath -
  64. %    About:    Given the bounds of the rectangle, build a path describing the outside
  65. %            edge of the rectangle.
  66. %            Note: defines new values for last* values in the process
  67. %%%%%%%%%%%%%
  68. /rectpath
  69. {
  70.     /lastright exch def
  71.     /lastbottom exch def
  72.     /lastleft exch def
  73.     /lasttop exch def
  74.  
  75.     newpath
  76.         lastleft lasttop moveto
  77.         lastright lasttop lineto
  78.         lastright lastbottom lineto
  79.         lastleft lastbottom lineto
  80.     closepath
  81. }
  82. def
  83.  
  84. %%%%%%%%%%%%%
  85. %    Name:    frameRect            [0030]
  86. %    Syntax:    t l b r frameRect -
  87. %    About:    Given the bounds of the rectangle, build a pair of paths, one forming the
  88. %            outside edge of the framed rectagle, and one the inside.  Fill between then.
  89. %            Note: defines new values for last* values in the process
  90. %%%%%%%%%%%%%
  91. /frameRect
  92. {
  93.     /lastright exch  def
  94.     /lastbottom exch  def
  95.     /lastleft exch def
  96.     /lasttop exch def
  97.     %
  98.     %    only do this if the pen sizes are > 0
  99.     %
  100.     penWidth 0 gt
  101.     penHeight 0 gt
  102.     and
  103.     {
  104.         gsave
  105.             penPattern usePattern
  106.             newpath
  107.                 lastleft lasttop moveto
  108.                 lastright lasttop lineto
  109.                 lastright  lastbottom  lineto
  110.                 lastleft lastbottom lineto
  111.             closepath
  112.                 lastleft penWidth add    lasttop penHeight add   moveto
  113.                 lastleft penWidth add   lastbottom penHeight sub   lineto
  114.                 lastright penWidth sub   lastbottom penHeight sub   lineto
  115.                 lastright penWidth sub   lasttop penHeight add   lineto
  116.             closepath
  117.             fill
  118.         grestore
  119.     }
  120.     if
  121. }
  122. def
  123.  
  124. %%%%%%%%%%%%%
  125. %    Name:    paintRect            [0031]
  126. %    Syntax:    t l b r paintRect -
  127. %    About:    Paints the rectangle formed by the bounds we are passed.
  128. %%%%%%%%%%%%%
  129. /paintRect
  130. {
  131.     gsave
  132.         penPattern usePattern
  133.         rectpath
  134.         fill
  135.     grestore
  136. } def
  137.  
  138. %%%%%%%%%%%%%
  139. %    Name:    invertRect            [0032]
  140. %    Syntax:    t l b r invertRect -
  141. %    About:    Erases the rectangle formed by the bounds we are passed.
  142. %            Note: erasing always means filling with the background pattern
  143. %%%%%%%%%%%%%
  144. /eraseRect
  145. {
  146.     gsave
  147.         backPattern usePattern
  148.         rectpath
  149.         fill
  150.     grestore
  151. }
  152. def
  153.  
  154. %%%%%%%%%%%%%
  155. %    Name:    invertRect            [0033]
  156. %    Syntax:    t l b r invertRect -
  157. %    About:    Call rectpath to properly consume arguments, but do nothing since
  158. %            we don't know how to invert in PS.
  159. %%%%%%%%%%%%%
  160. /invertRect
  161. {
  162.     gsave
  163.         rectpath
  164.     grestore
  165. }
  166. def
  167.  
  168. %%%%%%%%%%%%%
  169. %    Name:    fillRect                [0034]
  170. %    Syntax:    t l b r fillRect -
  171. %    About:    Fills the path formed by the rectangle bounds we are passed
  172. %%%%%%%%%%%%%
  173. /fillRect
  174. {
  175.     gsave
  176.         fillPattern usePattern
  177.         rectpath
  178.         fill
  179.     grestore
  180. }
  181. def
  182.  
  183. %%%%%%%%%%%%%
  184. %    Name:    frameSameRect        [0038]
  185. %    Syntax:    - frameSameRect -
  186. %    About:    Frames the last rectangle used
  187. %%%%%%%%%%%%%
  188. /frameSameRect
  189.     { lasttop lastleft lastbottom lastright frameRect }
  190. def
  191.  
  192. %%%%%%%%%%%%%
  193. %    Name:    paintSameRect        [0039]
  194. %    Syntax:    - paintSameRect -
  195. %    About:    paints the last rectangle used
  196. %%%%%%%%%%%%%
  197. /paintSameRect
  198.     { lasttop lastleft lastbottom lastright paintRect }
  199. def
  200.  
  201. %%%%%%%%%%%%%
  202. %    Name:    eraseSameRect        [003A]
  203. %    Syntax:    - eraseSameRect -
  204. %    About:    Erases the last rectangle used
  205. %%%%%%%%%%%%%
  206. /eraseSameRect
  207.     { lasttop lastleft lastbottom lastright eraseRect }
  208. def
  209.  
  210. %%%%%%%%%%%%%
  211. %    Name:    invertSameRect        [003B]
  212. %    Syntax:    - invertSameRect -
  213. %    About:    Inverts the last rectangle used
  214. %%%%%%%%%%%%%
  215. /invertSameRect
  216.     { lasttop lastleft lastbottom lastright invertRect }
  217. def
  218.  
  219. %%%%%%%%%%%%%
  220. %    Name:    fillSameRect            [003C]
  221. %    Syntax:    - fillSameRect -
  222. %    About:    Fills the last rectangle used
  223. %%%%%%%%%%%%%
  224. /fillSameRect
  225.     { lasttop lastleft lastbottom lastright fillRect }
  226. def
  227.  
  228. %END Rectangles
  229. @
  230.  
  231.  
  232. 1.7
  233. log
  234. @Sat Jan  9 21:07:41 PST 1993
  235. @
  236. text
  237. @@
  238.  
  239.  
  240. 1.6
  241. log
  242. @Fri Jan  1 11:51:47 PST 1993
  243. @
  244. text
  245. @@
  246.  
  247.  
  248. 1.5
  249. log
  250. @Thu Dec 31 15:35:32 PST 1992
  251. @
  252. text
  253. @@
  254.  
  255.  
  256. 1.4
  257. log
  258. @Sat Dec  5 23:07:40 PST 1992
  259. @
  260. text
  261. @d3 2
  262. a4 2
  263. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  264. %    utility: rectpath
  265. d6 4
  266. a9 13
  267. %    Description:
  268. %        takes a rectangle (top left bottom right) and makes it the
  269. %        current path, while also defining the global last rect
  270. %        values in the process.  Note that we add one to the bottom and
  271. %        right coordinates when building the path.  This is because the
  272. %        rectangle that the Mac QuickDraw draws for these coordinates ends up
  273. %        being a little bit wider and taller than a PS filled rect.  We don't
  274. %        alter the last___ variables, however, since they later get passed
  275. %        back here sometimes, and this would lead to increassing them too much.
  276. %    Weirdnesses:
  277. %        We use the lastrect globals for local variable use here...
  278. %    Bugs:
  279. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  280. d19 3
  281. a21 3
  282.         lastright 1 add lasttop lineto
  283.         lastright 1 add lastbottom 1 add lineto
  284.         lastleft lastbottom 1 add lineto
  285. d23 2
  286. a24 1
  287. } def
  288. d26 7
  289. a32 19
  290.  
  291.  
  292. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  293. %    Opcode:    0030
  294. %    Name:    frameRect
  295. %    Syntax:    t l b r frameRect - 
  296. %    Description:
  297. %        Given a quintuple of coordinates, this builds a framed rectangle taking
  298. %        into account the current penWidth and penHeight.  NOTE that we special
  299. %        case for a penwidth of 1 and height of 1 to get best drawing results in what's
  300. %        probably the most common case.
  301. %    Weirdnesses:
  302. %        We use the lastrect globals for local variable use here...
  303. %    Bugs:
  304. %        If the penwidth is larger than the width of the rect (or the height the height), I
  305. %        imagine that this does not draw the same thing that the Mac does.
  306. %    Modificatons:
  307. %        Removed 1 add after right and bottom in outer rect of frame.  Dunny wy they there.
  308. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  309. d39 3
  310. a41 1
  311.  
  312. d53 7
  313. a59 19
  314.                 lastleft lasttop lineto
  315.                 
  316.                 penWidth 1 ne
  317.                 penHeight 1 ne
  318.                 or
  319.                 {
  320.                     lastleft penWidth add    lasttop penHeight add   moveto
  321.                     lastleft penWidth add   lastbottom penHeight sub   lineto
  322.                     lastright penWidth sub   lastbottom penHeight sub   lineto
  323.                     lastright penWidth sub   lasttop penHeight add   lineto
  324.                     lastleft penWidth add   lasttop penHeight add   lineto
  325.                     closepath
  326.                     fill
  327.                 }
  328.                 {
  329.                     closepath
  330.                     stroke
  331.                 }
  332.                 ifelse
  333. d63 2
  334. a64 1
  335. } def
  336. d66 5
  337. a70 10
  338.  
  339. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  340. %    Opcode:    0031
  341. %    Name:    paintRect
  342. %    Syntax:    t l b r paintRect - 
  343. %    Description:
  344. %        Takes a rectangle (x y width height) and paints its area on
  345. %        screen.  Because it uses rectpath, this ends up storing the bounds too.
  346. %    Bugs:
  347. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  348. d80 6
  349. a85 12
  350.  
  351. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  352. %    Opcode:    0032
  353. %    Name:    eraseRect
  354. %    Syntax:    t l b r eraseRect - 
  355. %    Description:
  356. %        Takes a rectangle (x y width height) and erases its area on
  357. %        screen.  Erasing merely involves painting with the current
  358. %        background color.  Because it uses rectpath, this ends up
  359. %        storing the bounds too.
  360. %    Bugs:
  361. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  362. d93 2
  363. a94 1
  364. } def
  365. d96 6
  366. a101 11
  367.  
  368. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  369. %    Opcode:    0033
  370. %    Name:    invertRect
  371. %    Syntax:    t l b r invertRect - 
  372. %    Description:
  373. %        As far as I can tell, no one uses this for anything.  Build the path
  374. %        in order to get the side effect of string the 'last rectangle'
  375. %        in case we need it.
  376. %    Bugs:
  377. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  378. d107 2
  379. a108 1
  380. } def
  381. d110 5
  382. a114 10
  383.  
  384. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  385. %    Opcode:    0034
  386. %    Name:    fillRect
  387. %    Syntax:    t l b r fillRect - 
  388. %    Description:
  389. %        This takes a rectangle, and fills it with the current fill pattern.
  390. %        This also stores the bounds, by way of rectpath, for any future use.
  391. %    Bugs:
  392. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  393. d122 2
  394. a123 1
  395. } def
  396. d125 5
  397. a129 10
  398.  
  399. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  400. %    Opcode:    0038
  401. %    Name:    frameSameRect
  402. %    Syntax:    -  frameSameRect - 
  403. %    Description:
  404. %        Using the bounds of the last rectangle manipulated, call
  405. %        framerect to frame a rectangle there.
  406. %    Bugs:
  407. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  408. d134 5
  409. a138 10
  410.  
  411. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  412. %    Opcode:    0039
  413. %    Name:    paintSameRect
  414. %    Syntax:    -  paintSameRect - 
  415. %    Description:
  416. %        Using the bounds of the last rectangle manipulated, call
  417. %        paintrect to paint a rectangle there.
  418. %    Bugs:
  419. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  420. d143 5
  421. a147 9
  422.  
  423. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  424. %    Opcode:    003A
  425. %    Name:    eraseSameRect
  426. %    Syntax:    -  eraseSameRect - 
  427. %    Description:
  428. %        I'll let you guess what this does.
  429. %    Bugs:
  430. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  431. d152 5
  432. a156 10
  433.  
  434. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  435. %    Opcode:    003B
  436. %    Name:    invertSameRect
  437. %    Syntax:    -  invertSameRect - 
  438. %    Description:
  439. %        This calls invertRect with the bounds of the last rect used.
  440. %        If invertrect is ever made to actually do something, this will too.
  441. %    Bugs:
  442. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  443. d161 5
  444. a165 9
  445.  
  446. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  447. %    Opcode:    003C
  448. %    Name:    fillSameRect
  449. %    Syntax:    -  fillSameRect - 
  450. %    Description:
  451. %        What a surprise!  This fills the last rectangle used!
  452. %    Bugs:
  453. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  454. a168 1
  455.  
  456. @
  457.  
  458.  
  459. 1.3
  460. log
  461. @Thu Dec  3 18:02:13 PST 1992
  462. @
  463. text
  464. @d65 1
  465. @
  466.  
  467.  
  468. 1.2
  469. log
  470. @Fri Nov 27 19:38:20 PST 1992
  471. @
  472. text
  473. @@
  474.  
  475.  
  476. 1.1
  477. log
  478. @Sun Nov  8 09:29:03 PST 1992
  479. @
  480. text
  481. @d50 2
  482. d67 3
  483. a69 3
  484.                 lastright 1 add lasttop lineto
  485.                 lastright 1 add lastbottom 1 add lineto
  486.                 lastleft lastbottom 1 add lineto
  487. @
  488.