Page 1 of 1
Write a text on a picture
Posted: Sun Jul 23, 2023 10:51 am
by papiosaur
hello,
i would like to write a text on a picture but don't work, this is my code:
Code: Select all
Enablelayers()
LoadBrush(2, pict$)
ScaleBrush(2, 320, 256)
moai.Set("image", "brush", 2)
SetFontColor(#RED)
OpenFont(1, "Fonts:_ttf/Arimo-Bold.ttf", 72, {Engine = #FONTENGINE_INBUILT})
UseFont(1)
CreateTextObject(1, "Hello World!")
DisplayTextObject(1, #CENTER, #CENTER)
Thanks for your help

Re: Write a text on a picture
Posted: Sun Jul 23, 2023 11:30 am
by papiosaur
The picture is showed but not the text
Re: Write a text on a picture
Posted: Sun Jul 23, 2023 1:11 pm
by plouf
What you are trying to is a bit confusing
I see
EnableLayers() and
DisplayTextObject() which are commands supposed to work in diplays fullscreen or hollywooddisplay bit also you set image with moai.set which is rapagui
So you either create a hollywooddisplayinside GUI and brush and then text in there
Or draw on image and then display modified image
Re: Write a text on a picture
Posted: Mon Jul 24, 2023 5:27 am
by plouf
here a full working example usign Hollywooddisplay inside RapaGUI
Code: Select all
xml$ = [[
<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
<window id="win" title="Tasks" >
<hgroup>
<vgroup>
<rectangle />
<button id="ok">OK</button>
<hollywood display="2" width="300" height="300"/>
<button id="no">NO</button>
</vgroup>
<vgroup>
<rectangle />
<button id="2">2</button>
<rectangle />
<button id="3">3</button>
</vgroup>
</hgroup>
</window>
</application>
]]
@REQUIRE "RapaGUI"
CreateDisplay(2,{color=#RED,x=300,y=300})
CreateBrush(1,260,260,#GREEN)
moai.CreateApp(xml$)
SelectDisplay(2)
DisplayBrush(1,20,20)
SetFontColor(#YELLOW)
CreateTextObject(1, "Hello World!")
DisplayTextObject(1, #CENTER, #CENTER)
Repeat
WaitEvent
Forever
Re: Write a text on a picture
Posted: Mon Jul 24, 2023 2:58 pm
by papiosaur
Thanks a lot plouf for the example!
I will try that soon

Re: Write a text on a picture
Posted: Tue Jul 25, 2023 10:44 pm
by papiosaur
@plouf : work perfectly, thanks a lot !