Rectangular Text
BlitzPlus Forums/BlitzPlus Programming/Rectangular Text
| ||
This is a little function I wrote to make a string of text be displayed at a certain location at a certain width. I have already chopped 9 lines off the code and was wondering if anybody could shorten it more. Graphics 800,600,32,2 SetBuffer BackBuffer() textsquare("This is the test of the new textsquare function and I need to ramble to make sure it works, so that is what I am doing. I hope it works well. Yeah. This is getting old. Yup. It is. Ok. That ought to be long enough now.",100,20,400) Flip WaitKey End Function textsquare(incoming$,x,y,width) word$="" tempx=x tempy=y While incoming$<>"" word$="" While Right$(word$,1)<>" " And incoming$<>"" word$=word$+Left$(incoming$,1) incoming$=Right$(incoming$,Len(incoming$)-1) Wend If tempx+StringWidth(word$)<width+x Text(tempx,tempy,word$) tempx=tempx+StringWidth(word$) Else tempx=x tempy=tempy+FontHeight() Text(tempx,tempy,word$) tempx=tempx+StringWidth(word$) End If Wend End Function Good luck! |
| ||
What are the forum codes? |
| ||
You misunderstand me, fool. I don't want to put code in a box for the forums. I want to do it in a graphics mode. I am currently writing a function that does it fully justified. |
| ||
not al that shorter line wise but its more efficient |
| ||
This code will justify it too! If you can shorten it, please do. |
| ||
Ok. This is as good as I can get it. 22 lines of bliss. Shorten it. Please. |