.. role:: ts-api-decorator

####
Vec2
####

.. js:module:: cee
   :noindex:

.. container:: ts-api-section

   .. js:class:: Vec2

      An immutable 2d vector with x, y  values. 

      Used e.g. for texture coordinates



.. container:: api-index-section

   .. rubric:: Constructors

   .. rst-class:: api-index-list-item api-kind-constructor api-parent-kind-class

   * :js:meth:`~cee.Vec2.constructor`



.. container:: api-index-section

   .. rubric:: Properties

   .. rst-class:: api-index-list-item api-kind-property api-parent-kind-class

   * :js:attr:`~cee.Vec2.x`
   * :js:attr:`~cee.Vec2.y`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~cee.Vec2.equals`
   * :js:meth:`~cee.Vec2.getLength`
   * :js:meth:`~cee.Vec2.getLengthSquared`
   * :js:meth:`~cee.Vec2.getNegated`
   * :js:meth:`~cee.Vec2.getNormalized`
   * :js:meth:`~cee.Vec2.add`
   * :js:meth:`~cee.Vec2.dot`
   * :js:meth:`~cee.Vec2.from`
   * :js:meth:`~cee.Vec2.fromArray`
   * :js:meth:`~cee.Vec2.negate`
   * :js:meth:`~cee.Vec2.scale`
   * :js:meth:`~cee.Vec2.sub`





------------

Constructors
============

.. container:: ts-api-section

   .. js:function:: Vec2.constructor( x, y)

      :param x: None
      :type x: number
      :param y: None
      :type y: number


      Constructor


      :rtype: Vec2



Properties
==========

.. container:: ts-api-section

   .. js:attribute:: Vec2.x

      :type: number

      The x coordinate of the vector



.. container:: ts-api-section

   .. js:attribute:: Vec2.y

      :type: number

      The y coordinate of the vector



Methods
=======

.. rst-class:: ts-api-section

equals
------

.. js:method:: Vec2.equals( other)

   :param other: None
   :type other: Vec2Like


   Returns true if the vectors are equal


   :rtype: boolean

.. rst-class:: ts-api-section

getLength
---------

.. js:method:: Vec2.getLength()



   Returns the length of the vector (sqrt(x^2 + y^2)).


   :rtype: number

.. rst-class:: ts-api-section

getLengthSquared
----------------

.. js:method:: Vec2.getLengthSquared()



   Returns the squared length of the vector


   :rtype: number

.. rst-class:: ts-api-section

getNegated
----------

.. js:method:: Vec2.getNegated()



   Returns a negated version of the vector.


   :rtype: Vec2

.. rst-class:: ts-api-section

getNormalized
-------------

.. js:method:: Vec2.getNormalized()



   Returns a normalized version of the vector.


   :rtype: Vec2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` add
------------------------------

.. js:method:: Vec2.add( a, b)

   :param a: None
   :type a: Vec2Like
   :param b: None
   :type b: Vec2Like


   Returns the result of adding the two vectors


   :rtype: Vec2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` dot
------------------------------

.. js:method:: Vec2.dot( a, b)

   :param a: None
   :type a: Vec2Like
   :param b: None
   :type b: Vec2Like


   Returns the dot product of the 2 vectors


   :rtype: number

.. rst-class:: ts-api-section

:ts-api-decorator:`static` from
-------------------------------

.. js:method:: Vec2.from( vec)

   :param vec: None
   :type vec: Vec2Like


   Creates a new Vec2 instance from any object with x and y properties.


   :rtype: Vec2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` fromArray
------------------------------------

.. js:method:: Vec2.fromArray( arr)

   :param arr: None
   :type arr: ArrayLike <number>


   Creates a new Vec2 instance from the first 2 elements of the given array.


   :rtype: Vec2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` negate
---------------------------------

.. js:method:: Vec2.negate( vec)

   :param vec: None
   :type vec: Vec2Like


   Returns the negation of the given vector


   :rtype: Vec2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` scale
--------------------------------

.. js:method:: Vec2.scale( vec, factor)

   :param vec: None
   :type vec: Vec2Like
   :param factor: None
   :type factor: number


   Returns the result of scaling the given vector by the given factor


   :rtype: Vec2

.. rst-class:: ts-api-section

:ts-api-decorator:`static` sub
------------------------------

.. js:method:: Vec2.sub( a, b)

   :param a: None
   :type a: Vec2Like
   :param b: None
   :type b: Vec2Like


   Returns the result of subtracting vector b from vector a


   :rtype: Vec2

