Fabric.js 旋转角度 angle

JavaScript/前端
443
0
0
2022-11-08
标签   JavaScript库

旋转角度 angle

Fabric.js 旋转角度 angle

<template> 
  <div> 
    <canvas width="500" height="500" id="canvas" style="border: 1px solid #ccc;"></canvas> 
  </div>
</template>

<script setup>
import { onMounted } from 'vue'
import { fabric } from 'fabric'

function init() {
  const canvas = new fabric.Canvas('canvas')

  let triangle = new fabric.Triangle({
    top: 100,
    left: 100,
    width: 80,
    height: 100,
    fill: 'blue',
    angle: 30 // 旋转30度
  })

  canvas.add(triangle)
}

onMounted(() => {
  init()
})
</script>