[Implemented] Optional x,y for Drawtext()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

[Implemented] Optional x,y for Drawtext()

Post by Psychophanta »

Please,
Because when a Drawtext() is done, the next Drawtext() (without x,y params) should be printed after it, contiguous.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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")
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

wow, it works. Clever idea, thanx :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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
Post Reply