home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Graphics / PerfectPaint / rexx / line / Funny_Line.rx < prev    next >
Text File  |  1999-12-10  |  4KB  |  284 lines

  1. /*Line Crenel
  2.     It's just an adaptation from some TVPaint macros
  3. */
  4.  
  5.     options results
  6.   parse ARG Port x1 y1 x2 y2 b
  7.  
  8.  
  9.     ADDRESS COMMAND
  10.     type=0
  11.     if EXISTS('PerfectPaint:Prefs/Rexx_Prefs/Funny_Line') THEN DO
  12.         IF OPEN('lfile','PerfectPaint:Prefs/Rexx_Prefs/Funny_Line', "R") then DO
  13.             type = READLN('lfile')
  14.             CALL CLOSE('lfile')
  15.         END
  16.     END
  17.  
  18.   ADDRESS value Port
  19.     pp_DialogInit 250 60 "*Funny*Line*" 1
  20.         pp_Cycle 0 100 8 100 16 "Type" 1 "Crenel|Cut|Jagged|Shaky" type
  21.     pp_Dialog
  22.     rc=result
  23.     if rc=0 then
  24.         do
  25.             EXIT
  26.         end        
  27.  
  28.     pp_GetDialog 0
  29.     type=result
  30.  
  31.     CALL SavePrefs('Funny_Line',type)
  32.     ADDRESS value Port    
  33.  
  34.     pp_updateUndo
  35.  
  36. if type=0 then DO
  37.     pp_STARTpoly
  38.     l=20;w=5;x=x1;y=y1;iy=1;dy=y2-y1
  39.     if (dy<0) then
  40.     do
  41.         dy=-dy;iy=-1
  42.     end
  43.     ix=1;dx=x2-x1
  44.     if (dx<0) then
  45.     do
  46.         dx=-dx;ix=-1
  47.     end
  48.     xb=x;yb=y;xa=x;ya=y;c=1
  49.     if (dx>dy) then
  50.     do
  51.         d=dx
  52.         do while (x~==x2)
  53.             x=x+ix;d=d-dy
  54.             if (d<0) then
  55.             do
  56.                 y=y+iy;d=d+dx
  57.             end
  58.             if((x%l)*l == x) then
  59.             do
  60.                 if (c==1) then
  61.                 do    
  62.                     pp_Addpoly xb yb-w;pp_ADDpoly x y-w;pp_ADDpoly x y-w
  63.                     c=0
  64.                 end
  65.                 else
  66.                 do
  67.                     pp_ADDpoly xb yb+w;pp_ADDpoly x y+w;pp_ADDpoly x y-w
  68.                     c=1
  69.                 end
  70.                 xb=x;yb=y
  71.             end
  72.         end
  73.     end
  74.     else
  75.     do
  76.         d=dy
  77.         do while (y ~==y2)
  78.             y=y+iy;d=d-dx
  79.             if (d<0) then
  80.             do
  81.                 x=x+ix;d=d+dy
  82.             end
  83.             if((y%l)*l == y) then
  84.             do
  85.                 if (c==1) then
  86.                 do
  87.                     pp_ADDpoly xb-w yb;pp_ADDpoly x-w y;pp_ADDpoly x+w y
  88.                     c=0
  89.                 end
  90.                 else
  91.                 do
  92.                     pp_ADDpoly xb+w yb;pp_ADDpoly x+w y;pp_ADDpoly x-w y
  93.                     c=1
  94.                 end
  95.                 xb=x;yb=y
  96.             end
  97.         end
  98.     end
  99.     pp_ENDpoly
  100. END
  101.  
  102. if type=1 then DO
  103.     l=20;x=x1;y=y1;iy=1;dy=y2-y1
  104.     if (dy<0) then
  105.     do
  106.         dy=-dy;iy=-1
  107.     end
  108.     ix=1;dx=x2-x1
  109.     if (dx<0) then
  110.     do
  111.         dx=-dx;ix=-1
  112.     end
  113.     xb=x;yb=y;xa=x;ya=y;c=1
  114.     if (dx>dy) then
  115.     do
  116.         d=dx
  117.         do while (x~==x2)
  118.             x=x+ix;d=d-dy
  119.             if (d<0) then
  120.             do
  121.                 y=y+iy;d=d+dx
  122.             end
  123.             if((x%l)*l == x) then
  124.             do
  125.                 if (c==1) then
  126.                 do
  127.                     pp_line xb yb x y;c=0
  128.                 end
  129.                 else c=1
  130.                 xb=x;yb=y
  131.             end
  132.         end
  133.     end
  134.     else
  135.     do
  136.         d=dy
  137.         do while (y ~==y2)
  138.             y=y+iy;d=d-dx
  139.             if (d<0) then
  140.             do
  141.                 x=x+ix;d=d+dy
  142.             end
  143.             if((y%l)*l == y) then
  144.             do
  145.                 if (c==1) then
  146.                 do
  147.                     pp_line xb yb x y;c=0
  148.                 end
  149.                 else c=1
  150.                 xb=x;yb=y
  151.             end
  152.         end
  153.     end
  154. END
  155.  
  156. if type=2 then DO
  157.     l=10;w=5;x=x1;y=y1;iy=1;dy=y2-y1
  158.     if (dy<0) then
  159.     do
  160.         dy=-dy;iy=-1
  161.     end
  162.     ix=1;dx=x2-x1
  163.     if (dx<0) then
  164.     do
  165.         dx=-dx;ix=-1
  166.     end
  167.     xb=x;yb=y;xa=x;ya=y;c=1
  168.     if (dx>dy) then
  169.     do
  170.         d=dx
  171.         do while (x~==x2)
  172.             x=x+ix;d=d-dy
  173.             if (d<0) then
  174.             do
  175.                 y=y+iy;d=d+dx
  176.             end
  177.             if((x%l)*l == x) then
  178.             do
  179.                 if (c==1) then
  180.                 do
  181.                     pp_line xb yb+w x y-w;c=0
  182.                 end
  183.                 else
  184.                 do
  185.                     pp_line xb yb-w x y+w;c=1
  186.                 end
  187.                 xb=x;yb=y
  188.             end
  189.         end
  190.     end
  191.     else
  192.     do
  193.         d=dy
  194.         do while (y ~==y2)
  195.             y=y+iy;d=d-dx
  196.             if (d<0) then
  197.             do
  198.                 x=x+ix;d=d+dy
  199.             end
  200.             if((y%l)*l == y) then
  201.             do
  202.                 if (c==1) then
  203.                 do
  204.                     pp_line xb+w yb x-w y;c=0
  205.                 end
  206.                 else
  207.                 do
  208.                     pp_line xb-w yb x+w y;c=1
  209.                 end
  210.                 xb=x;yb=y
  211.             end
  212.         end
  213.     end
  214. END
  215.  
  216. if type=3 then DO
  217.     w=5;l=5;x=x1;y=y1;iy=1;dy=y2-y1
  218.     if (dy<0) then
  219.     do
  220.         dy=-dy;iy=-1
  221.     end
  222.     ix=1;dx=x2-x1
  223.     if (dx<0) then
  224.     do
  225.         dx=-dx;ix=-1
  226.     end
  227.     xb=x;yb=y;xa=x;ya=y
  228.     if (dx>dy) then
  229.     do
  230.         d=dx
  231.         do while (x~==x2)
  232.             x=x+ix;d=d-dy
  233.             if (d<0) then
  234.             do
  235.                 y=y+iy;d=d+dx
  236.             end
  237.             if((x%l)*l == x) then
  238.             do
  239.                 xa=x+random(0,w,time('S'));ya=y+random(0,w,time('S'))
  240.                 pp_line xb yb xa ya;xb=xa;yb=ya
  241.             end
  242.         end
  243.     end
  244.     else
  245.     do
  246.         d=dy
  247.         do while (y ~==y2)
  248.             y=y+iy;d=d-dx
  249.             if (d<0) then
  250.             do
  251.                 x=x+ix;d=d+dy
  252.             end
  253.             if((y%l)*l == y) then
  254.             do
  255.                 xa=x+random(0,w);ya=y+random(0,w)
  256.                 pp_line xa ya xb yb;xb=xa;yb=ya
  257.             end
  258.         end
  259.     end
  260. END
  261.  
  262. EXIT
  263.  
  264.  
  265. SavePrefs: PROCEDURE
  266.     
  267.     Prefname='PerfectPaint:Prefs/Rexx_Prefs/'||ARG(1)
  268.  
  269.     if EXISTS(Prefname) THEN DO
  270.         ADDRESS COMMAND
  271.         'delete >nil: '||Prefname
  272.     END
  273.  
  274.     IF OPEN('pfile',PrefName,'W') THEN DO
  275.  
  276.     do i=2 to ARG()
  277.         CALL WRITELN('pfile',ARG(i))
  278.     end
  279.  
  280.     CALL CLOSE('pfile')
  281.  
  282. RETURN
  283.  
  284.