Write a text on a picture

Find quick help here to get you started with Hollywood
Post Reply
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Write a text on a picture

Post 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 ;-)
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Re: Write a text on a picture

Post by papiosaur »

The picture is showed but not the text
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Write a text on a picture

Post 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
Christos
plouf
Posts: 666
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Write a text on a picture

Post 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
Christos
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Re: Write a text on a picture

Post by papiosaur »

Thanks a lot plouf for the example!

I will try that soon ;-)
papiosaur
Posts: 217
Joined: Fri Mar 31, 2023 1:34 pm

Re: Write a text on a picture

Post by papiosaur »

@plouf : work perfectly, thanks a lot !
Post Reply