Transparency Pixel colour for Sprites on HP Prime
|
05-20-2021, 09:35 PM
Post: #1
|
|||
|
|||
Transparency Pixel colour for Sprites on HP Prime
I had a look here:
https://www.omnimaga.org/hp-calculator-p...hp-prime)/ And downloaded the suggested program in the second post, DIMGROB generator. I generated a sprite, and assumed that the corners of the ball would be transparent, but they are white, on top of the calc screen: Code: EXPORT ball() Is there another colour code that actually will appear transparent on top of the screen, and is there a way to have the ball not wipe out the screen on G0? |
|||
05-21-2021, 12:57 AM
Post: #2
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
What I do is have a background with no objects in one graphics page, then for each movement, I copy the background to a second page, BLIT the objects to the second page then copy that second page to G0. To the user it looks like the objects are moving over the background without disturbing it.
Tom L Cui bono? |
|||
05-21-2021, 09:58 AM
Post: #3
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-21-2021 12:57 AM)toml_12953 Wrote: What I do is have a background with no objects in one graphics page, then for each movement, I copy the background to a second page, BLIT the objects to the second page then copy that second page to G0. To the user it looks like the objects are moving over the background without disturbing it. Do you do that every single time something moves? How do we go about getting pixels of a GROB to be transparent? The program DIMGROB creator that I used had set some of those pixels to transparent, and they ended up white. |
|||
05-21-2021, 12:17 PM
Post: #4
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-21-2021 09:58 AM)matalog Wrote:(05-21-2021 12:57 AM)toml_12953 Wrote: What I do is have a background with no objects in one graphics page, then for each movement, I copy the background to a second page, BLIT the objects to the second page then copy that second page to G0. To the user it looks like the objects are moving over the background without disturbing it. I use a mask with the a silhouette of the object in black on a white rectangle. I AND it onto the background which gives me the background with the black shape on it (looks like a cutout of the object) then XOR the object onto it. Tom L Cui bono? |
|||
05-21-2021, 05:42 PM
Post: #5
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
From the chat in this link:
https://www.omnimaga.org/hp-calculator-p...hp-prime)/ It seemed like the 'sprites' can be created and used with transparency colour/pixels, is that not the case? Most even in-any-way modern programming languages allow some parts of graphics objects to be transparent, are you saying that what you did was to mask them off and there may be another method? Or is there no way to have parts of a GROB transparent apart from using a mask to hide them? |
|||
05-21-2021, 07:12 PM
Post: #6
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
Here is a silly little program I wrote that uses sprites with a transparent background. I use G2 for the sprites by initializing it as a transparent color and then drawing the images on it.
Code:
|
|||
05-21-2021, 09:41 PM
Post: #7
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-21-2021 07:12 PM)john gustaf stebbins Wrote: Here is a silly little program I wrote that uses sprites with a transparent background. I use G2 for the sprites by initializing it as a transparent color and then drawing the images on it. There's nothing silly about that! That's a really good pendulum wave demonstration! I'll have a good read through it and make sure I understand it. Thanks for sharing that. |
|||
05-22-2021, 03:39 AM
Post: #8
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-21-2021 09:41 PM)matalog Wrote: There's nothing silly about that! That's a really good pendulum wave demonstration! You're quite kind. One of the things that took me a while to work out was that if I drew to a transparent graphic, it would become a solid background, where the drawing affected it. I have another version of of this where the balls are drawn using partially transparent colors for each frame, so you can see the balls behind the front ones. I could not figure a way to create partially transparent sprites with the built in drawing commands. The only command that preserved the alpha value for the graphic itself is DIMGROB. I've not worked with other graphic systems using transparency. I had expected that if I had a color with transparency (alpha 255) and I drew a color with half transparency (alpha 127) I would get a final color with half transparency (alpha 127). I expect there could be some issues with how this would work in G0 (can't let us see the innards of the calculator :^), but it could be very useful for building images in the other graphic variables. |
|||
05-22-2021, 05:30 AM
Post: #9
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
Take a look at the new ability to embed pictures as data. You should be able to directly use PNG with transparency. Just make sure to unpack it first into a G<N> or other named variable first to avoid PNG decompression each time. That would kill your speed.
TW Although I work for HP, the views and opinions I post here are my own. |
|||
05-22-2021, 09:11 AM
Post: #10
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-22-2021 05:30 AM)Tim Wessman Wrote: Take a look at the new ability to embed pictures as data. You should be able to directly use PNG with transparency. Just make sure to unpack it first into a G<N> or other named variable first to avoid PNG decompression each time. That would kill your speed. That sounds great Tim, is it documented somewhere, so I know what I'm attempting to do? I'm quite new to the HP Prime, and still finding my feet using it. |
|||
05-22-2021, 07:02 PM
Post: #11
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-22-2021 05:30 AM)Tim Wessman Wrote: Take a look at the new ability to embed pictures as data. You should be able to directly use PNG with transparency. Just make sure to unpack it first into a G<N> or other named variable first to avoid PNG decompression each time. That would kill your speed. I was not able to get that to work, but haven't had time to play with it since the first recent beta. I'll have to try again. |
|||
05-22-2021, 07:17 PM
Post: #12
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-21-2021 07:12 PM)john gustaf stebbins Wrote: Here is a silly little program I wrote that uses sprites with a transparent background. I use G2 for the sprites by initializing it as a transparent color and then drawing the images on it. What is it in your program that determines that the pendula will be on a transparent background? Is it the line DIMGROB_P(G2,440,25,RGB(255,255,255,255)); ? Something to do with RGB(255,255,255,255))? Is it only the fourth 255 in that, and the fact that it is greater than 128? And then that you are only drawing pixels of other colours on that layer? |
|||
05-22-2021, 07:31 PM
(This post was last modified: 05-22-2021 08:21 PM by matalog.)
Post: #13
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-22-2021 05:30 AM)Tim Wessman Wrote: Take a look at the new ability to embed pictures as data. You should be able to directly use PNG with transparency. Just make sure to unpack it first into a G<N> or other named variable first to avoid PNG decompression each time. That would kill your speed. Tim, it you looks like you created the program that I used and mentioned in the original post of this thread above. You can find your original post in this old thread: https://www.omnimaga.org/hp-calculator-p...hp-prime)/ With your DIMGROB creator program, how would you then have the output (with relevant pixels coloured your transparency colour in the program) appear transparent? Also, what is the colour method that your program outputs? This format: #8000800080008000:64h - 64 bit Hex? Would that make it 32768,32768,32768,32768 for R,G,B,A. I'm just trying to understand that. Should the calculator see that as transparent? |
|||
05-22-2021, 10:07 PM
Post: #14
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
(05-22-2021 07:17 PM)matalog Wrote: What is it in your program that determines that the pendula will be on a transparent background? Is it the line DIMGROB_P(G2,440,25,RGB(255,255,255,255)); ? Something to do with RGB(255,255,255,255))? Is it only the fourth 255 in that, and the fact that it is greater than 128? And then that you are only drawing pixels of other colours on that layer? Yes, since I'm passing a transparent color to DIMGROB_P it is initializing the graphic as transparent. I'm not sure when the 128 fence is relevant here, it has been a while since I was working this out. RGB takes four inputs, with the fourth being the alpha value for the color (the amount of transparency). Here is the first version of the program I wrote that uses partially transparent colors to give a glass effect to the balls. I'm using a color with alpha of 64 and get bit of pass through, but the color dominates. The drawing is done with ARC_P. Code:
513016415223221833242338122322514610315 |
|||
05-23-2021, 02:02 AM
(This post was last modified: 05-23-2021 05:04 PM by matalog.)
Post: #15
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
Hey, thanks for the continuous replies, I do appreciate it!
I had a go at getting them moving in front of a background. EXPORT vispends() BEGIN DIMGROB_P(G1,320,240); DIMGROB_P(G4,320,240); BLIT_P(G1,0,0,320,240,G0,0,0,320,240); BLIT_P(G2,0,0,320,240,G0,0,0,320,240); BLIT_P(G3,0,0,320,240,G0,0,0,320,240); BLIT_P(G4,0,0,320,240,G0,0,0,320,240); DIMGROB_P(G1,320,240); DIMGROB_P(G2,440,25,RGB(255,255,255,255)); FOR T FROM 0 TO 10000 STEP 2 DO BLIT_P(G1,0,0,320,240,G4,0,0,320,240); FOR B FROM 1 TO 19 DO C:=RGB(255-B*12,64,B*12,64); ARC_P(G1,160+150*SIN(T*(1-B/80)),12+B*22,10,{#0,C}); END; BLIT(G1); END; WAIT() END; |
|||
05-23-2021, 11:50 PM
Post: #16
|
|||
|
|||
RE: Transparency Pixel colour for Sprites on HP Prime
I finally got what I wanted, by loading a .png image with AFiles and then saving that to a graphics variable, and it works fine.
I assume that is what you were referring to Tim. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)