Fabric.js ActiveSelection strokeLineJoin Propiedad

Fabric.js es una biblioteca de JavaScript que se utiliza para trabajar con lienzo. El lienzo ActiveSelection es una de las clases de fabric.js que se usa para crear instancias de ActiveSelection . El lienzo ActiveSelection significa que ActiveSelection es móvil y se puede estirar según los requisitos. En este artículo, utilizaremos la propiedad strokeLineJoin .

Enfoque: primero importe la biblioteca fabric.js . Después de importar la biblioteca, cree un bloque de lienzo en la etiqueta del cuerpo que contendrá ActiveSelection. Después de esto, inicialice una instancia de la clase Canvas y ActiveSelection proporcionada por Fabric.JS y use la propiedad strokeLineJoin .

Sintaxis:

fabric.ActiveSelection(ActiveSelection, {
 strokeLineJoin : string
});

Parámetros: Esta función toma un solo parámetro como se mencionó anteriormente y se describe a continuación.

  • strokeLineJoin: este parámetro toma un valor de string.

Ejemplo: este ejemplo usa FabricJS para establecer la propiedad strokeLineJoin del lienzo ActiveSelection como se muestra en el siguiente ejemplo.

HTML

<!DOCTYPE html>
<html>
  
<head>
    <!-- FabricJS CDN -->
    <script src=
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">
    </script>
</head>
  
<body>
    <div style="text-align: center;width: 400px;">
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
  
        <b>
            Fabric.js | ActiveSelection strokeLineJoin Property
        </b>
    </div>
  
    <div style="text-align: center;">
        <canvas id="canvas" width="500" height="500"
            style="border:1px solid green;">
        </canvas>
    </div>
  
    <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200327230544/g4gicon.png"
        width="100" height="100"
        id="my-image" style="display: none;">
          
    <script>
        var canvas = new fabric.Canvas("canvas");
  
        // Initiate a Rect instance  
        var rectangle = new fabric.Rect({
            width: 200,
            height: 100,
        });
        canvas.add(rectangle);
  
        var geek = new fabric.IText('GeeksforGeeks', {
        });
        canvas.add(geek);
        canvas.centerObject(geek);
  
        var gfg = new fabric.ActiveSelection(canvas.getObjects(), {
            stroke: 'red',
            strokeLineJoin: 'bevel',
            strokeWidth: 9
        })
        canvas.setActiveObject(gfg);
        canvas.requestRenderAll();
        canvas.centerObject(gfg);
  
    </script>
</body>
  
</html>

Producción:

Publicación traducida automáticamente

Artículo escrito por dheerchanana08 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *