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

FabricJS - How to move a Line object one step down in the draw object stack?

WBOY
Release: 2023-09-10 14:01:11
forward
1176 people have browsed it

FabricJS – 如何将 Line 对象在绘制对象堆栈中向下移动一步?

In this tutorial, we will learn how to move a Line object one step down the draw object stack using FabricJS. Line element is one of the basic elements provided in FabricJS. It is used to create straight lines. Since line elements are geometrically one-dimensional and contain no interiors, they are never filled. We can create a line object by creating a fabric.Line instance, specifying the x and y coordinates of the line and adding it to the canvas. To move the Line object one step down the draw object stack, we use the sendBackwards method.

Syntax

 sendBackwards(intersecting: Boolean): fabric.Object 
Copy after login

Parameters

  • Intersect - This parameter accepts Boolean valuesWhen specified as a "true" value, the object will be sent behind the next lower intersecting object. If the value is "false", it normally sends the object after the next object on the stack. This parameter is optional.

Using the sendBackwards method

Example

Let’s look at a code example to see how to use the sendBackwards method time output. sendBackwards method moves the object one step down in the draw object stack. In this example, line2 is sent after line1 using the sendBackwards method.




   
   

Using sendBackwards method

You can see that line2 (red) has been moved down in the stack of drawn objects

Copy after login

Use the sendBackwards method and enable three objects and enable the intersection key

Example

In this example, we use three line objects, line1, line2 and line3. Although they have been added to the canvas in numerical order, line3 is clearly behind line1. This is because we are using the sendBackwards method with intersection key enabled, which sends line3 to its next lower intersection object (i.e. line1) later. p>




   
   

Using sendBackwards method with three objects and intersection key enabled

You can see that the green line now lies behind the blue line which is line number 1

Copy after login

The above is the detailed content of FabricJS - How to move a Line object one step down in the draw object stack?. 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!