# IScalable

### Introduction

The IScalable interface provides an interface for 2D objects which can be resized. IScalable objects have two properties which control size:

* ScaleX
* ScaleY

Note: By default, scale has **nothing** to do with the Texture that an object is displaying. Two objects showing different Textures of different dimensions will be the same size if they have the same scale values.

### What is Scale?

Scale defines the distance from the center of an object to its edge. ![ScaleDiagram.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-adb8a985fff11acbe7569d21a64714d515581712%2Fmigrated_media-ScaleDiagram.png?alt=media) Scale values are used used instead of "width" and "height" because it simplifies collision and object placement. In other words, the following relationships exist:

```
ScaleX = Width / 2;
ScaleY = Height / 2;
```

OR

```
Width = ScaleX * 2;
Height = ScaleY * 2;
```

### Scale Example

The following code creates 3 [Sprites](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) with different scales.

```
 Sprite regularSizedSprite = SpriteManager.AddSprite("redball.bmp");
 regularSizedSprite.Y = 4;

 Sprite scaledOnXSprite = SpriteManager.AddSprite("redball.bmp");
 scaledOnXSprite.ScaleX = 3;

 Sprite scaledOnXAndYSprite = SpriteManager.AddSprite("redball.bmp");
 scaledOnXAndYSprite.Y = -7;
 scaledOnXAndYSprite.ScaleX = 3;
 scaledOnXAndYSprite.ScaleY = 3;
```

![ScaledSprites.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-052ebcbe7a2124df663df316bcd4d28891177223%2Fmigrated_media-ScaledSprites.png?alt=media)

### Scale is independent of Texture

The ScaleX and ScaleY values on objects such as Sprites is (by default) independent of the Sprite's [Texture property](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php). Therefore, if two Sprites both have the same ScaleX and ScaleY values, they will appear as the same size on screen regardless of the size of the Textures that they are displaying.

### Tutorials

* [Understanding the 3D Camera tutorial](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) - Information on Scale and it's relationship to on-screen size
* [Setting a Sprite to Pixel Size](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php#Setting_a_Sprite_to_Pixel_Size) - Shows how to set a Sprite's scale so that it appears the same dimensions as its source [Texture](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php).
* [Justifying IScalables](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php)

### More Information

* [FlatRedBall.Graphics.Model.PositionedModel.ScaleX](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) - Scale and PositionedModels.

### IScalable Members

* [FlatRedBall.Math.Geometry.IScalable.ScaleXVelocity](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php)
* [FlatRedBall.Math.Geometry.IScalable.ScaleYVelocity](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php)

Did this article leave any questions unanswered? Post any question in our [forums](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/forum.md) for a rapid response.
