# Looking for function copyPixels

**URL:** <https://phaser.discourse.group/t/looking-for-function-copypixels/15547>\
**Category:** Phaser 3\
**Created:** [January 27, 2026, 1:54am UTC](https://phaser.discourse.group/t/looking-for-function-copypixels/15547 "2026-01-27T01:54:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kobaltic](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/kobaltic/32/9224_2.png) [@kobaltic](https://phaser.discourse.group/u/kobaltic)\
**Post date:** [January 27, 2026, 1:54am UTC](https://phaser.discourse.group/t/looking-for-function-copypixels/15547/1 "2026-01-27T01:54:58Z")

</div>

I created a project a decade ago. I am now updating to Phaser 3 and plan on adding new features. 😃 In Phaser 2.0.5 there was a function called copyPixels. I am trying to find out if this got removed or replaced with another function. This was the function  
`copyPixels: function (a, b, c, d) {`  
`“string” == typeof a && (a = this.game.cache.getImage(a)),`  
`a && this.context.drawImage(a, b.x, b.y, b.width, b.height, c, d, b.width, b.height),`  
`(this.dirty = !0);`  
`},`

Thanks

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 27, 2026, 2:16am UTC](https://phaser.discourse.group/t/looking-for-function-copypixels/15547/2 "2026-01-27T02:16:44Z")

</div>

There isn’t a Phaser 3 method exactly like the Phaser 2 `copyPixels()`. A replacement would be something like

```javascript
Phaser.Textures.CanvasTexture.prototype.copyPixels = function(
  source, 
  sourceRect, 
  destX, 
  destY
) {
  if (typeof source === 'string') {
    source = this.manager.get(source).getSourceImage();
  }

  this.context.drawImage(
    source,
    sourceRect.x,
    sourceRect.y,
    sourceRect.width,
    sourceRect.height,
    destX,
    destY,
    sourceRect.width,
    sourceRect.height
  );

  this.update();

  return this;
}

```

If you don’t need a source rectangle then you could use [drawFrame()](https://docs.phaser.io/api-documentation/class/textures-canvastexture#drawframe).

---

<div class="post-metadata">

**Author:** ![kobaltic](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/kobaltic/32/9224_2.png) [@kobaltic](https://phaser.discourse.group/u/kobaltic)\
**Post date:** [January 27, 2026, 1:08pm UTC](https://phaser.discourse.group/t/looking-for-function-copypixels/15547/3 "2026-01-27T13:08:38Z")

</div>

Thanks. I did figure this out before the post was allowed to be posted, as it was my first post. I found out a lot has changed and I am making those changes.
