onilink_ Modérateur
Messages : 9178 Localisation : Montpellier Projet Actuel : Planet Centauri
OniDev
| Sujet: [script] draw_toile Ven 19 Mar 2010 - 18:19 | |
| Bon aujourd'hui un petit script assez original qui va permettre de dessiner des toiles d'araignées. Petit screen : Fichier d'exemple : http://host-a.net/onilink_/toile.gm6Fonction : draw_toile(x, y, branches, fils, rayon, color1, color2) - Spoiler:
- Code:
-
var i, j, k, branches, toile, r, xx, yy; var x1, x2, y1, y2, bx1, by1, cx1, cx2, l, d, ccx, ccy, d1, d2, rr, n;
branches = max(1,argument2) toile = max(0,argument3) r = argument4 xx = argument0 yy = argument1 c1 = argument5 c2 = argument6
for(i=0 ; i<360 ; i+= 360/branches) { x1 = lengthdir_x(1,i) y1 = lengthdir_y(1,i) x2 = lengthdir_x(1,i+360/branches) y2 = lengthdir_y(1,i+360/branches) bx1 = x1*r by1 = y1*r draw_line_color(xx, yy, xx + x1*r*1.1, yy + y1*r*1.1,c1,c2) for(j=1 ; j<=toile ; j+=1) { cx1 = x1*j*r/toile cy1 = y1*j*r/toile cx2 = x2*j*r/toile cy2 = y2*j*r/toile l = point_distance(0, 0, cx1, cy1)*sqrt(3) d = i + 180/branches ccx = lengthdir_x(l,d) ccy = lengthdir_y(l,d) rr = point_distance(ccx, ccy, cx1, cy1) d1 = ceil(point_direction(ccx, ccy, cx1, cy1)) d2 = ceil(point_direction(ccx, ccy, cx2, cy2)) draw_set_color(merge_color(c1,c2,j/toile)) draw_primitive_begin(pr_linestrip) if(d1-d2 < 0) { n = 5 for(k = d2 ; k <= 360 ; k+=n) { draw_vertex(xx + ccx + lengthdir_x(rr,k),yy + ccy + lengthdir_y(rr,k)) if(k >= 360-5) n=1 } n = 5 for(k = 0 ; k <= d1 ; k+=n) { draw_vertex(xx + ccx + lengthdir_x(rr,k),yy + ccy + lengthdir_y(rr,k)) if(k >= d1-5) n=1 } } else { n = 5 for(k = d2 ; k <= d1 ; k+=n) { draw_vertex(xx + ccx + lengthdir_x(rr,k),yy + ccy + lengthdir_y(rr,k)) if(k >= d1-5) n=1 } } draw_primitive_end() } }
Infos : optimisation en cours... |
|
Mr_Twister Très bonne participation
Messages : 144 Localisation : (null) Projet Actuel : Aucun.
| Sujet: Re: [script] draw_toile Ven 19 Mar 2010 - 19:24 | |
| C'est quoi des : VERTEX _________________ Sup bro. |
|
Invité Invité
| Sujet: Re: [script] draw_toile Ven 19 Mar 2010 - 19:34 | |
| |
|
glcraft Utilisateur confirmé: Rang *****
Messages : 1698 Localisation : Entre l'Espagne, l'Italie, la Suisse, L'allemagne et le RU :P Projet Actuel : Jeu de survie avancé
||--------
| Sujet: Re: [script] draw_toile Ven 19 Mar 2010 - 21:23 | |
| belle effet ! |
|
medoc Très bonne participation
Messages : 162 Localisation : 91 Essonne (et j'en dirai pas plus ici ^^) Projet Actuel : F.A.D.W. ~ 15%
| Sujet: Re: [script] draw_toile Ven 19 Mar 2010 - 23:28 | |
| |
|
Kif12 Utilisateur confirmé: Rang *
Messages : 188
| Sujet: Re: [script] draw_toile Sam 20 Mar 2010 - 6:08 | |
| onilink_. j'aime tout tes topics ^^, sa montre que les mathématiques peuvent faire de très belle chose. |
|
Invité Invité
| |
medoc Très bonne participation
Messages : 162 Localisation : 91 Essonne (et j'en dirai pas plus ici ^^) Projet Actuel : F.A.D.W. ~ 15%
| Sujet: Re: [script] draw_toile Sam 20 Mar 2010 - 15:53 | |
| L'informatique est très belle invention de toute façon |
|
Contenu sponsorisé
| Sujet: Re: [script] draw_toile | |
| |
|