Post Reply 
Elastic Grids
12-14-2013, 04:59 PM (This post was last modified: 12-18-2013 08:10 PM by Damien.)
Post: #1
Elastic Grids
Hi everyone,

Suppose we have a rubber grid...

This code gives to the grid a kind of magnify effect.
Code:

EXPORT Quadrillages164()
BEGIN
 LOCAL DI,ANg,NX,NY,XI,YI;
 RECT_P(#383838h);
 HAngle:=0;
 FOR L:=0 TO 1 DO  // L=0 vertical line, L=1 horizontal lines
  FOR I:=0 TO 20 DO // Lines
   FOR J:=0 TO 20 DO // segments of each lines
    X:=I/10-1; Y:=J/10-1;
    IF L==1 THEN 
     T:=X; X:=Y; Y:=T;
    END;
    DI:=√(X²+Y²);
    IF X<>0 THEN 
     ANg:=ATAN(Y/X) 
    ELSE 
     ANg:=π/2*SIGN(Y); 
    END;
    IF X<0 THEN 
     ANg:=ANg+π; 
    END;
    IF DI<1 THEN 
     DI:=DI^.4; // <--- try to change DI value 
    END;
    XI:=120+IP(119*DI*COS(ANg)); 
    YI:=120+IP(119*DI*SIN(ANg));
    IF J==0 THEN 
     NX:=XI; NY:=YI; 
    END;
    IF J>0 THEN 
     LINE_P(NX,NY,XI,YI,#E8B800h); 
     NX:=XI; NY:=YI; 
    END;
   END;
  END;
 END;
WAIT(-1);
END;

Or a kind of rotation effect.
Code:

EXPORT Quadrillages166()
BEGIN
 RECT_P(#383838h);
 LOCAL DI,ANg,NX,NY,XI,YI;
 FOR L:=0 TO 1 DO
  FOR I:=0 TO 20 DO
   FOR J:=0 TO 20 DO
    X:=I/10-1; Y:=J/10-1;
    IF L==1 THEN 
     T:=X; X:=Y; Y:=T;
    END;
    DI:=√(X²+Y²);
    IF X<>0 THEN 
     ANg:=ATAN(Y/X) 
    ELSE 
     ANg:=π/2*SIGN(Y); 
    END;
    IF X<0 THEN 
     ANg:=ANg+π; 
    END;
    IF DI<1 THEN 
     ANg:=ANg+π/2*(DI-1); // <---
    END;
    XI:=120+IP(119*DI*COS(ANg)); 
    YI:=120+IP(119*DI*SIN(ANg));
    IF J==0 THEN 
     NX:=XI; NY:=YI; 
    END;
    IF J>0 THEN 
     LINE_P(NX,NY,XI,YI,#E8B800h); 
     NX:=XI; NY:=YI; 
    END;
   END;
  END;
 END;
WAIT(-1);
END;
Or some kind of twist.
Replace
Code:
IF D1<1 THEN ....
By
Code:

IF DI<1 THEN 
 ANg:=ANg-π/4*SIN(2*π*(DI-1));
END;

Or try to change the loops like so:
Code:
 
 FOR L:=0 TO 0 DO
  FOR I:=0 TO 20 DO
   FOR J:=0 TO 40 DO
    X:=I/10-1; Y:=J/20-1;
     .
     .
    IF DI<1 THEN 
     ANg:=ANg-π*2*(DI-1);
    END;


Cheers,

Damien.
Find all posts by this user
Quote this message in a reply
12-18-2013, 06:29 PM
Post: #2
RE: Elastic Grids
Very nice!!!!

Waiting for more... Wink
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: