Generador de polígonos fácil basado en JavaScript y Canvas-PolyGEN

Tiempo de ejecución: 30 minutos. Empezar

Autor: CameronSamuels
Views Total: 1,917
Sitio oficial: Ir a la web
Actualizado: October 4, 2018
Licencia: MIT

Vista prévia

Generador de polígonos fácil basado en JavaScript y Canvas-PolyGEN

Descripción

PolyGEN es una librería JavaScript muy simple que te permite dibujar polígonos altamente personalizables en un elemento canvas HTML5.

Funcionamiento

Inserte la versión minimizada de PolyGEN en la página HTML.

<script src="bin/polygen.min.js"></script>

Cree un elemento canvas HTML:

<canvas width="1024" height="1024"></canvas>

El ejemplo de JavaScript para dibujar un polígono personalizado en el elemento canvas.

//Declare canvas element
PolyGen.canvas = document.querySelector('canvas');

//Declare canvas context of the canvas element
PolyGen.context = PolyGen.canvas.getContext('2d');

//Declare the thickness of the lines of the shape
PolyGen.thickness = 8;

//Declare the color of the lines - it can be in any CSS color form (hex, rgb, rgba, name, etc)
PolyGen.color ='#2a2a2a';

//Declare the size of the shape - the radius
PolyGen.size = 2048;

//Create the shape by calling this function - replace 5 with the number of sides
PolyGen.create(5);

// or
 // Parameters: c = number of sides, a = canvas, m = canvas context,
// e = shape radius, r = shape border thickness, o = shape border color,
// n = shape x position , s = shape y position
PolyGen(c,a,m,e,r,o,n,s);

Registro de cambios

10/04/2018

  • Solo se permite el parámetro context

Te puede interesar: