home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d925 / donsgenies.lha / DonsGenies / FrenchGenies.lha / Rexx / CopierEtR駱騁erDeLuxe.pprx < prev    next >
Text File  |  1993-08-03  |  14KB  |  372 lines

  1. /*
  2. @BCopierEtRépéterDeLuxe @P@I Ecrit et © par Don Cox en juillet 92
  3. @IN'est pas du Domaine Publique. Tous Droits Réservés.
  4. Traduit par Fabien Larini le 27/07/93.
  5.  
  6. Ce Génie fait des copies multiples d'un boîte en utilisant le décalage et
  7. l'angle de rotation indiqués par l'utilisateur. Vous pouvez aussi 
  8. appliquer un facteur d'échelle pour les copies ainsi que le centre de 
  9. rotation.
  10. */
  11.  
  12. /*
  13. StepAndRepeatDeLuxe
  14. This Genie will make multiple copies of a box with user specified offset and rotation between copies. You can also scale the copies and set the centre of rotation.
  15. Written by Don Cox   July 92.
  16. */
  17.  
  18.  
  19. if ~show(l, "gdarexxsupport.library") then
  20.    if ~addlib("gdarexxsupport.library", 0, -30) then
  21.       exit_msg("Installez gdarexxsupport.library dans votre répertoire Libs: avant d'utiliser ce Genie !")
  22.   
  23.  
  24. cr = '0a'x
  25. address command
  26. call SafeEndEdit.rexx()
  27. units = ppm_GetUnits()
  28. if units = 3 then call ppm_SetUnits(2)
  29.  
  30. signal on halt
  31. signal on break_c
  32. signal on break_e
  33. signal on break_d
  34.  
  35. cu = "in"
  36. if units = 2 then cu = "cm"
  37.  
  38. call ppm_AutoUpdate(0)
  39.  
  40. call ppm_NewGroup()
  41. box = ppm_ClickOnBox("Clickez Dans la Boîte à Copier")
  42. if box = 0 then exit_msg("Pas de Boîte Sélectionnée")
  43. call ppm_AddToGroup(box)  /* whole set grouped including original box */
  44. dup = 0
  45.  
  46. trace n
  47.  
  48. source = ppm_Inform(3,"Données ...","Identiques","Par Défaut","Fichier")
  49.  
  50. oldangle = ppm_GetBoxAngle(box)
  51. call ppm_SetBoxAngle(box,0)   /* rotate to zero to get centre */
  52. boxpos  = ppm_GetBoxPosition(box)
  53. curX   = word(boxpos, 1 )
  54. curY   = word(boxpos, 2 )
  55.  
  56. boxsize = ppm_GetBoxSize(box)
  57. width   = word(boxsize, 1 )
  58. height  = word(boxsize, 2 )
  59.  
  60. centreX = curX+(width/2)
  61. centreY = curY+(height/2)
  62. call ppm_SetBoxAngle(box,oldangle)
  63. boxpos  = ppm_GetBoxPosition(box)
  64.  
  65. ImageScaleX = word(ppm_GetBoxScale(box),1)
  66. ImageScaleY = word(ppm_GetBoxScale(box),2)
  67.  
  68. call ppm_ShowStatus("Position: "curX", "curY" Taille: L"width", H"height)
  69.  
  70. formstring = ""
  71.  
  72. if source = 0 then do
  73.     if open("temp","ram:SRD.data","R") then do
  74.         formstring = readch("temp",512)
  75.         call close("temp")
  76.         end
  77.     if formstring = "" then source = 1  /* defaults if failed  */
  78.     end   /* source = 0  */
  79.  
  80. if source = 2 then do
  81.     loadfile = ppm_GetFileName("Charge les Données sur Disque","ram:","")
  82.     if loadfile = "" then break
  83.     if open("loader",loadfile,"R") then do
  84.         formstring = readch("loader",512)
  85.         call close("loader")
  86.         end
  87.     if formstring = "" then source = 1  /* go for defaults  */
  88.     end
  89.  
  90. /*if formstring = "" then formstring ="rows:2"||cr"columns:1"||cr"horiz. spacing ("cu"):"width||cr"vertical spacing ("cu"):"height||cr"horiz. offset ("cu"):"0||cr"offset angle:"0||cr"rotation angle:"0||cr"rotation centre, X:"centreX||cr"rotation centre, Y:"centreY||cr"scale, X:1.00"||cr"scale, Y:1.00"||cr"spiral scale:1.00"||cr"spiral spacing("cu"):0"||cr"save settings (Y/N):N"||cr"Link boxes (Y/N):N"*/
  91. if formstring = "" then formstring ="Lignes:2"||cr"Colonnes:1"||cr"Espact Horiz. ("cu"):"width||cr"Espact Vertical ("cu"):"height||cr"Décalage Horiz. ("cu"):"0||cr"Décalage Angulaire:"0||cr"Angle de Rotation:"0||cr"Centre Rotation, X:"centreX||cr"Centre Rotation, Y:"centreY||cr"Echelle, X:1.00"||cr"Echelle, Y:1.00"||cr"Echelle de Spirale:1.00"||cr"Incr. Spirale("cu"):0"||cr"Sauve Données (O/N):N"||cr"Chaîne Boîtes (O/N):N"
  92.  
  93.  
  94. form = ppm_GetForm("Copie & Répète DeLuxe", 12, formstring)
  95. if form = '' then exit_msg("Annulé par l'Utilisateur")
  96.  
  97. parse var form rows '0a'x columns '0a'x  horizontal '0a'x vertical '0a'x HorizOffset '0a'x OffsetAngle '0a'x RotAngle '0a'x Xcentre '0a'x Ycentre '0a'x Xscale '0a'x Yscale '0a'x SpiralScale '0a'x SpiralIncrement '0a'x Saving '0a'x Linking
  98.  
  99.  
  100. if rows = '' then rows = 1
  101. if columns = '' then columns = 1
  102. if horizontal = '' then horizontal = 0
  103. if vertical = '' then vertical = 0
  104. if HorizOffset = "" then HorizOffset = 0
  105. if OffsetAngle = "" then OffsetAngle = 0
  106. if RotAngle = '' then RotAngle = 0
  107. if Xcentre = "" then Xcentre = centreX
  108. if Ycentre = "" then Ycentre = centreY
  109. if Xscale = "" then Xscale = 1
  110. if Yscale = "" then Yscale = 1
  111. if SpiralScale = "" then SpiralScale = 1
  112. if SpiralIncrement = "" then SpiralIncrement = 0
  113.  
  114. if ~(datatype(rows, n)) then exit_msg("Saisie Invalide pour le Nombre de Lignes : "rows)
  115. if ~(datatype(columns, n)) then exit_msg("Saisie Invalide pour le Nombre de Colonnes : "columns)
  116. if ~(datatype(horizontal, n)) then exit_msg("Saisie Invalide pour l'Espacement Horiz. : "horizontal)
  117. if ~(datatype(HorizOffset, n)) then exit_msg("Saisie Invalide pour le Décalage Horiz. : "HorizOffset)
  118. if ~(datatype(vertical, n)) then exit_msg("Saisie Invalide pour l'Espacement Vertical : "vertical)
  119. if ~(datatype(OffsetAngle, n)) then exit_msg("Saisie Invalide pour le Décalage Angulaire: "OffsetAngle)
  120. if ~(datatype(RotAngle, n)) then exit_msg("Saisie Invalide pour l'Angle de Rotation : "RotAngle)
  121. if ~(datatype(Xcentre, n)) then exit_msg("Saisie Invalide pour l'Abscisse du Centre de Rotation : "Xcentre)
  122. if ~(datatype(Ycentre, n)) then exit_msg("Saisie Invalide pour l'Ordonnée du Centre de Rotation : "Ycentre)
  123. if ~(datatype(Xscale, n)) then exit_msg("Saisie Invalide pour l'Echelle X : "Xscale)
  124. if ~(datatype(Yscale, n)) then exit_msg("Saisie Invalide pour l'Echelle Y : "Yscale)
  125. if ~(datatype(SpiralScale, n)) then exit_msg("Saisie Invalide pour l'Echelle de Spirale : "SpiralScale)
  126. if ~(datatype(SpiralIncrement, n)) then exit_msg("Saise Invalide pour l'Incrément de Spirale : "SpiralIncrement)
  127.  
  128. formstring ="Lignes:"rows||"0a"x"Colonnes:"columns||"0a"x"Espact Horiz. ("cu"):"horizontal||"0a"x"Espact Vertical ("cu"):"vertical||"0a"x"Décalage Horiz. ("cu"):"HorizOffset||"0a"x"Décalage Angulaire:"OffsetAngle||"0a"x"Angle de Rotation:"RotAngle||"0a"x"Centre Rotation, X:"Xcentre||"0a"x"Centre Rotation, Y:"Ycentre||"0a"x"Echelle, X:"Xscale||"0a"x"Echelle, Y:"Yscale||"0a"x"Echelle de Spirale:"SpiralScale||"0a"x"Inc. Spirale ("cu"):"SpiralIncrement||"0a"x"Sauve Données (O/N):"upper(Saving)||"0a"x"Chaîne Boîtes (O/N):"upper(Linking)"0a"x
  129.  
  130. if open("temp","ram:SRD.data","W") then do
  131.     call seek("temp",0,"B") 
  132.     call writech("temp",formstring)
  133.     call close("temp")
  134.     end
  135.  
  136. if upper(Saving) = "O" then do
  137.     savefile = ppm_GetFileName("Sauve les Données","ram:","")
  138.     if savefile = "" then break
  139.     if open("saver",savefile,"W") then do
  140.         call writech("saver",formstring)
  141.         call close("saver")
  142.         end
  143.     end
  144.  
  145. if RotAngle ~=0 then SpiralIncrement = SpiralIncrement/(360/RotAngle) /* get value for each unit  */
  146.  
  147.  
  148. AroundCentre = 0
  149. if centreX ~= Xcentre | centreY ~= Ycentre then AroundCentre = 1
  150. rotationangle = oldangle
  151. HorizShift = 0   /* sideways shift for offset angle */
  152. if OffsetAngle ~= 0 then do  /* use horiz. spacing and offset angle */
  153.     Oangle=OffsetAngle*3.1415926/180  /* convert to radians  */
  154.     vertical = horizontal*sin(Oangle)
  155.     HorizShift = horizontal*cos(Oangle)
  156.     end
  157. ScaledWidth = width
  158. ScaledHeight = height
  159. ScaledImageX = ImageScaleX
  160. ScaledImageY = ImageScaleY
  161. scaling = 0
  162. if Xscale~=1 | Yscale~=1 then scaling = 1    /* set scaling flag  */
  163.  
  164. boxes.1.1 = box
  165.  
  166.  
  167. /* For single rows or lines of units */
  168. if rows = 1 | columns = 1 then do
  169.     call ppm_ShowStatus("Travail en cours sur une colonne/ligne")
  170.     do i = 2 to max(rows,columns)
  171.         k=i-1
  172.         box = boxes.1.k
  173.         
  174.         /* to avoid a bug in CloneBox we have to clone first and then set the position  */
  175.         boxX=word(ppm_GetBoxPosition(box),1)
  176.         boxY=word(ppm_GetBoxPosition(box),2)
  177.         boxX=boxX+HorizShift+HorizOffset+horizontal
  178.         boxY=boxY+vertical
  179.         newbox = ppm_CloneBox(box, 0,0)
  180.         call ppm_AddToGroup(newbox)
  181.         call ppm_SetBoxPosition(newbox,boxX,boxY)
  182.         
  183.         boxes.1.i = newbox
  184.         if rotangle ~= 0 then do
  185.             newangle = (rotationangle + rotangle)//360
  186.             call ppm_SetBoxAngle(newbox, newangle)
  187.             rotationangle = newangle
  188.             end
  189.  
  190.         if  AroundCentre = 1 then do
  191.             adjustment = newbox "0a"x Xcentre "0a"x Ycentre "0a"x rotangle "0a"x SpiralScale "0a"x SpiralIncrement
  192.             call rotator(adjustment)
  193.             end
  194.  
  195.         if upper(linking)="O" then linked = ppm_LinkBox(box,newbox)
  196.  
  197.         if scaling = 1 then do
  198.             ScaledWidth = ScaledWidth*abs(Xscale)
  199.             ScaledHeight = ScaledHeight*abs(Yscale)
  200.             ScaledImageX = ScaledImageX*Xscale
  201.             ScaledImageY = ScaledImageY*Yscale
  202.             call ppm_SetBoxSize(newbox,ScaledWidth,ScaledHeight)
  203.             call ppm_SetBoxScale(newbox,ScaledImageX,ScaledImageY)
  204.             vertical = vertical * abs(Yscale)
  205.             horizontal = horizontal * abs(Xscale)
  206.             end
  207.  
  208.         end   /* of column */
  209. end /* rows or columns = 1  */
  210.  
  211.  
  212. else do   /* for multiple columns  */
  213.  
  214. /* make first column */
  215. call ppm_ShowStatus("Travail en Cours sur la Colonne 1")
  216.     do i = 2 to rows
  217.         k=i-1
  218.         box = boxes.1.k
  219.                 
  220.         /* to avoid a bug in CloneBox we have to clone first and then set the position  */
  221.         boxX=word(ppm_GetBoxPosition(box),1)
  222.         boxY=word(ppm_GetBoxPosition(box),2)
  223.         boxX=boxX+HorizShift+HorizOffset
  224.         boxY=boxY+vertical
  225.         newbox = ppm_CloneBox(box, 0,0)
  226.         call ppm_AddToGroup(newbox)
  227.         call ppm_SetBoxPosition(newbox,boxX,boxY)
  228.         
  229.         boxes.1.i = newbox
  230.         if rotangle ~= 0 then do
  231.             newangle = (rotationangle + rotangle)//360
  232.             call ppm_SetBoxAngle(newbox, newangle)
  233.             rotationangle = newangle
  234.             end
  235.  
  236.         if  AroundCentre = 1 then do
  237.             adjustment = newbox "0a"x Xcentre "0a"x Ycentre "0a"x rotangle "0a"x SpiralScale "0a"x SpiralIncrement
  238.             call rotator(adjustment)
  239.             end
  240.  
  241.         if upper(linking)="O" then linked = ppm_LinkBox(box,newbox)
  242.  
  243.         if scaling = 1 then do
  244.             ScaledImageY = ScaledImageY*Yscale
  245.             ScaledHeight = ScaledHeight*abs(Yscale)
  246.             call ppm_SetBoxSize(newbox,width,ScaledHeight)
  247.             call ppm_SetBoxScale(newbox,ImageScaleX,ScaledImageY)
  248.             vertical = vertical * abs(Yscale)
  249.             end
  250.  
  251.     end   /* of first column */
  252.  
  253.  
  254.     vertical = height
  255.     box = boxes.1.1
  256.     rotationangle = oldangle
  257.  
  258.     do j = 2 to columns
  259.        call ppm_ShowStatus("Travail en Cours sur la Colonne "j) 
  260.        k = j-1
  261.  
  262.         rotationangle = ppm_GetBoxAngle(boxes.k.1)
  263.         do i = 1 to rows
  264.             box = boxes.k.i
  265.                     
  266.             /* to avoid a bug in CloneBox we have to clone first and then set the position  */
  267.             boxX=word(ppm_GetBoxPosition(box),1)
  268.             boxY=word(ppm_GetBoxPosition(box),2)
  269.             boxX=boxX+Horizontal
  270.             newbox = ppm_CloneBox(box, 0,0)
  271.             call ppm_AddToGroup(newbox)
  272.             call ppm_SetBoxPosition(newbox,boxX,boxY)
  273.             
  274.             boxes.j.i = newbox
  275.             if rotangle ~= 0 then do
  276.                 newangle = (rotationangle + rotangle)//360
  277.                 call ppm_SetBoxAngle(newbox, newangle)
  278.                 rotationangle = newangle
  279.                 end
  280.  
  281.         if  AroundCentre = 1 then do
  282.             adjustment = newbox "0a"x Xcentre "0a"x Ycentre "0a"x rotangle "0a"x SpiralScale "0a"x SpiralIncrement
  283.             call rotator(adjustment)
  284.             end
  285.  
  286.         if upper(linking)="O" then linked = ppm_LinkBox(box,newbox)
  287.  
  288.         if scaling = 1 then do
  289.             ScaledWidth = word(ppm_GetBoxSize(box),1) * abs(Xscale)
  290.             ScaledHeight = word(ppm_GetBoxSize(box),2)
  291.             ScaledImageX = word(ppm_GetBoxScale(box),1) *Xscale
  292.             ScaledImageY = word(ppm_GetBoxScale(box),2)
  293.             call ppm_SetBoxSize(newbox,ScaledWidth,ScaledHeight)
  294.             call ppm_SetBoxScale(newbox,ScaledImageX,ScaledImageY)
  295.             vertical = vertical * abs(Yscale)
  296.             ScaledImageY = ScaledImageY * Yscale
  297.             end
  298.  
  299.         end   /* rows */
  300.         
  301.         if scaling = 1 then do 
  302.             horizontal = horizontal* abs(Xscale)
  303.             vertical = height
  304.             ScaledImageX = ScaledImageX*Xscale
  305.             ScaledImageY = ImageScaleY
  306.             end
  307.     end   /* columns */
  308.  
  309. end  /* multiple columns  */
  310.  
  311. exit_msg()
  312. end
  313.  
  314.  
  315. /* Rotate box around a centre */
  316.  
  317. rotator: procedure
  318.  
  319. parse arg box '0a'x Xcentre '0a'x Ycentre '0a'x angle '0a'x SpiralScale '0a'x SpiralIncrement
  320. startangle = ppm_GetBoxAngle(box)
  321. call ppm_SetBoxAngle(box,0)
  322. boxpos = ppm_GetBoxPosition(box)
  323. boxleft = word(boxpos,1)
  324. boxtop = word(boxpos,2)
  325. boxsize = ppm_GetBoxSize(box)
  326. boxwidth = word(boxsize,1)
  327. boxheight = word(boxsize,2)
  328. boxcentreX = boxleft+(boxwidth/2)
  329. boxcentreY = boxtop+(boxheight/2)
  330.  
  331. rangle=angle*3.1415926/180  /* convert to radians  */
  332. cosa = cos(rangle)
  333. sina = sin(rangle)
  334. Xoffset = boxcentreX-Xcentre
  335. Yoffset = boxcentreY-Ycentre
  336. newX = (Xoffset*cosa)+(Yoffset*sina)
  337. newY = (Yoffset*cosa)-(Xoffset*sina)
  338.  
  339. if SpiralIncrement ~= 0 then do   /* using Pythagoras to split increment of radius into x & y  */
  340.     incX = (SpiralIncrement * newX) / (sqrt((newX*newX) + (newY*newY)))
  341.     incY = (SpiralIncrement * newY) / (sqrt((newX*newX) + (newY*newY)))
  342.     newX = NewX + incX
  343.     newY = newY + incY
  344.     end
  345.  
  346. x = Xcentre+newX
  347. y = Ycentre+newY
  348. x = x * SpiralScale
  349. y = y * SpiralScale
  350. call ppm_SetBoxPosition(box,x-(boxwidth/2),y-(boxheight/2))
  351. call ppm_SetBoxAngle(box,startangle)
  352.  
  353. return
  354.  
  355.  
  356. break_d:
  357. break_e:
  358. break_c:
  359. halt:
  360.     call exit_msg("L'Utilisateur a arrêté le Génie !")
  361.  
  362. exit_msg: procedure  expose units
  363. do
  364.     parse arg message
  365.  
  366.     if message ~= '' then call ppm_Inform(1, message,)
  367.     call ppm_ClearStatus()
  368.     call ppm_SetUnits(units)
  369.     call ppm_AutoUpdate(1)
  370.     exit
  371. end
  372.