home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Raytracing / Raytracer / LW5VT09.LHA / Toaster / Arexx_examples / PlugIns / CreateArcText.lwm < prev    next >
Encoding:
Text File  |  1996-06-10  |  10.1 KB  |  310 lines

  1. /* CMD: ½CreateArcText                                                  */
  2. /* By Brett Evan Hester      13032 Copenhill Rd. Dallas, Tx. 75240-5302 */
  3.     MacrosName = "CreateArcText"
  4. /* Macro Type:                                                          */
  5. /* CREATES     * TEXT      * LAYER NEEDED * REMEMBERS                   */
  6. /* Description:                                                         */
  7.  
  8. Info1A = "!Create Arc Text ©             Information 1 of 2"
  9. Info1B = ""
  10. Info1C = "@This macro creates an object out of text in the "
  11. Info1D = "@shape of an arc, curve, or circle.              "
  12. Info1E = ""
  13. Info1F = "UPPER ARC bends text on the TopSide of a circle."
  14. Info1G = "LOWER ARC bends text on the BtmSide of a circle."
  15. Info1H = "WRAP AROUND bends text around the equater of a  "
  16. Info1I = "globe.                                          "
  17. Info1J = ""
  18. Info1K = "RADIUS refers to the inner edge of the circle,  "
  19. Info1L = "where the text is closest to the center.        "
  20. Info1M = ""
  21. Info1N = "LOAD FONT will display a file req. to add a font"
  22.  
  23. Info2A = "!Create Arc Text ©             Information 2 of 2"
  24. Info2B = "@               Plug-Ins and Go! ©               "
  25. Info2C = "                           Hester and associates"
  26. Info2D = "                           13032 Copenhill Road "
  27. Info2E = "                           Dallas, Texas 75240  "
  28. Info2F = "@Special Thanks to:                              "
  29. Info2G = "Arnie Cachelin  Henry Ribron    Mark J. Holland "
  30. Info2H = "J. Phil Kelso   Terry Wester    Steven K. Simms "
  31. Info2I = "Kevin DeRita    Greg Glaser     William S. Hawes"
  32. Info2J = "NewTek ©        Commodore ©     INOVAtronics ©  "
  33. Info2K = ""
  34. Info2L = "@This macro represents a lot of time & hard work."
  35. Info2M = "@Encourage people to create new ones and not kill"
  36. Info2N = "@that possibility by stealing those that are out."
  37.  
  38. /* -------------------------------------------------------------------- */
  39.                                      /* Start Error Detection (See End) */
  40. SIGNAL ON ERROR
  41. SIGNAL ON SYNTAX
  42.                                                    /* Address LightWave */
  43. VT3DLib = ADDLIB("LWModelerARexx.port",0)
  44. ADDRESS "LWModelerARexx.port"
  45.                                                   /* Add Math Functions */
  46. MATHLIB="rexxmathlib.library"
  47. IF POS(MATHLIB , SHOW('L')) = 0 THEN
  48.     IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
  49.         CALL Notify(1,"!Can't find "MATHLIB)
  50.         EXIT
  51.     END
  52.  
  53. /* -------------------------------------------------------------------- */
  54.                                                    /* Empty Layer Setup */
  55. Empty = EmptyLayers()
  56. IF (WORDS(Empty) < 2) THEN DO
  57.     CALL Notify(1,"!Sorry!","@This macro needs two empty layers.")
  58.     CALL Exiting
  59. END
  60. MainLayer = WORD(Empty, 1)
  61. WorkLayer = WORD(Empty, 2)
  62.  
  63. /* -------------------------------------------------------------------- */
  64.                                              /* Setting Fixed Variables */
  65. PI = 3.141592653589793238462643
  66. RadToDeg = 180 / PI ; DegToRad = PI / 180
  67.  
  68. /* -------------------------------------------------------------------- */
  69.                                     /* Reading Global Macro Preferences */
  70. BEHDefaultFilePath = "Sys:"
  71. BEHSettingsSavedTo = "T:"
  72. BEHSpeechAndSound = "1"
  73.  
  74. IF (EXISTS("S:PlugInPrefs")) THEN DO
  75.     IF (~OPEN(PlugInPrefs, "S:PlugInPrefs", 'R')) THEN BREAK
  76.     IF (READLN(PlugInPrefs) ~= "PlugInPrefs") THEN BREAK
  77.     BEHDefaultFilePath = READLN(PlugInPrefs)
  78.     BEHSettingsSavedTo = READLN(PlugInPrefs)
  79.     BEHSpeechAndSound = READLN(PlugInPrefs)
  80.     CALL CLOSE PlugInPrefs
  81. END
  82. /* -------------------------------------------------------------------- */
  83.                                             /* Recalling Macro Settings */
  84. ReqStyle = "1"
  85. ReqText = "Welcome"
  86. ReqFont = "0"
  87. ReqRadius = "5"
  88. FilePath = "/ToasterFonts"
  89.  
  90. PrefsFileName = BEHSettingsSavedTo||MacrosName||".PLUG"
  91.  
  92. IF (EXISTS(PrefsFileName)) THEN DO
  93.     IF (~OPEN(PrefsFile, PrefsFileName, 'R')) THEN BREAK
  94.     IF (READLN(PrefsFile) ~= MacrosName) THEN BREAK
  95.  
  96.     ReqStyle = READLN(PrefsFile)
  97.     ReqText = READLN(PrefsFile)
  98.     ReqFont = READLN(PrefsFile)
  99.     ReqRadius = READLN(PrefsFile)
  100.     FilePath = READLN(PrefsFile)
  101.     FileName = READLN(PrefsFile)
  102.  
  103.     CALL CLOSE PrefsFile
  104. END
  105.  
  106. /* ******************************************************************** */
  107.                                                    /* Main Body Of Code */
  108. OKtoContinueA = 0
  109. DO UNTIL OKtoContinueA = 1
  110.     OKtoContinueA = 1
  111.     OKtoContinueB = 0
  112.     DO UNTIL OKtoContinueB = 1
  113.         OKtoContinueB = 1
  114.         CALL MenuRequester
  115.         IF BEHInfo = 1 THEN CALL LoadingFont
  116.         IF BEHInfo = 2 THEN CALL InformationWindows
  117.     END
  118.     CALL VerifyInput
  119. END
  120. CALL CreationStage
  121. CALL SaveSettings
  122. CALL Exiting
  123.  
  124. /* ******************************************************************** */
  125.                                                       /* User Interface */
  126. MenuRequester:
  127.  
  128.     CALL Req_Begin("Create Arc Text ©    by Brett Hester")
  129.  
  130.     ReqA = Req_AddControl("Style",'CH', "UpperArc LowerArc WrapAround")
  131.     ReqB = Req_AddControl("Text:",'S',"32")
  132.     ReqC = Req_AddControl("Font",'F')
  133.     ReqD = Req_AddControl("Radius",'N',1)
  134.     CALL Req_AddControl("",'T', "")
  135.     ReqE = Req_AddControl("",'CH', " Load Font  Information")
  136.  
  137.     CALL Req_SetVal(ReqA, ReqStyle)
  138.     CALL Req_SetVal(ReqB, ReqText)
  139.     CALL Req_SetVal(ReqC, ReqFont)
  140.     CALL Req_SetVal(ReqD, ReqRadius)
  141.     CALL Req_SetVal(ReqE, 0)
  142.  
  143.     IF Req_Post() = 0 THEN CALL Exiting
  144.  
  145.     ReqStyle = Req_GetVal(ReqA)
  146.     ReqText = Req_GetVal(ReqB)
  147.     ReqFont = Req_GetVal(ReqC)
  148.     ReqRadius = ABS(Req_GetVal(ReqD))
  149.     BEHInfo = Req_GetVal(ReqE)
  150.  
  151.     IF ReqRadius < 1 THEN ReqRadius = 1
  152.  
  153.     CALL Req_End()
  154.  
  155. RETURN
  156.  
  157. /* -------------------------------------------------------------------- */
  158.                                                         /* Loading Font */
  159. LoadingFont:
  160.  
  161.     FileReq = GetFileName("--- Load Font ---", FilePath, FileName)
  162.     IF FileReq ~= "(none)" THEN DO
  163.                         /* Extracting File Name and Path from Requester */
  164.         FileReqLength = LENGTH(FileReq)
  165.         FileDivider = LASTPOS("/",FileReq)
  166.         IF FileDivider = 0 THEN FileDivider = LASTPOS(":",FileReq)
  167.         FileNameLength = FileReqLength - FileDivider
  168.  
  169.         FilePath = STRIP(LEFT(FileReq, FileDivider),"T","/")
  170.         FileName = RIGHT(FileReq, FileNameLength)
  171.  
  172.         ReqFont = FontLoad(FileReq)
  173.         IF ReqFont = 0 THEN CALL Notify(1,"!Sorry!,",'@Cannot load font "'FileReq'"')
  174.     END
  175.     OKtoContinueB = 0
  176.  
  177. RETURN
  178.  
  179. /* -------------------------------------------------------------------- */
  180.                                                         /* Verify Input */
  181. VerifyInput:
  182.  
  183.     IF ReqText = "" THEN DO
  184.         CALL Notify(1,"!Text must be provided!")
  185.         OKtoContinueA = 0
  186.     END
  187.     IF ReqFont = 0 THEN DO
  188.         CALL Notify(1,"!A font must be loaded!")
  189.         OKtoContinueA = 0
  190.     END
  191.  
  192. RETURN
  193.  
  194. /* -------------------------------------------------------------------- */
  195.                                                       /* Creation Stage */
  196. CreationStage:
  197.  
  198.     Total = 0
  199.     DO i=1 TO LENGTH(ReqText)
  200.         CALL SetLayer(WorkLayer)
  201.  
  202.         Width = MakeText(SUBSTR(ReqText,i,1), ReqFont)
  203.         PARSE VALUE BoundingBox() WITH N X1 X2 Y1 Y2 Z1 Z2
  204.         Width = Width + X1
  205.                                               /* Side Side Side Formula */
  206.         Angle = (ACOS(((ReqRadius*ReqRadius*2)-(Width*Width))/(2*ReqRadius*ReqRadius)))*RadToDeg
  207.         Total = Total + Angle
  208.  
  209.         IF ReqStyle = 1 THEN DO
  210.             CALL Rotate((90-((180-Angle)/2)), "Z", 0 0 0)
  211.             CALL Move(0 ReqRadius 0)
  212.         END
  213.         IF ReqStyle = 2 THEN DO
  214.             CALL Rotate(((90-((180-Angle)/2))*-1), "Z", 0 0 0)
  215.             CALL Move(0 ((-1*ReqRadius)-0.75) 0)
  216.         END
  217.         IF ReqStyle = 3 THEN DO
  218.             CALL Rotate((90-((180-Angle)/2)), "Y", 0 0 0)
  219.             CALL Move(0 0 (-1*ReqRadius))
  220.         END
  221.  
  222.         CALL Cut() ; CALL SetLayer(MainLayer) ; CALL Paste()
  223.  
  224.         IF ReqStyle = 1 THEN CALL Rotate((-1*Angle), "Z", 0 0 0)
  225.         IF ReqStyle = 2 THEN CALL Rotate(Angle, "Z", 0 0 0)
  226.         IF ReqStyle = 3 THEN CALL Rotate((-1*Angle), "Y", 0 0 0)
  227.     END
  228.  
  229.     IF ReqStyle = 1 THEN CALL Rotate((Total/2), "Z", 0 0 0)
  230.     IF ReqStyle = 2 THEN CALL Rotate(((Total/2)*-1), "Z", 0 0 0)
  231.     IF ReqStyle = 3 THEN CALL Rotate((Total/2), "Y", 0 0 0)
  232.  
  233. RETURN
  234.  
  235. /* -------------------------------------------------------------------- */
  236.                                             /* Recording Macro Settings */
  237. SaveSettings:
  238.  
  239.     IF (OPEN(PrefsFile, PrefsFileName, 'W')) THEN DO
  240.         CALL WRITELN(PrefsFile, MacrosName)
  241.  
  242.         CALL WRITELN(PrefsFile, ReqStyle)
  243.         CALL WRITELN(PrefsFile, ReqText)
  244.         CALL WRITELN(PrefsFile, ReqFont)
  245.         CALL WRITELN(PrefsFile, ReqRadius)
  246.         CALL WRITELN(PrefsFile, FilePath)
  247.         CALL WRITELN(PrefsFile, FileName)
  248.  
  249.         CALL CLOSE PrefsFile
  250.     END
  251.  
  252. RETURN
  253.  
  254. /* -------------------------------------------------------------------- */
  255.                                                               /* Ending */
  256. Exiting:
  257.  
  258.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  259.     EXIT
  260.  
  261. RETURN
  262.  
  263. /* -------------------------------------------------------------------- */
  264.                                                  /* Information Windows */
  265. InformationWindows:
  266.  
  267.     OKorCancel = Notify(2, Info1A, Info1B, Info1C, Info1D, Info1E, Info1F, Info1G, Info1H, Info1I, Info1J, Info1K, Info1L, Info1M, Info1N)
  268.     IF OKorCancel = 1 THEN CALL Notify(1, Info2A, Info2B, Info2C, Info2D, Info2E, Info2F, Info2G, Info2H, Info2I, Info2J, Info2K, Info2L, Info2M, Info2N)
  269.     OKtoContinueB = 0
  270.  
  271. RETURN
  272.  
  273. /* -------------------------------------------------------------------- */
  274.                                                       /* Error Handling */
  275. SYNTAX:
  276. ERROR:
  277.  
  278.     ErrCode = RC
  279.     ErrLine = SIGL
  280.     ErrInfo = ERRORTEXT(ErrCode)
  281.  
  282.     Err1 = "!Sorry!"
  283.     Err2 = "An Error has been detected"
  284.     Err3 = "@þ Macro -            "
  285.     Err4 = "@þ Line Number -      "
  286.     Err5 = "@þ Error Code -       "
  287.     Err6 = "@þ Error Description -"
  288.     Err7 = "@¤ Please Inform -    "
  289.     Err8 = '  "Error Notice"     '
  290.     Err9 = "  13032 Copenhill Rd."
  291.     Err10 = "  Dallas, TX. 75240  "
  292.  
  293.     Call Notify(1,Err1,Err2,Err3,MacrosName,Err4,ErrLine,Err5,ErrCode,Err6,ErrInfo,Err7,Err8,Err9,Err10)
  294.  
  295. /* -------------------------------------------------------------------- */
  296.                                              /* Advanced Error Handling */
  297.     CALL SETCLIP("ErrorMacro",MacrosName)
  298.     CALL SETCLIP("ErrorLine",ErrLine)
  299.     CALL SETCLIP("ErrorCode",ErrCode)
  300.     CALL SETCLIP("ErrorDesc",ErrInfo)
  301.  
  302.     PARSE SOURCE TempA TempB ErrFile TempC TempD TempE
  303.  
  304.     CALL SETCLIP("ErrorFile",ErrFile)
  305.  
  306. /* -------------------------------------------------------------------- */
  307.  
  308.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  309.     EXIT
  310.