Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 KB | None | 0 0
  1. //////////////////////////////////////////////////////////// english //
  2. // -------------------------------
  3. // -=> WR-reversePathDirection <=-
  4. // -------------------------------
  5. //
  6. // A Javascript for Adobe Illustrator
  7. // by Wolfgang Reszel (ai-js@rumborak.de)
  8. //
  9. // Version 0.2 from 1.12.2004
  10. //
  11. // This script reverses the path-direction of all selected paths.
  12. //
  13. // To enable the english messages change the "de" into "en" in line 40.
  14. //
  15. // Sorry for my bad english. For any corrections send an email to:
  16. // ai-js@rumborak.de
  17. //
  18. //////////////////////////////////////////////////////////// Deutsch //
  19. // -------------------------------
  20. // -=> WR-reversePathDirection <=-
  21. // -------------------------------
  22. //
  23. // Ein Javascript fuer Adobe Illustrator
  24. // von Wolfgang Reszel (ai-js@rumborak.de)
  25. //
  26. // Version 0.2 vom 1.12.2004
  27. //
  28. // Dieses Skript kehrt die Pfadrichtung aller markierten Pfadobjekte um.
  29. //
  30. // Um dieses Skript mit deutschen Meldungen zu versehen, muss in Zeile
  31. // 40 das "en" durch ein "de" ersetzt werden.
  32. //
  33. // Verbesserungsvorschlaege an: ai-js@rumborak.de
  34. //
  35.  
  36. //$.bp();
  37.  
  38. // -------------------------------------------------------------------
  39.  
  40. var language="en"; // "de" fuer Deutsch
  41.  
  42. // -------------------------------------------------------------------
  43.  
  44. var WR="WR-reversePathDirection v0.2\n\n";
  45.  
  46. if (language == "de") {
  47.  
  48. var MSG_noobjects = WR+"Bitte w\xE4hle vorher einige Objekte aus.";
  49. var MSG_nodocs = WR+"Kein Dokument ge\xF6ffnet.";
  50.  
  51. } else {
  52.  
  53. var MSG_noobjects = WR+"Please select some objects.";
  54. var MSG_nodocs = WR+"You have no open document."
  55.  
  56. }
  57.  
  58. var error=0;
  59.  
  60. if (documents.length<1) {
  61. error++;
  62. alert(MSG_nodocs);
  63. }
  64. if (error == 0) {
  65. var theObjects=selection;
  66.  
  67. if (theObjects.length<1 && error == 0) {
  68. error++;
  69. alert(MSG_noobjects);
  70. }
  71. }
  72. if (error < 1) {
  73. reversePaths(theObjects);
  74. }
  75.  
  76. function reversePaths(theItems) {
  77. if (theItems.typename == "TextPath") {
  78. pathLen = theItems.pathPoints.length;
  79.  
  80. for ( k = 0; k < pathLen/2; k++ ) {
  81. h = pathLen-k-1;
  82.  
  83. HintenAnchor = theItems.pathPoints[h].anchor;
  84. HintenLeft = theItems.pathPoints[h].leftDirection;
  85. HintenType = theItems.pathPoints[h].pointType;
  86. HintenRight = theItems.pathPoints[h].rightDirection;
  87.  
  88. theItems.pathPoints[h].anchor = theItems.pathPoints[k].anchor;
  89. theItems.pathPoints[h].leftDirection = theItems.pathPoints[k].rightDirection;
  90. theItems.pathPoints[h].pointType = theItems.pathPoints[k].pointType;
  91. theItems.pathPoints[h].rightDirection = theItems.pathPoints[k].leftDirection;
  92. theItems.pathPoints[k].anchor = HintenAnchor;
  93. theItems.pathPoints[k].leftDirection = HintenRight;
  94. theItems.pathPoints[k].pointType = HintenType;
  95. theItems.pathPoints[k].rightDirection = HintenLeft;
  96.  
  97. }
  98. }
  99.  
  100. for (var i = 0 ; i < theItems.length; i++)
  101. {
  102. if (theItems[i].typename == "GroupItem" || theItems[i].typename == "CompoundPathItem" ) {
  103. reversePaths(theItems[i].pathItems);
  104. try {reversePaths(theItems[i].compoundPathItems)} catch (e) {};
  105. }
  106. if (theItems[i].typename == "TextFrame" ) {reversePaths(theItems[i].textPath);}
  107. if (theItems[i].typename == "TextArtItem" ) {reversePaths(theItems[i].textPaths);}
  108. if ( theItems[i].typename == "PathItem" && !theItems[i].locked && !theItems[i].parent.locked && !theItems[i].layer.locked ) {
  109.  
  110. pathLen = theItems[i].pathPoints.length;
  111.  
  112. for ( k = 0; k < pathLen/2; k++ ) {
  113. h = pathLen-k-1;
  114.  
  115. HintenAnchor = theItems[i].pathPoints[h].anchor;
  116. HintenLeft = theItems[i].pathPoints[h].leftDirection;
  117. HintenType = theItems[i].pathPoints[h].pointType;
  118. HintenRight = theItems[i].pathPoints[h].rightDirection;
  119.  
  120. theItems[i].pathPoints[h].anchor = theItems[i].pathPoints[k].anchor;
  121. theItems[i].pathPoints[h].leftDirection = theItems[i].pathPoints[k].rightDirection;
  122. theItems[i].pathPoints[h].pointType = theItems[i].pathPoints[k].pointType;
  123. theItems[i].pathPoints[h].rightDirection = theItems[i].pathPoints[k].leftDirection;
  124. theItems[i].pathPoints[k].anchor = HintenAnchor;
  125. theItems[i].pathPoints[k].leftDirection = HintenRight;
  126. theItems[i].pathPoints[k].pointType = HintenType;
  127. theItems[i].pathPoints[k].rightDirection = HintenLeft;
  128. }
  129. }
  130. if ( theItems[i].typename == "TextPath" && !theItems[i].locked && !theItems[i].parent.locked && !theItems[i].parent.layer.locked ) {
  131.  
  132. pathLen = theItems[i].textPathObject.pathPoints.length;
  133.  
  134. for ( k = 0; k < pathLen/2; k++ ) {
  135. h = pathLen-k-1;
  136.  
  137. HintenAnchor = theItems[i].textPathObject.pathPoints[h].anchor;
  138. HintenLeft = theItems[i].textPathObject.pathPoints[h].leftDirection;
  139. HintenType = theItems[i].textPathObject.pathPoints[h].pointType;
  140. HintenRight = theItems[i].textPathObject.pathPoints[h].rightDirection;
  141.  
  142. theItems[i].textPathObject.pathPoints[h].anchor = theItems[i].textPathObject.pathPoints[k].anchor;
  143. theItems[i].textPathObject.pathPoints[h].leftDirection = theItems[i].textPathObject.pathPoints[k].rightDirection;
  144. theItems[i].textPathObject.pathPoints[h].pointType = theItems[i].textPathObject.pathPoints[k].pointType;
  145. theItems[i].textPathObject.pathPoints[h].rightDirection = theItems[i].textPathObject.pathPoints[k].leftDirection;
  146. theItems[i].textPathObject.pathPoints[k].anchor = HintenAnchor;
  147. theItems[i].textPathObject.pathPoints[k].leftDirection = HintenRight;
  148. theItems[i].textPathObject.pathPoints[k].pointType = HintenType;
  149. theItems[i].textPathObject.pathPoints[k].rightDirection = HintenLeft;
  150. }
  151. }
  152. }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement