Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
How to make a circle invisible using FabricJS?
In this tutorial, we are going to learn how to make a Circle invisible using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we have to create an instance of fabric.Circle class and add it to the canvas. Our circle object can be customized in various ways like changing its dimensions, adding a background color or by making it visible or invisible. We can do this by using the visible property.
Syntax
new fabric.Circle( { visible: Boolean }: Object)
Parameters
options (optional) ? This parameter is an Object which provides additional customizations to our circle. Using this parameter, properties such as colour, cursor, stroke width and a lot of other properties can be changed related to the object of which visible is a property.
Options Keys
visible ? This property accepts a Boolean value which allows us to render an object onto the canvas. Its default value is True.
Example 1
Passing visible property as key with a 'true' value
Let's see a code to understand what happens when we pass the visible property a True value. By assigning the value as 'true' we make sure that our Circle object is rendered onto the canvas. This is also the default behaviour in FabricJS.
Making a circle invisible using FabricJS
Here, the circle is visible because we have set visible to True. This is the default behavior. So, even if we don't apply the visible property, it will be set to True, by defalt.
Example 2
Passing visible property as key with a 'false' value
In this example, we are passing the visible property as key with a False value. Assigning a false value will make sure that our circle object does not get rendered onto the canvas. It simply does not make the object 'invisible' but gets rid of it altogether. It can be used to remove an object from canvas without removing its code.
Making a circle invisible using FabricJS
Notice that the circle is invisible here, as we have set visible to False.
