Old 08-02-2018, 01:50 AM   #1
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default Q: gfx_blit: Rotate text -90 degrees ?

Here's another one I am having problems getting right: I wish to display some text rotated by -90 degrees, thus:


Here's my lua code so far:

Code:
gfx.dest=127;               -- draw to offscreen buffer
LW, LH = gfx.measurestr("... Rotated text ...")
gfx.setimgdim(127, LW, LH)
gfx.x =0; gfx.y = 0; set_colour(CYAN); gfx.a = 0.80
gfx.printf("%s", ... Rotated text ...")  -- so far, so good.

gfx.dest=-1;                -- back to on-screen
gfx.x = 200;  gfx.y = 200; 
gfx.blit(127, 1, 270/360 *2*3.14159,    -- source, scale, rotation (in radians) [, 
         0, 0, LW, LH,                          -- srcx, srcy, srcw, srch, 
         400, 400, LH, LW,  -- destx, desty, destw, desth, (yep, switched around)
         0, 0)                                     -- rotxoffs, rotyoffs])
What am I missing?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 08-02-2018, 05:25 AM   #2
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 809
Default

Rotating while blitting does not rotate the destination rectangle. This code uses a rect large enough to take the text at all angles.

Code:
gfx.init("rotated_blit...?", 400, 400, 0, 100, 100)
gfx.clear = 0

LW, LH = gfx.measurestr("...Rotated Text...")
gfx.setimgdim(127, LW, LW)

gfx.x, gfx.y = 0, LW * 0.5
gfx.set(1, 1, 1)
gfx.a = 0.80

gfx.dest = 127; gfx.mode = 6
gfx.drawstr("...Rotated Text...")

ang = math.rad(270)

function main()
    key = gfx.getchar()
    
    gfx.dest = -1; gfx.mode = 6
    gfx.x, gfx.y = 200, 200 
    
    gfx.blit(127, 1, ang,   0, 0, LW, LW,   100, 100, LW, LW)
    gfx.update()     
    
    if key ~= -1 and key ~= 27 then reaper.defer(main) end

    ang = ang + 0.01
    if ang > math.rad(360) then ang = 0 end
end

main()
It's obviously not ideal because the src/dst rectangles are much larger than what you want (width, height instead of width, width as I used).

<previous edit removed>
But... why that doesn't work when you swap width/height at the destination, as in your example, I don't know.
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen

Last edited by RobU; 08-02-2018 at 05:52 AM.
RobU is online now   Reply With Quote
Old 08-02-2018, 09:56 AM   #3
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Yes, you'd think that it should work, shouldn't it?

But, thank you for the code snippet- the key seems to be having a square image size, slightly bigger than the string width. I tried it with a few examples and am making some progress. However:
(a) I turned on "Blend" mode for gfx.mode, otherwise I got the black background from the buffer. (As in the screenshot below.)

(b) how do I initialise the off-screen buffer; sometimes when I changed the text it seemed to have kept the image of the previous text in the buffer

(c) the rotation degraded the quality of the text characters

(d) short strings (or is it lower-case strings?) (e.g. "two") had their bottoms chopped off

This shows a string with 0 rotation, 270 rotation and my idea of the buffer with the transformation shown. Given that it is a straight-forward 90 degree transform, maybe there is a better way.

__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 08-02-2018 at 10:05 AM.
DarkStar is offline   Reply With Quote
Old 08-02-2018, 11:10 AM   #4
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,415
Default

you need to "clear" the buffer if you are going to reuse it.

This is undocumented, but (iirc) the way to do that is to set the image dimensions to a negative number.

i.e

gfx.setimgdim(127, -1, -1);

then resize it to what you need. in doing that, you clear the buffer back to alpha.

Last edited by James HE; 08-02-2018 at 11:15 AM.
James HE is offline   Reply With Quote
Old 08-02-2018, 01:08 PM   #5
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,346
Default

I think any resize will do it; -1,-1 might just be a convention to make it obvious.

Quote:
Resize image referenced by index 0..1024-1, width and height must be 0-2048. The contents of the image will be undefined after the resize.
Lokasenna is online now   Reply With Quote
Old 08-02-2018, 01:14 PM   #6
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,346
Default

Disclaimer - pure conjecture:

When it rotates the image it's still got that buffer's dimensions to work with, so a 128x64 image can't be rotated 90 degrees without losing half of it - thus, needing a 128x128 buffer.

You could always use another buffer in between - draw the text to a 128x128 buffer, rotational blit it to another 128x128 buffer so you have the whole thing, then blit from there to the main buffer and specify a source rectangle of 64x128.

