Old 01-07-2022, 12:43 PM   #1
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,269
Default gfx.blit requires four parameters...?

The Lua API docs say of gfx.blit(source,scale,rotation) that "If three parameters are specified, copies the entirety of the source bitmap to gfx.x, gfx.y using current opacity and copy mode..." and more. Note the if. To me, this means that not all parameters are required. So I try: gfx.blit(src_img) and to my surprise I get an error saying Function 'blit' requires 4 parameters, 1 passed.

If I do gfx.blit(src_img, 1) I get a message saying almost the same thing: Function 'blit' requires 4 parameters, 2 passed

Only if I pass all three parameters gfx.blit(src_img, 1, 0) do I not get any error message.

So I guess the API docs and the error message should be updated. Right?
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 01-07-2022, 12:50 PM   #2
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,349
Default

There are two help entries for gfx.blit. The one you are looking at describes the behavior with three parameters, the other one describes the behavior with more than three parameters. The 4th and 5th parameters are "srcx, srcy" so I think you are getting the "4 parameters" message because if you provide one, you have to provide both.

I do notice the documentation spells "entirity" wrong though
schwa is offline   Reply With Quote
Old 01-07-2022, 01:18 PM   #3
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,476
Default

Maybe it's better to rephrase the error-message to "...requires at least 3 parameters..."
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper
Bugreports&Docs notes please do here:https://github.com/Ultraschall/ultra...-reaper/issues - Donate, if you wish
Meo-Ada Mespotine is online now   Reply With Quote
Old 01-07-2022, 03:07 PM   #4
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,269
Default

OK, this is a minor detail really, and maybe my post was a slight overreaction

Quote:
Originally Posted by schwa View Post
There are two help entries for gfx.blit. The one you are looking at describes the behavior with three parameters, the other one describes the behavior with more than three parameters. The 4th and 5th parameters are "srcx, srcy" so I think you are getting the "4 parameters" message because if you provide one, you have to provide both.
But, I'm not sure that I follow this... Yes, I read the notes for the simplified 3-parameter blit, and that's the one I use. The problem does not occur if I give srcx but not srcy, it occurs when I give only the src_img, and no scale, no rotation. That should not ask for 4 parameters, should it?

And if I have to give all three parameters, the docs should not say "If three parameters are specified". Or?

Quote:
Originally Posted by schwa View Post
I do notice the documentation spells "entirity" wrong though
Yeah, when quoting the spell-checker complained so I changed it But when updating that, maybe also the "if" should be removed.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Old 01-07-2022, 04:19 PM   #5
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,586
Default

Hmm yeah the two implementations of gfx_blit() can get combined, doing that.
Justin is offline   Reply With Quote
Old 01-07-2022, 04:53 PM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,476
Default

Quote:
Originally Posted by Justin View Post
Hmm yeah the two implementations of gfx_blit() can get combined, doing that.
Would it be possible to make rotation and scale optional? So

gfx.blit(1)

is equal to

gfx.blit(1, 1, 0)

?
I think that is probably the most used case for people who just want to quickly blit something.
Happens often to me, at least.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper
Bugreports&Docs notes please do here:https://github.com/Ultraschall/ultra...-reaper/issues - Donate, if you wish
Meo-Ada Mespotine is online now   Reply With Quote
Old 01-07-2022, 06:40 PM   #7
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,586
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Would it be possible to make rotation and scale optional? So

gfx.blit(1)

is equal to

gfx.blit(1, 1, 0)

?
I think that is probably the most used case for people who just want to quickly blit something.
Happens often to me, at least.
Yeah, sure (though it wouldn't work with 6.44 and earlier)
Justin is offline   Reply With Quote
Old 01-07-2022, 06:47 PM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,476
Default

No problem for my usual usecases.

Maybe a note in the docs "6.44 and lower expect three parameters minimum" for scripts that need to be backwards-compatible should be enough, I think.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper
Bugreports&Docs notes please do here:https://github.com/Ultraschall/ultra...-reaper/issues - Donate, if you wish
Meo-Ada Mespotine is online now   Reply With Quote
Old 01-08-2022, 01:06 PM   #9
Fabian
Human being with feelings
 
Fabian's Avatar
 
Join Date: Sep 2008
Location: Sweden
Posts: 7,269
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Would it be possible to make rotation and scale optional? So

gfx.blit(1)

is equal to

gfx.blit(1, 1, 0)

?
I think that is probably the most used case for people who just want to quickly blit something.
Happens often to me, at least.
It is exactly the same here. This was what I stumbled on from the beginning, so would be very convenient.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
Fabian is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.