mercredi 17 octobre 2012

NCL2dLocation

- var location = new NCL2dLocation(x,y)


create a new NCL2dLocation object. 

-x : the x-coordinate of the location.

-y : the y-coordinate of the location.


Example: 

this.location = new NCL2dLocation(20,30);
alert("x="+this.location.x+"y="+this.location.y);

Object functions



NCL2dLocation.getLocation()

return an array with x and y coordinates.

example:
var coord = location.getLocation();
var x = coord[0];
var y = coord[1];



NCL2dLocation.setX(number)

set the x coordinate of the location

example: 
var location = new NCL2dLocation(10,10);
location.setX(30);


NCL2dLocation.setY(number)

set the y coordinate of the location

example: 
var location = new NCL2dLocation(10,10);
location.setY(30);


NCL2dLocation.toString()

return a string who represents the object. "[x:y]";

example: 
var location = new NCL2dLocation(10,10);
alert(location.toString());

mardi 16 octobre 2012

Curve

- Curve(location-origin,location-end,location-control)


Draw a Curve. 

- location-origin : the first point (NCL2dLocation object).

- location-end : the second point (NCL2dLocation object).
- location-control : the Bezier control point (Determine the curve) (NCL2dLocation object).


Example: 

this.setup = function()
{
   NCL = parent.NCL();
}
this.draw = function(scene)
{
   NCL.context.strokeStyle = "red";
   NCL.curve(
             new NCL2dLocation(10,10),
             new NCL2dLocation(50,50),
             new NCL2dLocation(20,15)
            );
}

Line

- Line(x,y,x1,y1)


Draw a Line. 

- x : the x-coordinate of the first point.
- y : the y-coordinate of the first point. 

- x : the x-coordinate of the second point.
- y : the y-coordinate of the second point. 


Example: 

this.setup = function()
{
   NCL = parent.NCL();
}
this.draw = function(scene)
{
   NCL.context.strokeStyle = "red";
   NCL.line(10,10,100,100);
}

Rect

- rect(x,y,width,height)


Draw a Rectangle. 

- x : the x-coordinate of the rectangle.
- y : the y-coordinate of the rectangle.
- width :  the width of the rectangle.
- height : the height of the rectangle. 



Example: 

this.setup = function()
{
   NCL = parent.NCL();
}
this.draw = function(scene)
{
   NCL.context.fillStyle = "red";
   NCL.rect(10,10,20,50);
}

Triangle

- Triangle(x,y,x1,y1,x2,y2)


Draw a Triangle. 

- x : the x-coordinate of the first point.
- y : the y-coordinate of the first point. 

- x1 : the x-coordinate of the second point.
- y1: the y-coordinate of the second point. 

- x2 : the x-coordinate of the third point.
- y2: the y-coordinate of the third point. 



Example: 

this.setup = function()
{
   NCL = parent.NCL();
}
this.draw = function(scene)
{
   NCL.context.fillStyle = "red";
   NCL.triangle(10,10,10,20,20,20);
}

Circle

- Circle(radius,x,y)


Draw a Circle. 

- x : the x-coordinate of the circle.
- y : the y-coordinate of the circle. 
- radius : the radius of the circle.

Example: 

this.setup = function()
{
   NCL = parent.NCL();
}
this.draw = function(scene)
{
   NCL.context.fillStyle = "red";
   NCL.circle(50,100,100);
}

Square

- Square(x,y,size)


Draw a Square. 
- x : the x-coordinate of the square.
- y : the y-coordinate of the square. 
- size : the size of the square.

Example: 

this.setup = function()
{
   NCL = parent.NCL();
}
this.draw = function(scene)
{
   NCL.context.fillStyle = "red";
   NCL.square(10,10,30);
}