[Request] drawing a dinamic line
07-10-2014, 06:03 PM (This post was last modified: 07-10-2014 06:30 PM by fabila.)
Post: #1
 fabila Junior Member Posts: 25 Joined: Dec 2013
[Request] drawing a dinamic line
I'm trying to draw a diameter of a circle, and rotate by dragging your finger on the screen,
How to do a single line it looks? I tried but that rect(G2) after blit(G2) but erases the background

Code:
 export Mes() BEGIN     LOCAL m,m1,m2,mx,my,mxi,myi,A;   RECT(RGB(252,252,200));         DIMGROB_P(G2,340,240,RGB(252,252,200,128));         DIMGROB_P(G3,340,240,RGB(252,252,200,128));       ARC_P(G3,160,105,85,0,360); blit(G3); WHILE MOUSE(1)≥0 DO END; REPEAT     REPEAT         m:=MOUSE;         m1:=B→R(m(1));         m2:=B→R(m(2));              UNTIL SIZE(m1)>0;              mx:=m1(1);         my:=m1(2);         mxi:=m1(3);         myi:=m1(4);     if m1(5)==#2d then  A:=(mx-mxi); END;          LINE_P(G2,161+85*COS(A),106+85*SIN(A),161-85*COS(A),106-85*SIN(A),RGB(0,0,255));         TEXTOUT_P(A,G2,20,208,2,RGB(255,0,0));   BLIT(G2); UNTIL my>220 ; END;
07-10-2014, 07:41 PM
Post: #2
 eried Senior Member Posts: 745 Joined: Dec 2013
RE: [Request] drawing a dinamic line
For your example, fastest way is just redrawing the last line over with the background color.

My website: ried.cl
07-10-2014, 07:58 PM
Post: #3
 fabila Junior Member Posts: 25 Joined: Dec 2013
RE: [Request] drawing a dinamic line
(07-10-2014 07:41 PM)eried Wrote:  For your example, fastest way is just redrawing the last line over with the background color.
the problem is that if redraw using blit (G3) in the last line, the screen flickers while dragging your finger with a very ugly effect.
07-10-2014, 08:21 PM
Post: #4
 eried Senior Member Posts: 745 Joined: Dec 2013
RE: [Request] drawing a dinamic line
Well, you can use G0 and/or a condition to avoid unnecessary redraws:

Code:
export Mes() BEGIN   LOCAL m,m1,m2,mx,my,mxi,myi,A;   LOCAL p1:=0,p2:=0,p3:=0,p4:=0,o1:=-1,o2:=-1,o3:=-1,o4:=-1;   RECT(RGB(252,252,200));   DIMGROB_P(G2,340,240,RGB(252,252,200,128));   DIMGROB_P(G3,340,240,RGB(252,252,200,128));   ARC_P(G3,160,105,85,0,360);   blit(G3);    WHILE MOUSE(1)≥0 DO END; REPEAT   REPEAT     m:=MOUSE;     m1:=B→R(m(1));     m2:=B→R(m(2));        UNTIL SIZE(m1)>0;      mx:=m1(1);   my:=m1(2);   mxi:=m1(3);   myi:=m1(4);      if m1(5)==#2d then  A:=(mx-mxi); END;      p1:=161+85*COS(A);   p2:=106+85*SIN(A);   p3:=161-85*COS(A);   p4:=106-85*SIN(A);      if p1<>o1 then     LINE_P(G0,o1,o2,o3,o4,RGB(252,252,200));     LINE_P(G0,p1,p2,p3,p4,RGB(0,0,255));     o1:=p1;o2:=p2;o3:=p3;o4:=p4;   end;   //TEXTOUT_P(A,G0,20,208,2,RGB(255,0,0));   //BLIT(G2); UNTIL my>220 ; END;

My website: ried.cl
07-10-2014, 09:23 PM
Post: #5
 fabila Junior Member Posts: 25 Joined: Dec 2013
RE: [Request] drawing a dinamic line
thank you very much for the code, just what I needed

Habia intentado el volver a dibujar la recta de color del fondo pero me faltaba el condicional muchas gracias.
 « Next Oldest | Next Newest »

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