Comunidad de diseño web y desarrollo en internet online

Dibujar curvas (función raíz cuadrada)

Citar            
MensajeEscrito el 26 Nov 2005 02:58 pm
¿Cómo puedo dibujar una curva "y=a*sqrt(x)" mediante AS?

Por Zah

BOFH

4290 de clabLevel

27 tutoriales
5 articulos

  Bastard Operators From Hell Editores

Zaragoza, España

firefox
Citar            
MensajeEscrito el 26 Nov 2005 04:40 pm
Fijate si te gusta este.

Código :

//-------------TAMAÑO DE LA PANTALLA-----------------
_global.ancho_de_pantalla = Stage.width
_global.alto_de_pantalla = Stage.height


//-------------HACEMOS LOS DEBERES-----------------
this.createEmptyMovieClip("funcion_parametrica_mc", 1); //creamos el mc con profundidad 1
funcion_parametrica_mc.lineStyle(5, 0xFF00FF, 100); // Estilo de la linea que vamos a dibujar

function sqr(y:Number) { 
 return Math.pow(y, 3); 
}

//------------VALORES INICIALES----------------
cantidad_de_puntos = 51
puntoinicial = - 50
escala = 500
i = puntoinicial


/// A dibujar se a dicho!!!
for (i=puntoinicial; i<cantidad_de_puntos; i++) { 

// esta es la funcion en forma parametrica
   valordey = (alto_de_pantalla / 2) - sqr(i) /escala
   valordex = (ancho_de_pantalla / 2) + i *2  
// ----------------------------------------------------

// nos paramos en donde va el primer punto
if (i == puntoinicial) { funcion_parametrica_mc.moveTo(valordex, valordey); }

// tiramos la linea entre el punto actual hasta el punto nuevo
funcion_parametrica_mc.lineTo(valordex, valordey);

}

Por afterawer

14 de clabLevel



Genero:Masculino  

Neuquen

firefox
Citar            
MensajeEscrito el 26 Nov 2005 05:39 pm
Mira aqui, a lo mejor te sirve de ayuda.


^^ ruuuuuuuuuuuuu

Por Gengis

27 de clabLevel



 

Córdoba(España)

firefox
Citar            
MensajeEscrito el 26 Nov 2005 10:04 pm
Gracias pero no pude entender ni adaptar tu código y ya había visto este post con similares resultados :oops: ... así que hice mi propia función: :P

Código :

var endY:Number = -24;
var factor:Number = 2;
createEmptyMovieClip("func", 1);
func.lineStyle(1, 0xFF0000, 100);
var bucle:Number = 0;
var currentX:Number = 0;
while (bucle>endY) {
   bucle = -factor*Math.sqrt(currentX);
   func.lineTo(currentX-1, bucle);
   currentX++;
}

Por Zah

BOFH

4290 de clabLevel

27 tutoriales
5 articulos

  Bastard Operators From Hell Editores

Zaragoza, España

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.