日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

在本教程中,我們將學習如何使用 FabricJS 禁用 Circle 的居中縮放。圓形是 FabricJS 提供的各種形狀之一。為了創建一個圓圈,我們必須創建一個 Fabric.Circle 類的實例并將其添加到畫布中。通過控件進行縮放時,為 centeredScaling 屬性分配一個真值,使用中心作為對象的變換原點。

語法

new fabric.Circle({ centeredScaling: Boolean }: Object)

登錄后復制

參數

    選項(可選) – 此參數是一個提供額外自定義的對象到我們的圈子。使用此參數,可以更改與centeredScaling屬性相關的對象的顏色、光標、描邊寬度等屬性

選項鍵

    centeredScaling – 此屬性接受布爾值價值。當此屬性為True時,對象使用中心作為變換原點。

    示例 1

    centeredScaling作為鍵傳遞并為其分配一個“true”值

    讓我們看一段代碼,看看圓形對象在centeredScaling時的行為

    em> 屬性已啟用。當我們放大對象時,變換的原點是圓心。

    <!DOCTYPE html>
    <html>
       <head>
          <!-- Adding the Fabric JS Library-->
          <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/510/fabric.min.js"></script>
       </head>
    
       <body>
          <h2>Disabling the centered scaling of circle using FabricJs</h2>
          <p>Select the object and stretch it by holding one of its controlling corners. You will notice the circle scales up uniformly from its center. This is the default behavior. Here we have not used the <b>centeredScaling</b> property but by default, it is set to True. </p>
          <canvas id="canvas"></canvas>
    
          <script>
             // Initiate a canvas instance
             var canvas = new fabric.Canvas("canvas");
             var cir = new fabric.Circle({
                left: 215,
                top: 100,
                fill: "white",
                radius: 50,
                stroke: "#c154c1",
                strokeWidth: 5,
                borderColor: "#daa520",
                centeredScaling: true
             });
    
             // Adding it to the canvas
             canvas.add(cir);
             canvas.setWidth(document.body.scrollWidth);
             canvas.setHeight(250);
          </script>
       </body>
    </html>

    登錄后復制

    示例 2

    禁用 centeredScaling 屬性

    我們可以通過為其指定一個 false 值來禁用 centeredScaling 屬性。它將迫使圓不再使用圓心作為變換中心。這是一個代碼來證明這一點

    <!DOCTYPE html>
    <html>
       <head>
          <!-- Adding the Fabric JS Library-->
          <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/510/fabric.min.js"></script>
       </head>
    
       <body>
          <h2>Disabling the centered scaling of circle using FabricJs</h2>
          <p>Select the object and stretch it by holding one of its controlling corners. You will notice that the circle is no longer scaling up uniformly from its center. Here we have used the <b>centeredScaling</b> property and set it False. </p>
          <canvas id="canvas"></canvas>
    
          <script>
             // Initiate a canvas instance
             var canvas = new fabric.Canvas("canvas");
             var circle = new fabric.Circle({
                left: 215,
                top: 100,
                fill: "",
                radius: 50,
                stroke: "#c154c1",
                strokeWidth: 5,
                borderColor: "#daa520",
                centeredScaling: false
             });
    
             // Adding it to the canvas
             canvas.add(circle);
             canvas.setWidth(document.body.scrollWidth);
             canvas.setHeight(250);
          </script>
       </body>
    </html>

    登錄后復制

    以上就是如何使用 FabricJS 禁用 Circle 的居中縮放?的詳細內容,更多請關注www.92cms.cn其它相關文章!

分享到:
標簽:FabricJS 如何使用 居中 禁用 縮放
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定