亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.430618.com 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

在本教程中,我們將學(xué)習(xí)如何使用 FabricJS 禁用 Ellipse 的居中縮放。橢圓形是 FabricJS 提供的各種形狀之一。為了創(chuàng)建一個(gè)橢圓,我們必須創(chuàng)建一個(gè) Fabric.Ellipse 類的實(shí)例并將其添加到畫布中。通過(guò)控件進(jìn)行縮放時(shí),為 centeredScaling 屬性分配“true”值,使用中心作為對(duì)象的變換原點(diǎn)。

語(yǔ)法

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

登錄后復(fù)制

參數(shù)

    選項(xiàng)(可選)- 此參數(shù)是一個(gè)對(duì)象 為我們的橢圓提供額外的定制。使用此參數(shù),可以更改與 centeredScaling 屬性相關(guān)的對(duì)象的顏色、光標(biāo)、描邊寬度和許多其他屬性。

    選項(xiàng)鍵

      centeredScaling – 此屬性接受布爾值 值。當(dāng)此屬性為True時(shí),對(duì)象使用中心作為變換原點(diǎn)。

      示例 1

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

      以下示例演示了橢圓對(duì)象在centeredScaling時(shí)的行為方式屬性已啟用。當(dāng)我們放大對(duì)象時(shí),變換的原點(diǎn)是橢圓的中心。

      <!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>How to disable the centered scaling of Ellipse using FabricJS?</h2>
            <p>Select the object and stretch it from its corners. The ellipse will scale up from its center. This is the default behavior.</p>
            <canvas id="canvas"></canvas>
      
            <script>
               // Initiate a canvas instance
               var canvas = new fabric.Canvas("canvas");
      
               // Initiate an ellipse instance
               var ellipse = new fabric.Ellipse({
                  left: 215,
                  top: 100,
                  fill: "white",
                  rx: 90,
                  ry: 50,
                  stroke: "#c154c1",
                  strokeWidth: 5,
                  borderColor: "#daa520",
                  centeredScaling: true,
               });
      
               // Adding it to the canvas
               canvas.add(ellipse);
               canvas.setWidth(document.body.scrollWidth);
               canvas.setHeight(250);
            </script>
         </body>
      </html>

      登錄后復(fù)制

      示例 2

      禁用 centeredScaling 屬性

      我們可以通過(guò)為其指定“false”值來(lái)禁用 centeredScaling 屬性。這將不再使用橢圓的中心作為變換中心。這是一個(gè)代碼,用于演示 –

      <!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>How to disable the centered scaling of Ellipse using FabricJS?</h2>
            <p>Select the object and stretch it from its corners. You will notice the object scales up but not from its center because we have set <b>centeredScaling</b> as False. </p>
            <canvas id="canvas"></canvas>
      
            <script>
               // Initiate a canvas instance
               var canvas = new fabric.Canvas("canvas");
      
               // Initiate an ellipse instance
               var ellipse = new fabric.Ellipse({
                  left: 215,
                  top: 100,
                  fill: "",
                  rx: 90,
                  ry: 50,
                  stroke: "#c154c1",
                  strokeWidth: 5,
                  borderColor: "#daa520",
                  centeredScaling: false,
               });
      
               // Adding it to the canvas
               canvas.add(ellipse);
               canvas.setWidth(document.body.scrollWidth);
               canvas.setHeight(250);
            </script>
         </body>
      </html>

      登錄后復(fù)制

      以上就是如何使用 FabricJS 禁用 Ellipse 的居中縮放?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!

分享到:
標(biāo)簽:FabricJS 如何使用 居中 禁用 縮放
用戶無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定