Class

# Point

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

## Description

An object used to represent and work with a given <span class="title-ref">Point</span> in the coordinate system.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name         | Type                             | Read-Only | Shared |
|--------------|----------------------------------|-----------|--------|
| `X<point.x>` | `Double</api/data_types/double>` |           |        |
| `Y<point.y>` | `Double</api/data_types/double>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                              | Parameters                                                                             | Returns                          | Shared |
|-----------------------------------|----------------------------------------------------------------------------------------|----------------------------------|--------|
| `Clone<point.clone>`              |                                                                                        | Point                            |        |
| `Constructor<point.constructor0>` |                                                                                        |                                  |        |
| `Constructor<point.constructor1>` | X As `Double</api/data_types/double>`, Y As `Double</api/data_types/double>`           |                                  |        |
| `DistanceTo<point.distanceto>`    | other As Point                                                                         | `Double</api/data_types/double>` |        |
| `Translate<point.translate>`      | deltaX As `Double</api/data_types/double>`, deltaY As `Double</api/data_types/double>` |                                  |        |

## Property descriptions

<div id="point.x">

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

</div>

<div class="rst-class">

forsearch

</div>

Point.X

**X** As `Double</api/data_types/double>`

> The horizontal coordinate of the <span class="title-ref">Point</span>.
>
> This code is in the MouseDown event handler. The new mouseposition is passed as the X,Y coordinates and mouseoffset is a property of the window.
>
> ``` xojo
> ' Update our mouse position.
> mouseposition = New Point(x, y)
>
> ' Now we determine which rect our cursor is in
> ' and save the offset (how far the cursor is inside the rect)
> ' so when the user moves the cursor, the rect
> ' won't jump around.
> If rectone.Contains(mouseposition) Then
>   mouseoffset.X = rectone.Origin.X - mouseposition.X
>   mouseoffset.Y = rectone.Origin.Y - mouseposition.X
>   draggingrect = rectone
> ElseIf recttwo.Contains(mouseposition) Then
>   mouseoffset.X = recttwo.Origin.X - mouseposition.X
>   mouseoffset.Y = recttwo.Origin.Y - mouseposition.Y
>   draggingrect = recttwo
> Else
>   mouseoffset.X = 0
>   mouseoffset.Y = 0
>   draggingrect = Nil
> End If
>
> ' refresh, without erasing the background
> Me.Refresh(False)
> Return True
> ```

<div id="point.y">

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

</div>

<div class="rst-class">

forsearch

</div>

Point.Y

**Y** As `Double</api/data_types/double>`

> The vertical coordinate of the <span class="title-ref">Point</span>.
>
> This code is in the MouseDown event handler. The new mouseposition is passed as the X,Y coordinates and mouseoffset is a property of the window.
>
> ``` xojo
> ' Update our mouse position.
> mouseposition = New Point(x, y)
>
> ' Now we determine which rect our cursor is in
> ' and save the offset (how far the cursor is inside the rect)
> ' so when the user moves the cursor, the rect
> ' won't jump around.
> If rectone.Contains(mouseposition) Then
>   mouseoffset.X = rectone.Origin.X - mouseposition.X
>   mouseoffset.Y = rectone.Origin.Y - mouseposition.X
>   draggingrect = rectone
> ElseIf recttwo.Contains(mouseposition) Then
>   mouseoffset.X = recttwo.Origin.X - mouseposition.X
>   mouseoffset.Y = recttwo.Origin.Y - mouseposition.Y
>   draggingrect = recttwo
> Else
>   mouseoffset.X = 0
>   mouseoffset.Y = 0
>   draggingrect = Nil
> End If
>
> ' refresh, without erasing the background
> Me.Refresh(False)
> Return True
> ```

## Method descriptions

<div id="point.clone">

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

</div>

<div class="rst-class">

forsearch

</div>

Point.Clone

**Clone** As Point

> Creates a duplicate of the <span class="title-ref">Point</span>.
>
> This example is in the MouseDrag event of a `Rect</api/graphics/rect>`. The object is being cloned as the way to update its position.
>
> ``` xojo
> ' Update our mouse position.
> mousePosition = New Point(x, y)
>
> ' If we're actually dragging something, move the rect.
> ' We update the rect's origin with a CLONE of the mouse position,
> ' because MousePosition is an instance of the Point class.
> ' Without the clone, when we call the offset function, we'll also update
> ' the MousePosition property, since both DraggingRect.Origin and MousePosition
> ' would point to the same variable.
>
> ' The offset function shifts the rect. Positive for right/down,
> ' negative for left/up.
>
> If draggingrect <> Nil Then
>   DraggingRect.Origin = Mouseposition.Clone
>   DraggingRect.Offset(MouseOffset.x, MouseOffset.y)
> End If
>
> ' refresh, without erasing the background
> Me.Refresh(False)
> ```

<div id="point.constructor0">

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

</div>

<div class="rst-class">

forsearch

</div>

Point.Constructor

**Constructor**

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.
>
> </div>
>
> Creates a <span class="title-ref">Point</span> at position (0, 0).

<div id="point.constructor1">

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

</div>

<div class="rst-class">

forsearch

</div>

Point.Constructor

**Constructor**(X As `Double</api/data_types/double>`, Y As `Double</api/data_types/double>`)

> Creates a basic <span class="title-ref">Point</span> with the passed coordinates.
>
> Create a <span class="title-ref">Point</span> at 100, 50:
>
> ``` xojo
> Var p As New Point(100, 50)
> ```

<div id="point.distanceto">

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

</div>

<div class="rst-class">

forsearch

</div>

Point.DistanceTo

**DistanceTo**(other As Point) As `Double</api/data_types/double>`

> Calculates the distance between the <span class="title-ref">Point</span> and the passed <span class="title-ref">other</span> Point.
>
> ``` xojo
> Var thePoint As Point = DraggingRect.Origin
> Var d As Double = thePoint.DistanceTo(RectTwo.Origin)
> ```

<div id="point.translate">

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

</div>

<div class="rst-class">

forsearch

</div>

Point.Translate

**Translate**(deltaX As `Double</api/data_types/double>`, deltaY As `Double</api/data_types/double>`)

> Moves the <span class="title-ref">Point</span> the given number of pixels. Positive numbers move the <span class="title-ref">Point</span> down or to the right, negative move it up or to the left.
>
> This example is in the MouseDrag event of a `Rect</api/graphics/rect>`. The object is being cloned as the way to update its position. MouseOffset is a <span class="title-ref">Point</span> property of the window.
>
> ``` xojo
> ' Update our mouse position.
> mouseposition = New Point(x, y)
>
> ' If we're actually dragging something, move the rect.
> ' We update the rect's origin with a CLONE of the mouse position,
> ' because MousePosition is an instance of the Point class.
> ' Without the clone, when we call the offset function, we'll also update
> ' the MousePosition property, since both DraggingRect.Origin and MousePosition
> ' would point to the same variable.
>
> ' The offset function shifts the rect. Positive for right/down,
> ' negative for left/up.
>
> If draggingrect <> Nil Then
>   draggingrect.Origin = mouseposition.Clone
>   draggingrect.Offset(mouseoffset.X, mouseoffset.Y)
> End If
>
> ' refresh, without erasing the background
> Me.Refresh(False)
> ```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

Object parent class; `DesktopCanvas</api/user_interface/desktop/desktopcanvas>` control; `DesktopWindow</api/user_interface/desktop/desktopwindow>`, `DesktopContainer</api/user_interface/desktop/desktopcontainer>`, `Rect</api/graphics/rect>`, `Size</api/graphics/size>` classes.

</div>
