KoctrX

Untitled

Jul 23rd, 2021
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. async rotateFrame(frameSprite, angle) {
  2. // //frameSprite = new PIXI.Sprite(_LIB.app.renderer.generateTexture(frameSprite));
  3. // // _LIB.download.imageByRender(frameSprite);
  4.  
  5. // // // const renderTexture = new PIXI.RenderTexture.create(frameSprite.width, frameSprite.height);
  6. // // // _LIB.app.renderer.render(frameSprite, renderTexture);
  7. // // // frameSprite = new PIXI.Sprite(renderTexture);
  8.  
  9. // // //_LIB.TextureManager.addT(frameSprite.texture, 'Frames-rotateFrame-frameSprite', true);
  10.  
  11. // return frameSprite;
  12. if (angle && !(angle % 90)) {
  13. const container = new PIXI.Container();
  14. container.addChild(frameSprite);
  15.  
  16. container.children[0].angle = angle;
  17. container.children[0].x = 0;
  18. container.children[0].y = 0;
  19.  
  20. let localBounds = container.getLocalBounds();
  21. container.children[0].x = localBounds.x * (localBounds.x < 0 ? -1 : 1);
  22. container.children[0].y = localBounds.y * (localBounds.y < 0 ? -1 : 1);
  23.  
  24. // frameSprite = new PIXI.Sprite(_LIB.app.renderer.generateTexture(container));
  25. // _LIB.TextureManager.addT(frameSprite.texture, 'Frames-rotateFrame-frameSprite', true);
  26.  
  27. //frameSprite = new PIXI.Sprite(new PIXI.Texture.fromBuffer(_LIB.app.renderer.extract.pixels(container), container.width, container.height));
  28.  
  29. frameSprite = new PIXI.Sprite((await _LIB.app.addToLoader(
  30. 'test' + Date.now(),
  31. _LIB.app.renderer.extract.base64(container))).texture
  32. );
  33.  
  34. if (frameSprite.width / frameSprite.height != _LIB.app.stage.width / _LIB.app.stage.height) {
  35. _LIB.watermark.remove(false, true);
  36. }
  37. /* frameSprite.angle += angle;
  38. frameSprite.position.set(frameSprite.width / 2, frameSprite.height / 2);
  39. frameSprite.pivot.set(frameSprite.width / 2, frameSprite.height / 2); */
  40. }
  41.  
  42. console.log('EXIT: ', frameSprite);
  43.  
  44. return frameSprite;
  45. }
Add Comment
Please, Sign In to add comment