HP Forums
RECT_P but without filling - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: RECT_P but without filling (/thread-5226.html)



RECT_P but without filling - hpfx - 11-27-2015 01:35 PM

Hi,
I tried to draw a rectangle, but without filling a color.
I didn't use the fillColor parameters but it fill with border color.

Code:

RECT_P(20,20,80,40,#DDDDDDh);

is there a tips for that ?
Thank you.


RE: RECT_P but without filling - DrD - 11-27-2015 02:46 PM

Code:

Export clr()
BEGIN  

  RECT;
  RECT_P(G0,130,90,190,110,#DDDDDDh,#FFFFFFFFh);    //  Rectangle, no fill
  RECT_P(G0,130,130,190,150,#DDDDDDh);              //  Rectangle, filled
  wait;

END;



RE: RECT_P but without filling - primer - 11-27-2015 03:18 PM

Hi,
(11-27-2015 02:46 PM)DrD Wrote:  RECT_P(G0,130,90,190,110,#DDDDDDh,#FFFFFFFFh); // Rectangle, no fill
It's not exactly "no fill", but "white filled."

For real "no fill", better to start on something like that :
Code:
RECT_P_NOFILL(x,y,x2,y2,col)
begin
 LINE_P(x,y,x2,y,col); //top
 LINE_P(x,y2,x2,y2,col); // bottom
 LINE_P(x,y,x,y2,col); //left
 LINE_P(x2,y,x2,y2,col); // right
end;
not very great, but it do the job.


RE: RECT_P but without filling - Tim Wessman - 11-27-2015 11:26 PM

(11-27-2015 03:18 PM)primer Wrote:  Hi,
(11-27-2015 02:46 PM)DrD Wrote:  RECT_P(G0,130,90,190,110,#DDDDDDh,#FFFFFFFFh); // Rectangle, no fill
It's not exactly "no fill", but "white filled."

Yes, it is "no fill". Specifically, a fill a a maximum alpha value. For more clarity:

RECT_P(10,10,50,50,RGB(35,45,55),RGB(0,0,0,255)); //fill will be completely transparent due to the last optional 4th alpha argument

No need for a custom function here.


RE: RECT_P but without filling - primer - 11-30-2015 09:04 AM

Indeed, I was wrong at counting the number of "F" Wink
but with RGB(0,0,0,255) (#FF000000h) it's clear, thanks.

helpfull tips !
Thanks.


RE: RECT_P but without filling - eried - 11-30-2015 03:33 PM

Both functions take almost the same time :O

Code:
RECT_P_NOFILL(x,y,x2,y2,col)
begin
 LINE_P(x,y,x2,y,col); //top
 LINE_P(x,y2,x2,y2,col); // bottom
 LINE_P(x,y,x,y2,col); //left
 LINE_P(x2,y,x2,y2,col); // right
end;

RECT_P_NO2FILL(x,y,x2,y2,col)
begin
 RECT_P(x,y,x+x2,y+y2,col,RGB(0,0,0,255));
end;

EXPORT test()
BEGIN
print();
local r,g,b,x,time1:=ticks;
FOR r FROM 1 TO 100 DO
FOR g FROM 1 TO 100 DO
FOR b FROM 1 TO 100 DO
FOR x FROM 1 TO 10 DO
RECT_P_NOFILL(x,x,10,50,RGB(r,g,b));
END;END;END;END;

print(ticks-time1);
time1:=ticks;
FOR r FROM 1 TO 100 DO
FOR g FROM 1 TO 100 DO
FOR b FROM 1 TO 100 DO
FOR x FROM 1 TO 10 DO
RECT_P_NO2FILL(x,x,10,50,RGB(r,g,b));
END;END;END;END;
print(ticks-time1);

END;



RE: RECT_P but without filling - Thomas_Sch - 11-30-2015 06:08 PM

Hello eried,
your code is calling RECT_P_NO2FILL 2 times. Or are I'm wrong?


RE: RECT_P but without filling - eried - 11-30-2015 06:28 PM

(11-30-2015 06:08 PM)Thomas_Sch Wrote:  Hello eried,
your code is calling RECT_P_NO2FILL 2 times. Or are I'm wrong?

Oh, you are right! that's why the performance was so similar, the routine using lines is much slower (62848 vs 48717 ticks)


RE: RECT_P but without filling - primer - 11-30-2015 08:42 PM

That's funny I made same kind of test, but I didn't test same thing as you.
I didn't think about colors, but about rectangle size.
I guess bigger rectangle may be slower.
here is my code, I'm varying the rect size.
Code:
RECT_P_NOFILL0(x,y,x2,y2,col);
RECT_P_NOFILL(x,y,x2,y2,col);

EXPORT test1()
BEGIN
local a,b;
local t;
RECT_P();
t:=TICKS;
 for a from 1 to 30
 do
  for b from 1 to 30
  do
// change comment here
     RECT_P_NOFILL(a+b*2,b+a*2,50+a*3+(b-15)*6,100+a*2+b*3,#0h);
//     RECT_P_NOFILL0(a+b*2,b+a*2,50+a*3+(b-15)*6,100+a*2+b*3,#0h);
  end;
 end;
t:=TICKS-t;
msgbox(t);
END;

RECT_P_NOFILL0(x,y,x2,y2,col)
begin
   RECT_P(x,y,x2,y2,col,#FFFFFFFFh);
end;

RECT_P_NOFILL(x,y,x2,y2,col)
begin
 LINE_P(x,y,x2,y,col); //top
 LINE_P(x,y2,x2,y2,col); // bottom
 LINE_P(x,y,x,y2,col); //left
 LINE_P(x2,y,x2,y2,col); // right
end;
results are :
* avg 313 for RECT
* avg 460 for LINEs
LINEs solution is about 50% slower than RECT.

Your bench show about 30% slower, in both case RECT is better.


RE: RECT_P but without filling - Han - 11-30-2015 09:55 PM

What about using the more advanced form of LINE_P?


RE: RECT_P but without filling - cyrille de brébisson - 12-01-2015 06:19 AM

Hello,

rect_p with a trensparent 'middle' will be drawn by 2 internal calls to h_line and 2 to v_line... it would be hard to be faster. In addition, it is also fast because there is little to no work needed to work on the input arguements...

line_p takes a whole lot more work to create the input as they are more complex.

Cyrille