Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/02/2010, 14:13
Silver
 
Fecha de Ingreso: noviembre-2001
Ubicación: México DF
Mensajes: 128
Antigüedad: 24 años, 9 meses
Puntos: 0
De acuerdo Respuesta: Coordenadas de un rectángulo

Este es el código en AS3, por si alguien lo necesita:

Código PHP:
// coordenadas iniciales
var startP:Point = new Point(150,150);
var 
endP:Point = new Point(180,210);
var 
slop:Point = new Point(startP.x - endP.x, startP.y - endP.y);
var 
length:Number = Math.sqrt(slop.x * slop.x + slop.y * slop.y);
var 
slopVector:Point = new Point(slop.x/length, slop.y/length);
var 
rHeight:int = 5; // altura del rectángulo
var offset:Point = new Point(rHeight * slop.y / length, rHeight * -slop.x / length); 

// obteniendo los 4 puntos para el dibujo
var topLeft:Point = new Point(startP.x - offset.x, startP.y - offset.y);
var 
bottomLeft:Point = new Point(startP.x + offset.x, startP.y + offset.y);
var 
topRight:Point = new Point(endP.x - offset.x, endP.y - offset.y);
var 
bottomRight:Point = new Point(endP.x + offset.x, endP.y + offset.y); 

// dibujando el rectángulo
var shape:Shape = new Shape();
shape.graphics.lineStyle(1,0x000000);
shape.graphics.beginFill(0xFF0000);
shape.graphics.moveTo(topLeft.x, topLeft.y);
shape.graphics.lineTo(topRight.x, topRight.y);
shape.graphics.lineTo(bottomRight.x, bottomRight.y);
shape.graphics.lineTo(bottomLeft.x, bottomLeft.y);
shape.graphics.lineTo(topLeft.x, topLeft.y);
shape.graphics.endFill();
addChild(shape); 
__________________
Nuedi Servicios SA de CV
http://www.nuedi.mx