【pixijs】关于pixijs画圆

pixijs中画布原点在左上角,向右是x的正方向,向下是y的正方向(这点和数学坐标系相反)。

用到arc函数时突然短路,忘记0度是从9点方向还是3点方向了,各种坐标系搞晕了,写个文章记录下。

演练场:https://pixijs.com/8.x/playground

demo如下:

javascript 复制代码
import { Application, Assets, Container, Sprite, Graphics } from 'pixi.js';

(async () => {
  // Create a new application
  const app = new Application();

  // Initialize the application
  await app.init({ background: '#1099bb', resizeTo: window });

  // Append the application canvas to the document body
  document.body.appendChild(app.canvas);

  // Create and add a container to the stage
  const container = new Container();

  app.stage.addChild(container);

  const graphics = new Graphics();
  graphics
    .arc(0, 0, 50, 0, Math.PI / 5)
    .stroke({ width: 2, color: 'pink' });

  // Draw a full circle using an arc
  graphics
    .arc(100, 0, 30, 0, Math.PI * 2)
    .stroke({ color: 'red' });

  // Draw a counterclockwise arc
  graphics
    .arc(200, 0, 40, 0, Math.PI / 5, true)
    .stroke({ width: 2, color: 'green' });
  container.addChild(graphics);
  // Move the container to the center
  container.x = app.screen.width / 2;
  container.y = app.screen.height / 2;

  // Center the bunny sprites in local container coordinates
  container.pivot.x = container.width / 2;
  container.pivot.y = container.height / 2;


})();
相关推荐
esmap1 天前
OpenClaw与ESMAP AOA定位系统融合技术分析
前端·人工智能·计算机视觉·3d·ai·js
薛定谔的猫喵喵2 天前
猪笼草生长环境模拟器:交互式生物教育工具实现指南
python·html·echarts·js
esmap3 天前
Clawdbot与ESMAP数字孪生技术融合分析
人工智能·计算机视觉·3d·ai·js
共享家95273 天前
基于 Coze 工作流搭建历史主题图片生成器
前端·人工智能·js
xqqxqxxq7 天前
《智能仿真无人机平台(多线程 V4.0)技术笔记》(集群进阶:多无人机任务分配与碰撞规避)
笔记·无人机·cocos2d
27669582927 天前
美团 小程序 mtgsig
python·小程序·node·js·mtgsig1.2·美团小程序·大众点评小程序
xqqxqxxq9 天前
《智能仿真无人机平台(多线程V3.0)技术笔记》
笔记·无人机·cocos2d
xqqxqxxq12 天前
《智能仿真无人机平台(多线程V2.0)技术笔记》(线程进阶: 无人机自动防空平台开发教程)
笔记·无人机·cocos2d
boneStudent13 天前
基于STM32F745的完整无人机飞控系统
stm32·无人机·cocos2d
mqjFKmYf14 天前
电镀生产线组态王6.53仿真程序5带配套西门子S7-200PLC程序和IO表,带运行效果视频
cocos2d