Home > Web Front-end > JS Tutorial > body text

How to disable selectivity of Triangle using FabricJS?

王林
Release: 2023-09-08 17:13:02
forward
1036 people have browsed it

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

In this tutorial, we will learn how to disable selectivity of triangles using FabricJS. Triangle is one of the various shapes provided by FabricJS. In order to create a triangle, we must create an instance of the Fabric.Triangle class and add it to the canvas.

In order to modify an object, we must select it in FabricJS. However, we can disable this behavior by using the selectable attribute.

Syntax

new fabric.Triangle{ selectable: Boolean }: Object)
Copy after login

Parameters

  • Options (optional) - This parameter is a Object< /em> Provides additional customization to our triangle. Using this parameter, you can change the properties of the object related to the selectable property, such as color, cursor, stroke width and many other properties.

  • < /ul>

    Option Key

    • Optional - This property accepts a Boolean value. When it is assigned a "false" value, the object cannot be selected for modification. Its default value is true.

    Example 1

    Default behavior or optional property when set to "true"< /p>

    Let's look at a code example to see how the object behaves by default when the selectable property is set to True. When the selectable property is set to True, we can select an object, move it around the canvas and modify it.

    
    
    
       
       
    
    

    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

    Copy after login

    Example 2

    Passing optional properties as keys

    In this example, we assign a False value to the optional properties. This means we can no longer select the triangle object for modification.

    
    
    
       
       
    
    

    Passing selectable property as key

    You can see that the triangle is no longer selectable

    Copy after login

    The above is the detailed content of How to disable selectivity of Triangle using FabricJS?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!