----

Completely unrelated, but worth remembering in case you haven't run into it yet - if you draw text straight into an empty buffer and then blit it onto a background, the edges will look shitty because they were antialiased against empty pixels. It's usually a good idea to draw a solid background the same dimensions as the text + a couple of pixels to catch the antialiasing.
Lokasenna is online now   Reply With Quote
Old 08-02-2018, 05:47 PM   #7
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,476
Default

the rotation parameter is really crap, sorry about that.

gfx.deltablit() is a better solution! You have total control of the deltas, so you can set dsdy and dtdx to 1 (s/t are the x/y coordinates of the source texture) and rotate 90 degrees...
Justin is online now   Reply With Quote
Old 08-03-2018, 03:35 AM   #8
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Hmm, I cannot work out how to use it.
Code:
gfx_deltablit(srcimg,srcx,srcy,srcw,srch, 
destx, desty, destw, desth, 
dsdx, dtdx, dsdy, dtdy, 
dsdxdy, dtdxdy ) -- REAPER 4.59+

Blits from srcimg(srcx,srcy,srcw,srch) to destination (destx,desty,destw,desth). 

Source texture coordinates are s/t, dsdx represents the change in s coordinate for 
each x pixel, dtdy represents the change in t coordinate for each y pixel, etc.
dsdxdy represents the change in dsdx for each line.
What is a texture?
What does s/t mean?

And what would the settings be to achieve the transformation I am looking for?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 08-03-2018, 04:14 AM   #9
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Meanwhile, this is the function I have come up with.

Code:
-- -------------------------------------------------------
function rotate_text(Ptext, Pdegrees, PdestX, PdestY)
-- -------------------------------------------------------
--local LW, LH, Ldim, degtorad

    degtorad = 1 / 360 * 2 * 3.14159
    save_gfxr = gfx.r; save_gfxg = gfx.g; save_gfxb = gfx.b

    gfx.r = 30/256; gfx.g = 30/256; gfx.b = 50/256  -- background colour, for the off-screen buffer
    LW, LH = gfx.measurestr(Ptext)  -- let the length of the string , in pixels
--    LW = math.max(LW, 19)
    Ldim = math.max(LW, LH) +1      -- get the larger, add 1 for safety

    gfx.dest=127;                   -- draw to off-screen buffer
    gfx.setimgdim(127, -1, -1)      -- clear the buffer
    gfx.setimgdim(127, Ldim, Ldim)  -- sets its size
    gfx.rect(0,0, Ldim, Ldim)       -- set the bg colour, for improved anti-aliasing

    gfx.a = 0.90
    gfx.r = save_gfxr; gfx.g = save_gfxg; gfx.b = save_gfxb -- set the text colour

    gfx.x =0; gfx.y = LW/2;                 -- position in the middle of the buffer 
    gfx.printf("%s", Ptext)

    gfx.dest=-1;                           -- switch back to on-screen
    gfx.mode = 0 +1-1 + 2 +4               -- blend mode (1) deactivated, disable source alpha (2), 
                                           -- disable filtering (4)

    gfx.blit(127, 1, Pdegrees * degtorad,  -- source, scale, rotation (in radians) [, 
             0,      LW/2 -1, Ldim, Ldim,  -- srcx, srcy, srcw, srch, 
             PdestX, PdestY,  Ldim, Ldim,  -- destx, desty, destw, desth,
             0, 0)                         -- rotxoffs, rotyoffs])

end -- of function
__________________
DarkStar ... interesting, if true. . . . Inspired by ...

Last edited by DarkStar; 08-03-2018 at 06:00 AM. Reason: buglet fixed (I hope) LW/2 -1
DarkStar is offline   Reply With Quote
Old 08-03-2018, 04:44 AM   #10
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,415
Default

Quote:
Originally Posted by Lokasenna View Post
I think any resize will do it; -1,-1 might just be a convention to make it obvious.

Unless something changed internally, negative resizing is the only way to get the buffer to go back to the alpha channel. Otherwise, things just get stuck in there. I can't seem to find the thread where MPL and I figured this out - it might have just been him - I can't remember.. lol!
James HE is offline   Reply With Quote
Old 08-03-2018, 05:54 AM   #11
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 809
Default

Quote:
Originally Posted by DarkStar View Post
Meanwhile, this is the function I have come up with.

Code:
[...]
    degtorad = 1 / 360 * 2 * 3.14159
