# Transformations on a 2D view's indices?

**URL:** <https://discourse.julialang.org/t/transformations-on-a-2d-views-indices/31609>\
**Category:** General Usage\
**Tags:** question, images, arrays\
**Created:** [November 28, 2019, 6:38am UTC](https://discourse.julialang.org/t/transformations-on-a-2d-views-indices/31609 "2019-11-28T06:38:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ianshmean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ianshmean/32/216042_2.png) [@ianshmean](https://discourse.julialang.org/u/ianshmean)\
**Post date:** [November 28, 2019, 6:38am UTC](https://discourse.julialang.org/t/transformations-on-a-2d-views-indices/31609/1 "2019-11-28T06:38:25Z")

</div>

Is there a way to take a view on a 2D matrix, and do things like translate the indices, or even rotate the view? Say, something like this.

```julia
using ColorTypes, ImageView
x = zeros(RGBA, 1000, 1000)
v = view(x, 400:600, 400:600) #view to a square in the middle

rotate!(v, pi/3) #rotate the view indices 60º
translate!(v, (100, -10)) #translate the view indices in x by +100, y by -1

v .= RGBA(1.0, 0.0, 0.0, 1.0) #set the elements in the view to red

display(x) 
#shows a transparent image with a red square to the 
#right and bottom of center, that's rotated by 60º

```

Rotation would require going for the nearest indices per element.
