Still have questions?
Contact support

# GraphicsJS Transformations

## Overview

GraphicsJS provides a convenient Transformations API that allows to move, scale, rotate and shear both elements and groups of elements. Transformations, in good hands, when used along with Layers, flexible Event Model and Virtual DOM, is a very powerful tool.

## Methods

The following methods allow you to work with transformation matrix, which is the fastest way to change elements, especially in groups:

The following sample demonstrates a shape drawn on a stage and the same shape with a transformation matrix set.

``````// add the transformation matrix
rect.setTransformationMatrix(1, 0.05, 1.5, 0.5, 1, 1);
``````

To change specific settings use:

The following sample demonstrates a triangle drawn on a stage and the same triangle with several transformation settings added.

``````// transform the triangle
transformedTriangle.setPosition(250, 15);
transformedTriangle.rotate(45, 300, 15);
transformedTriangle.scale(1.5, 0.5, 0, 50);
``````

To get the bounds, dimensions, and coordinates use:

These methods can be a great help when it is necessary to put an element somewhere corresponding to other elements or shapes. The following sample demonstrates the similar situation: here it is necessary to put a circle over a triangle in its center.

``````// get the triangle center point
triangleCenterX = triangle.getBounds().getLeft()+triangle.getBounds().getWidth()/2;
triangleCenterY = triangle.getBounds().getTop()+triangle.getBounds().getHeight()/2;

// create a circle
circle = stage.circle(triangleCenterX, triangleCenterY, 20);
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.6572705,"math_prob":0.96461034,"size":1843,"snap":"2019-26-2019-30","text_gpt3_token_len":409,"char_repetition_ratio":0.1636759,"word_repetition_ratio":0.042016808,"special_character_ratio":0.23331524,"punctuation_ratio":0.19269103,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98285425,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-07-18T23:26:21Z\",\"WARC-Record-ID\":\"<urn:uuid:d4ce035a-eff9-420c-8430-bc7fd02d2894>\",\"Content-Length\":\"55526\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:cdcef0f1-e631-4c34-948d-8463a7a518df>\",\"WARC-Concurrent-To\":\"<urn:uuid:c7eaa67b-8e94-4f63-a2cd-12310e247ac0>\",\"WARC-IP-Address\":\"104.236.66.244\",\"WARC-Target-URI\":\"https://docs.anychart.com/v8/Graphics/Transformations\",\"WARC-Payload-Digest\":\"sha1:UJYSSBOE6Y7DNKRQ7GSZY6JEULLD3MVG\",\"WARC-Block-Digest\":\"sha1:MRO5OALGQLRF6PRBO4N5C5UL67TOOIVL\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-30/CC-MAIN-2019-30_segments_1563195525863.49_warc_CC-MAIN-20190718231656-20190719013656-00044.warc.gz\"}"}