wawa
Junior Member
Posts: 24
|
Post by wawa on Jul 29, 2020 7:15:45 GMT -8
Is there a function to show only part of a sprite? For example my image is 64x64 but I want to display a square of 32x32 from 10,10 of its top-left corner.
|
|
|
Post by avanti on Jul 29, 2020 7:22:20 GMT -8
Scissor?
|
|
wawa
Junior Member
Posts: 24
|
Post by wawa on Jul 29, 2020 7:49:59 GMT -8
Scissor limits drawing to a rectangluar region of the screen, it does not cut a rectangle of any size at x,y inside a sprite to put it anywhere on the screen, no ?
|
|
|
Post by avanti on Jul 29, 2020 9:39:12 GMT -8
I guess I don't understand the distinction you are making. Can't I use scissor with a bitmap draw to show any part of an image at any location on the screen? You can also scale and translate the image using the transformation matrix.
Or, do you want to create an entirely new bitmap? If so, I suppose you could do it yourself with memory reads/writes. There is also the screen snapshot thing...
|
|
|
Post by jamesbowman on Jul 29, 2020 15:43:03 GMT -8
Scissor operates in screen space, restricting all drawing to a rectangle on screen:
GD.ScissorXY(100, 300); GD.ScissorSize(32, 32); GD.Begin(BITMAPS); GD.Vertex2f(PIXELS(100), PIXELS(300)); But there is also bitmap size. This lets you limit the size of the bitmap drawn on screen. So for your 64x64 bitmap example, you might limit it to 32x32 top-left with:
GD.BitmapSize(NEAREST, BORDER, BORDER, 32, 32); GD.Vertex2f(PIXELS(100), PIXELS(300));
|
|
|
Post by tftlcdcyg on Jul 30, 2020 6:25:45 GMT -8
The key to this type of screen is to think of it as something completely different to the screens of a lifetime (namely: ILI9341, ILI9488, etc.). You could resort to using cells for more complex cuts or in few cuts, you could use the asset creation tool Teensy 4 + NHD-FT813 7" Mona.gd2 (190.35 KB) Mona.h (1.32 KB) Mona1.h (891.6 KB)
|
|
wawa
Junior Member
Posts: 24
|
Post by wawa on Jul 30, 2020 8:37:34 GMT -8
Thanks all, well, I'm going to explore scissor more deeply
tftlcdcyg > Yes, I already used the asset creation tool to cut a picture in tiles for a Gameduino game (the 2nd game IN THIS VIDEO)
|
|
wawa
Junior Member
Posts: 24
|
Post by wawa on Aug 2, 2020 2:14:08 GMT -8
It's ok, I did what I wanted with scissor (cut out any blocks at any position from only 1 asset stored in flash memory): DEMOThanks for your help!
|
|
|
Post by jamesbowman on Aug 2, 2020 18:29:45 GMT -8
Heh, looks good!
|
|
|
Post by tftlcdcyg on Aug 2, 2020 21:32:46 GMT -8
Great! PD: my scissor test!
|
|
wawa
Junior Member
Posts: 24
|
Post by wawa on Aug 2, 2020 21:45:15 GMT -8
Great, powerful function
|
|