[...]
    gfx.blit(127, 1, Pdegrees * degtorad,  -- source, scale, rotation (in radians)
[..]

end -- of function

I have a cheeky question; what do you have against using 'math.rad(Pdegrees)' ? I'm thinking it has to be faster than a divide and 3 muls (almost certainly if math lib is made local), and even if it's not, it's 100x more readable
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen
RobU is online now   Reply With Quote
Old 08-03-2018, 06:01 AM   #12
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

^^^
old habit

And the result:
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 08-03-2018, 06:18 AM   #13
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 809
Default

Quote:
Originally Posted by DarkStar View Post
^^^
old habit

And the result:
Boom! Glad you got it working

Quote:
Originally Posted by Justin View Post
gfx.deltablit() is a better solution!
Impenetrable documentation for us amateur hackers

It would be sweet if gfx.blit()'s rotation option automagically adjusted the dstw, dsth, even if only for 90/270 degree operations.

gfx.blit2() ?
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen
RobU is online now   Reply With Quote
Old 08-03-2018, 06:51 AM   #14
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Here's something-else I ran into. Instead of
Code:
gfx.r = 30/256; gfx.g = 30/256; gfx.b = 50/256  -- background colour, for the off-screen buffer
to set the background colour for the off-screen buffer, I tried using
Code:
gfx.getpixel(gfx.r, gfx.g, gfx.b)
to pick up the existing background colour (before switching to the off-screen buffer) but that just set all 3 to nil.

Any ideas?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 08-03-2018, 07:08 AM   #15
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 809
Default

Quote:
Originally Posted by DarkStar View Post
Code:
gfx.getpixel(gfx.r, gfx.g, gfx.b)
to pick up the existing background colour (before switching to the off-screen buffer) but that just set all 3 to nil

Any ideas?

Code:
gfx.x, gfx.y = <insert your x, y here>

r, g, b = gfx.getpixel()
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen
RobU is online now   Reply With Quote
Old 08-03-2018, 07:13 AM   #16
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,346
Default

Or could just do this and it's probably faster than anything involving the math library:
Code:
local degtorad = 0.017453278


Also, I'd consider adding more than 1px to the buffer you're using - text antialiasing can extend 2+ pixels outward. I think I do 4px and then draw it at 2,2.

Last edited by Lokasenna; 08-03-2018 at 07:21 AM.
Lokasenna is online now   Reply With Quote
Old 08-03-2018, 09:17 AM   #17
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Quote:
Originally Posted by RobU View Post
Code:
gfx.x, gfx.y = <insert your x, y here>

r, g, b = gfx.getpixel()
Thank you - I was using the JS /EEL syntax - as I had taken the code from one of my JS FX. But shouldn't it have thrown up a syntax error?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 08-04-2018, 04:23 AM   #18
RobU
Human being with feelings
 
RobU's Avatar
 
Join Date: Sep 2009
Location: R'lyeh
Posts: 809
Default

Quote:
Originally Posted by DarkStar View Post
Thank you - I was using the JS /EEL syntax - as I had taken the code from one of my JS FX. But shouldn't it have thrown up a syntax error?
Lua ignores additional arguments and return values if they are not required - so doing something like ..

r, g, b, x, y, z = gfx.getpixel(a, b, c)

.. will still return the r, g, b values, x, y, z will be nil, and the arguments will be silently ignored.

There are occasions when that behavior can be useful, e.g. a function that takes optional arguments, etc.
__________________
Hard work never killed anybody, but why take a chance?
~Edgar Bergen
RobU is online now   Reply With Quote
Old 08-04-2018, 06:21 AM   #19
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,346
Default

Quote:
Originally Posted by RobU View Post
Lua ignores additional arguments and return values if they are not required - so doing something like ..

r, g, b, x, y, z = gfx.getpixel(a, b, c)

.. will still return the r, g, b values, x, y, z will be nil, and the arguments will be silently ignored.
Lua might, but the Reaper API doesn't always - try omitting the buffer argument in GetTrackName and see what happens.
Lokasenna is online now   Reply With Quote
Old 08-04-2018, 06:44 AM   #20
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Has anyone worked out how to use gfx_deltablit()?
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 08-04-2018, 07:51 AM   #21
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,476
Default

Quote:
Originally Posted by DarkStar View Post
Has anyone worked out how to use gfx_deltablit()?
Here's an example:
Code:
function run() 
  gfx.set(0);
  gfx.rect(0,0,gfx.w,gfx.h)
  
  -- draw a gradient for demonstration purposes
  gfx.gradrect(0,0,gfx.w,40, 
     0,0,0,1, 
     1/gfx.w, 1/gfx.w, 0, 0,0,
     0,0,0,0)
     
  -- rotate
  gfx.deltablit(-1, -- source image
     0,0, -- source coordinates s/t for top-left corner
     gfx.w,40, -- source clip size
     0,40,40,800, -- destination rectangle
      -- for the source image, s/t represent x/y (this is a common convention for graphics programming)
     0, 1, 1, 0,  -- dsdx, dtdx, dsdy, dtdy
     0,0 -- dsdxdy dtdxdy
    );

  gfx.update();

  reaper.defer(run);

end

gfx.init("test",800,800);
reaper.defer(run);
Though now I notice that this only works for certain rotations, I need to add an optional parameter to allow ignoring the source clip rectangle... oops

Last edited by Justin; 08-04-2018 at 08:00 AM.
Justin is online now   Reply With Quote
Old 08-04-2018, 08:17 AM   #22
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,476
Default

OK here's a way to do it using gfx.transformblit(), which is very handy (and even more powerful):
Code:
function run() 
  gfx.set(0);
  gfx.rect(0,0,gfx.w,gfx.h)
  
  -- draw a gradient for demonstration purposes
  gfx.gradrect(0,0,gfx.w,40, 
     0,0,0,1, 
     1/gfx.w, .2/gfx.w, 0, 0,0,
     0,1/40,0,0)

  gfx.transformblit(-1, -- source image
         0,40, 40, 800, -- output x/y/w/h
         2,2, -- 2x2 table below:
         {  -- gfx.transformblit takes a table of coordinates
           800,0,  -- source coordinates of top left
           800,40, -- source coordinates of top right
           0,0, -- source coordinates of bottom left
           0,40 -- source coordinates of bottom right             
         }
         )

  gfx.update();

  reaper.defer(run);

end

gfx.init("test",800,800);
reaper.defer(run);
Justin is online now   Reply With Quote
Old 08-04-2018, 08:48 AM   #23
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Thank you for taking the time out to post this. I try it out later.

Hmm, another bit of syntax I did not know :

Code:
         {             -- gfx.transformblit takes a table of coordinates
           800,0,    -- source coordinates of top left
           800,40,  -- source coordinates of top right
           0,0,       -- source coordinates of bottom left
           0,40      -- source coordinates of bottom right             
         }
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar is offline   Reply With Quote
Old 10-25-2019, 11:32 AM   #24
Archie
Human being with feelings
 
Archie's Avatar
 
Join Date: Oct 2017
Location: Russia
Posts: 29
Default

Quote:
Originally Posted by Justin View Post
Here's an example:
Code:
function run() 
  gfx.set(0);
  gfx.rect(0,0,gfx.w,gfx.h)
  
  -- draw a gradient for demonstration purposes
  gfx.gradrect(0,0,gfx.w,40, 
     0,0,0,1, 
     1/gfx.w, 1/gfx.w, 0, 0,0,
     0,0,0,0)
     
  -- rotate
  gfx.deltablit(-1, -- source image
     0,0, -- source coordinates s/t for top-left corner
     gfx.w,40, -- source clip size
     0,40,40,800, -- destination rectangle
      -- for the source image, s/t represent x/y (this is a common convention for graphics programming)
     0, 1, 1, 0,  -- dsdx, dtdx, dsdy, dtdy
     0,0 -- dsdxdy dtdxdy
    );

  gfx.update();

  reaper.defer(run);

end

gfx.init("test",800,800);
reaper.defer(run);
Though now I notice that this only works for certain rotations, I need to add an optional parameter to allow ignoring the source clip rectangle... oops


Hi!
Why, when I stretch or narrow the right side of the "w" window, the inverted image is stretched-narrowed along the "h" axis, although everything is indicated in fixed numbers in the code.
Is this a mistake or am I doing something wrong?
How to overcome it?
Thank?




Code:
function run() 
 gfx.set(0);
 gfx.rect(0,0,gfx.w,gfx.h)
 
 -- draw a gradient for demonstration purposes
 gfx.gradrect(0,0,gfx.w-50,40, 
 0,0,0,1, 
 1/(gfx.w-50), 1/(gfx.w-50), 0, 0,0,
 0,0,0,0)
 -- rotate
 gfx.deltablit(-1, -- source image
 0,0, -- source coordinates s/t for top-left corner
 gfx.w-50,40, -- source clip size
 0,40,40,500, -- destination rectangle
 -- for the source image, s/t represent x/y (this is a common convention for graphics programming)
 0, 1, 1, 0, -- dsdx, dtdx, dsdy, dtdy
 0,0 -- dsdxdy dtdxdy
 );
 gfx.update();

 reaper.defer(run);

end

gfx.init("test",800,600,0,200,50);
reaper.defer(run);
__________________
=================================
ReaPack| Archie-ReaScript: Discussion | Donate
Archie is offline   Reply With Quote
Old 10-25-2019, 02:52 PM   #25
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,176
Default

Is it because the destination rectangle just indicates the boundary rectangle into which the source rectangle is being blitted? No scaling going on.

Therefore you see the the vertical copy growing up to the vertical boundary size (460 pixels?)

Try adding a rectangle around the target rectangle. This shows (to me anyway) what is happening here...

Code:
function run() 
 gfx.set(0);
 gfx.rect(0,0,gfx.w,gfx.h)
 
 -- draw a gradient for demonstration purposes
 gfx.gradrect(0,0,gfx.w-50,40, 
 0,0,0,1, 
 1/(gfx.w-50), 1/(gfx.w-50), 0, 0,0,
 0,0,0,0)
 -- rotate
 gfx.deltablit(-1, -- source image
 0,0, -- source coordinates s/t for top-left corner
 gfx.w-50,40, -- source clip size
 0,40,40,500, -- destination rectangle
 -- for the source image, s/t represent x/y (this is a common convention for graphics programming)
 0, 1, 1, 0, -- dsdx, dtdx, dsdy, dtdy
 0,0 -- dsdxdy dtdxdy
 );
 
 gfx.r = 255
 gfx.rect(0,40,40,500,0)
 gfx.update();

 reaper.defer(run);

end

gfx.init("test",800,600,0,200,50);
reaper.defer(run);
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 10-25-2019, 10:15 PM   #26
Archie
Human being with feelings
 
Archie's Avatar
 
Join Date: Oct 2017
Location: Russia
Posts: 29
Default

Quote:
Originally Posted by lb0 View Post
Is it because the destination rectangle just indicates the boundary rectangle into which the source rectangle is being blitted? No scaling going on.
Ok, I wrote the image to the buffer before the loop and unzip it in the loop. The source rectangle is a fixed image now, but the destination rectangle is still scaled along the h axis when we stretch w

Quote:
Originally Posted by lb0 View Post
Therefore you see the the vertical copy growing up to the vertical boundary size (460 pixels?)
In my opinion this should not happen

Quote:
Originally Posted by lb0 View Post
Try adding a rectangle around the target rectangle. This shows (to me anyway) what is happening here...
I understand that no scaling occurs, but the gfx.deltablit function does it.
I think this is a mistake.
If I'm wrong, then show me some example where this function with this behavior could be useful, because in fact I can’t rotate the image


Code:
function run() 
  gfx.set(0);
  gfx.rect(0,0,gfx.w,gfx.h)
   
  
  gfx.dest =  -1
  
  -- rotate
  gfx.deltablit(1, -- source image
  0,0, -- source coordinates s/t for top-left corner
  gfx.w-50,40, -- source clip size
  0,40,40,500, -- destination rectangle
  -- for the source image, s/t represent x/y (this is a common convention for graphics programming)
  0, 1, 1, 0, -- dsdx, dtdx, dsdy, dtdy
  0,0 -- dsdxdy dtdxdy
  );
  gfx.update(); 
 
  reaper.defer(run);
 
end



gfx.init("test",800,600,0,200,50);


 gfx.dest = 1  
 gfx.setimgdim(1, -1, -1)   
 gfx.setimgdim(1, gfx.w, 40)    
 gfx.a = 1
 -- draw a gradient for demonstration purposes
 gfx.gradrect(0,0,gfx.w-50,40, 
 0,0,0,1, 
 1/(gfx.w-50), 1/(gfx.w-50), 0, 0,0,
 0,0,0,0)
 
 
reaper.defer(run);
__________________
=================================
ReaPack| Archie-ReaScript: Discussion | Donate
Archie is offline   Reply With Quote
Old 11-11-2019, 03:56 AM   #27
DarkStar
Human being with feelings
 
DarkStar's Avatar
 
Join Date: May 2006
Location: Surrey, UK
Posts: 18,054
Default

Revisiting this one...

It looks to me that any blit rotation without any shape distortion needs a square source and target. Is that correct?

Or, what is the best way to achieve the transformation of the text and its background:



I was hoping that the gfx_blit() above would do it, but no.
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
DarkStar 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 03:27 PM.


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