Page 1 of 1

[Implemented] Optional x,y for Drawtext()

Posted: Mon Feb 06, 2006 9:47 pm
by Psychophanta
Please,
Because when a Drawtext() is done, the next Drawtext() (without x,y params) should be printed after it, contiguous.

Posted: Mon Feb 06, 2006 9:50 pm
by blueznl
imagine you do a drawtext...

x = 10
y = 10
drawtext(x,y,"this ")

now the issue is: where does the next part go?

x = 10
y = 10
x = drawtext(x,y,"this ")
x = drawtext(x,y,"a test")

Posted: Mon Feb 06, 2006 9:58 pm
by Psychophanta
wow, it works. Clever idea, thanx :)

Posted: Mon Feb 06, 2006 10:06 pm
by Trond
Oh, I didn't know that the new DrawText() returned an X value, however since I already made it...

Code: Select all

Global Locate.POINT

Procedure Locate(x, y)
  Locate\x = x
  Locate\y = y
EndProcedure

Procedure DrawTextCont(text.s)
  DrawText(Locate\x, Locate\y, text.s)
  Locate\x + TextWidth(text.s)
EndProcedure

CreateImage(0, 400, 300)

StartDrawing(ImageOutput(0))
  Locate(10, 10)
  DrawTextCont("Apple pie ")
  DrawTextCont("tastes good!")
StopDrawing()


OpenWindow(0,0,0,245,105,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ImageGadget")
CreateGadgetList(WindowID(0))
  ImageGadget(0, 10, 10, 100, 83, ImageID(0))
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow