Image, and Text

114 views
Skip to first unread message

Alan Hendry

unread,
Aug 7, 2021, 9:42:27 AM8/7/21
to DroidScript
Hi,
Can some one explain pxw and pxh on createimage?
Specifically
img = app.CreateImage(null, 0.8, 0.5, "fix" , 20 , 20)
On drawtext x seems to be position (0 to 1) of left hand side,
But y appears to be the bottom of the text (0 to 1)
(perhaps the text baseline, so descenders like q y p g j will go lower)
Regards, ah

Steve Garman

unread,
Aug 7, 2021, 11:44:05 AM8/7/21
to DroidScript
There's something about it that feels right to me but I can't justify it so it may just be that I've been using it for so long that it feels natural

I think if it were anything to do with descenders, this would fit on the screen, which it doesn't
function OnStart()
{
   lay = app.CreateLayout("linear", "VCenter, FillXY")

   img = app.AddImage(lay, null, 0.9, 0.5)
   img.SetColor( "blue"  )
   img.SetPaintColor( "white" )
   img.SetTextSize( 64 )
   img.DrawText( "AaJjPpQqZz", 0, 1 )
   
   app.AddLayout(lay)
}


Alan Hendry

unread,
Aug 8, 2021, 9:47:50 AM8/8/21
to DroidScript
Hi, 

If the descenders drop off the bottom,
 then I'm pretty sure y=1 is a text baseline at the very bottom of the image.

My other question was about what pxw and pxh do.
Let's say I coded app.CreateImage(null, 40,40,"px,fix",20,20)
I presume that on the screen the image is 40 pixels by 40.
But what do pxw pxh of 20 mean?
Do they affect GetPixelData, GetPixelColor, SetPixelData?

I also noticed that images have getname and setname.
What is that used for? Do other objects have it?

Regards, ah

Steve Garman

unread,
Aug 22, 2021, 4:00:24 AM8/22/21
to DroidScript

  pxw and pxh are used with the "fix" option
  to define the size of the fixed pixel

function OnStart()
{
   lay = app.CreateLayout("Linear", "VCenter,FillXY")

   img1 = app.AddImage(lay, null, 0.8, 0.3, "fix", 10, 10)
   img2 = app.AddImage(lay, null, 0.8, 0.3, "fix", 20, 20)

   app.AddLayout(lay)
   img1.DrawLine(0, 0.5, 1, 0.5)
   img2.DrawLine(0, 0.5, 1, 0.5)
} ////

Alan Hendry

unread,
Aug 26, 2021, 7:19:52 AM8/26/21
to DroidScript
Sorry,
I guess I don't understand what a fixed pixel is.
My guess is that it's a pretend/virtual pixel.
img1 = app.AddImage(lay, null, 0.8, 0.3, "fix", 10, 10)
The image covers 0.8 of the screen width, and 0.3 of the height
(In portrait that could be 720*0.8=576 pixels, 1520*0.3=456 pixels on the screen).
So the virtual pixels (10X10) map to 57.6 screen pixels horizontally, and 45.6 vertically.
Presumably  GetPixelData, GetPixelColor, SetPixelData would be based on the virtual pixels.
Regards, ah
Reply all
Reply to author
Forward
0 new messages