Maison > interface Web > js tutoriel > le corps du texte

如何使用 FabricJS 禁用 Triangle 的选择性?

王林
Libérer: 2023-09-08 17:13:02
avant
1036 人浏览过

如何使用 FabricJS 禁用 Triangle 的选择性?

在本教程中,我们将学习如何使用 FabricJS 禁用三角形的选择性。三角形是 FabricJS 提供的各种形状之一。为了创建一个三角形,我们必须创建一个 Fabric.Triangle 类的实例并将其添加到画布中。

为了修改一个对象,我们必须在 FabricJS 中选择它。但是,我们可以通过使用 selectable 属性来禁用此行为。

语法

new fabric.Triangle{ selectable: Boolean }: Object)
Copier après la connexion

参数

  • 选项(可选) - 此参数是一个对象< /em> 为我们的三角形提供额外的定制。使用此参数,可以更改与selectable属性相关的对象的属性,例如颜色、光标、描边宽度和许多其他属性。

  • < /ul>

    选项键

    • 可选择 - 此属性接受布尔值。当为其分配“假”值时,无法选择该对象进行修改。其默认值为 true。

    示例 1

    默认行为或可选属性设置为“true”时< /p>

    让我们看一个代码示例,以了解默认情况下 selectable 属性设置为 True 时对象的行为方式。当 selectable 属性设置为 True 时,我们可以选择一个对象,在画布上移动它并对其进行修改。

    
    
    
       
       
    
    

    Default behaviour or when selectable property is set to 'true'

    You can try moving the triangle around the canvas or scaling it to prove that it's selectable

    Copier après la connexion

    示例 2

    将可选属性作为键传递

    在此示例中,我们为可选属性分配一个 False 值。这意味着我们无法再选择三角形对象进行修改。

    
    
    
       
       
    
    

    Passing selectable property as key

    You can see that the triangle is no longer selectable

    Copier après la connexion

    以上是如何使用 FabricJS 禁用 Triangle 的选择性?的详细内容。更多信息请关注PHP中文网其他相关文章!

source:tutorialspoint.com
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!