Post Reply 
RECT_P but without filling
11-27-2015, 01:35 PM
Post: #1
RECT_P but without filling
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.
Find all posts by this user
Quote this message in a reply
11-27-2015, 02:46 PM (This post was last modified: 11-27-2015 02:46 PM by DrD.)
Post: #2
RE: RECT_P but without filling
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;
Find all posts by this user
Quote this message in a reply
11-27-2015, 03:18 PM
Post: #3
RE: RECT_P but without filling
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.

primer
Find all posts by this user
Quote this message in a reply
11-27-2015, 11:26 PM (This post was last modified: 11-27-2015 11:33 PM by Tim Wessman.)
Post: #4
RE: RECT_P but without filling
(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.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
11-30-2015, 09:04 AM
Post: #5
RE: RECT_P but without filling
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.

primer
Find all posts by this user
Quote this message in a reply
11-30-2015, 03:33 PM (This post was last modified: 11-30-2015 06:29 PM by eried.)
Post: #6
RE: RECT_P but without filling
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;

My website: erwin.ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
11-30-2015, 06:08 PM
Post: #7
RE: RECT_P but without filling
Hello eried,
your code is calling RECT_P_NO2FILL 2 times. Or are I'm wrong?
Find all posts by this user
Quote this message in a reply
11-30-2015, 06:28 PM
Post: #8
RE: RECT_P but without filling
(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)

My website: erwin.ried.cl
Visit this user's website Find all posts by this user
Quote this message in a reply
11-30-2015, 08:42 PM
Post: #9
RE: RECT_P but without filling
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.

primer
Find all posts by this user
Quote this message in a reply
11-30-2015, 09:55 PM
Post: #10
RE: RECT_P but without filling
What about using the more advanced form of LINE_P?

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
12-01-2015, 06:19 AM
Post: #11
RE: RECT_P but without filling
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

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)