Omnimaga

Calculator Community => HP Calculators => Topic started by: DJ Omnimaga on December 03, 2013, 11:39:51 pm

Title: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 03, 2013, 11:39:51 pm
I am trying the example code found in the HP Prime help section, but I am getting an insufficient memory error. I am using 614 KB out of my 256 MB Flash. ???

Quote
Syntax: FILLPOLY_P([G], {coordinates...} or [Coordinates], Color, [Alpha])

Fills the polygon specified by the provided pixel coordinates using the color provided.
If Alpha (0 to 255) is provided, the polygon is drawn with trensparency.

Example: FILLPOLY_P([(20,20),(120,120),(150,20),(180,150),(50,100)], #FF, 128)

Does the calc literally have to be empty in order to use 3D functions? O.O
Title: Re: FILLPOLY_P: Insufficient memory
Post by: Matrefeytontias on December 04, 2013, 09:51:42 am
Aren't you missing a parameter ? In the text you quoted, it seems that you must pass 3 parameters (4 with alpha) and you passed 3 parameters including alpha.
Title: Re: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 04, 2013, 01:34:33 pm
I just used the example code ???
Title: Re: FILLPOLY_P: Insufficient memory
Post by: MacBernick on December 05, 2013, 10:06:29 pm
I think you should try and replace your ()'s by []'s, you will then have an actual matrix of coordinates. Looks like the Prime interprets (x, y) as complex numbers (x+iy).
Title: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 05, 2013, 10:10:56 pm
Ok I tried this and no longer get the error, but nothing happens at all.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: MacBernick on December 05, 2013, 10:24:55 pm
Yes you're right. The only way I managed to make it work is with lists

FILLPOLY_P({{20,20},{120,120},{150,20},{180,150},{50,100}}, #FF, 128)

is working fine.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 05, 2013, 10:30:48 pm
They really need to fix their help so that it provides working examples. :P (I mean, I went on-calc, selected FILLPOLY_P and pressed the Help key and this is what I got O.O)

It might be a typo, though.


It works now and thanks for the help! :D

And wow the function even supports alpha transparency...??? O.O

(http://img.ourl.ca//hpprimepolygonalphatransparency.png)
Title: Re: FILLPOLY_P: Insufficient memory
Post by: MacBernick on December 05, 2013, 10:39:42 pm
You're welcome.

yes I saw the help too. Bug in doc and in software I guess. Should work with matrix, and parenthesis should be replaced in doc too.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 06, 2013, 02:46:23 am
O.O

(http://img.ourl.ca//polyfade.gif)

Code: [Select]
EXPORT POLYFADE()
BEGIN
DIMGROB_P(G1,320,240);
DIMGROB_P(G2,320,240);
BLIT_P(G1,G0);
WHILE 1 DO
FOR Z FROM 0 TO 255 STEP 1 DO
BLIT_P(G2,G1);
FILLPOLY_P(G2,{{0,0},{320,0},{320,240},{0,240}}, #FF0000, Z);
FILLPOLY_P(G2,{{Z,Z},{320,0},{320-Z,240-Z},{0,240}}, #00FFFF, Z);
BLIT_P(G0,G2);
WAIT(.25);
END;
END;
END;
Now we have over 9000 possibilities!

Judging by the speed (which is the same on a real calc), don't expect Super Mario 64 or Minecraft, though :P (although I bet that calling every polygon in a single list might be faster, considering Tim Wessman had an entire wireframe 3D graph with polygons rotating at 20 FPS. I'll have to try with a larger list)
Title: Re: FILLPOLY_P: Insufficient memory
Post by: TheMachine02 on December 06, 2013, 01:09:35 pm
 :o  this is epic. HP you've done a really good job with these function
Title: Re: FILLPOLY_P: Insufficient memory
Post by: Sorunome on December 07, 2013, 04:49:04 am
Wow, that's looking awesome O.O
Title: Re: FILLPOLY_P: Insufficient memory
Post by: Jim Bauwens on December 07, 2013, 09:31:44 am
EDIT : no sarcasm intended =(

It seems like I downrated you by mistake, sorry for that. Probably happened on my mobile phone (I have the same problem with for example like buttons, pressing them unknowingly).

It's nice to see that the Prime is getting some good upgrades :)
Title: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 07, 2013, 09:55:03 am
I have Tapatalk on mobile so I can't see ratings from there. :P

Also I tried this with a longer list and it didn't make a speed difference. I assume that complex shapes might be pretty fast if done from a single call. I need to investigate on the Triangle command, though, after seeing that Tim Wessman's 3D thing was done in a single call and ran at 20 FPS.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: Han on December 18, 2013, 03:00:52 pm
Could someone humor me and try running the same code (as posted) on the most recent emulator update (or even firmware)? For some reason it seems to go extremely slowly.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 18, 2013, 04:02:59 pm
I thought that the current firmware was the only one with FILLPOLY support? O.O (the first firmware didn't have triangle/polygon commands)

For me, in the current firmware (version 2013 11 25 Rev 5447), on a real calculator it runs as fast as in the screenshot above (smoother, actually, since the GIF is capped at 30 images per second). If I use multiple FILLPOLY_P commands in one loop, however, it starts being a bit slower (not super slow, though).
Title: Re: FILLPOLY_P: Insufficient memory
Post by: Han on December 18, 2013, 04:23:14 pm
When you say as fast as the screenshot, I presume you meant even with the WAIT(.25) in the source, yes? I have not soft-reset my calculator yet, but it appears that my calculator is very slow in rendering. Even with WAIT(.25) completely removed, it feels sluggish. I will see if I can record the difference.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 18, 2013, 04:39:21 pm
Nah, I only used the WAIT(.25) in the emulator because I couldn't find another way to make the emulator at the same speed as my calc. I removed the WAIT command on calc.

Could you make a video? I hope your calc isn't messed up or something.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: Han on December 18, 2013, 04:48:36 pm
Looks like what I thought was an issue is not, then. I thought I had taken out the WAIT(.25) but I did not. So on the calculator, it was super slow. Without it, it works about as fast as the screenshot.
Title: Re: FILLPOLY_P: Insufficient memory
Post by: DJ Omnimaga on December 18, 2013, 04:52:55 pm
Oh ok, phew. I'm glad to hear it was a mistake. I would hate if your calc became defective or something (for example, underclock itself to 20 MHz like the HP 39gII liked to do from time to time)