# Zooming in on specific point. (Translate and scale)

**URL:** https://discourse.processing.org/t/zooming-in-on-specific-point-translate-and-scale/12310
**Category:** Coding Questions
**Created:** [June 26, 2019, 3:42pm UTC](https://discourse.processing.org/t/zooming-in-on-specific-point-translate-and-scale/12310 "2019-06-26T15:42:43Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [July 3, 2019, 4:36am UTC](https://discourse.processing.org/t/zooming-in-on-specific-point-translate-and-scale/12310/6 "2019-07-03T04:36:12Z")

</div>

> [@Kiwipai](#):
>
> my center points seem to veer off towards the bottom right corner when I try to zoom in.  
> Is there a way to scale while keeping the center I translated to in the center?

yes. you need to break up your translate into two stages, and do the scaling between them, while the center of your coordinate system is still at 0,0.

1. translate(width/2, height/2);
2. scale(amt)
3. translate(-avgx, -avgy);

For a recent related discussion, see:

> [@How can I center an object on my screen that moves?](https://discourse.processing.org/t/how-can-i-center-an-object-on-my-screen-that-moves/12196/4):
>
> Understanding the relationship between translate, scale, and the idea of a 2D “camera” can sometimes be a bit tricky. It is worth reviewing the coordinate system and 2D transformations tutorials: [https://processing.org/tutorials/drawing/](https://processing.org/tutorials/drawing/)[https://processing.org/tutorials/transform2d/](https://processing.org/tutorials/transform2d/) However, in the end, there are three key transformations: translate to the center of the screen optionally scale the view, e.g. based on player speed or inter-player distance translate again to recenter the came…

---

_[View the full topic](https://discourse.processing.org/t/zooming-in-on-specific-point-translate-and-scale/12310)._
