Fabric.js ActiveSelection strokeMiterLimit Propiedad

Fabric.js es una biblioteca de JavaScript que se utiliza para trabajar con lienzo. El lienzo ActiveSelection pertenece a la clase de fabric.js que se utiliza para crear instancias de ActiveSelection. El lienzo ActiveSelection significa que ActiveSelection se puede mover y se puede estirar según los requisitos. En este artículo usaremos la propiedad strokeMiterLimit.

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 strokeMiterLimit.

Sintaxis:

fabric.ActiveSelection(ActiveSelection, {
    strokeMiterLimit : number
});

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

  • strokeMiterLimit: este parámetro toma un valor numérico.

Ejemplo: este ejemplo usa FabricJS para establecer la propiedad strokeMiterLimit 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 strokeMiterLimit 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: 'miter',
            strokeMiterLimit: 10,
            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 *