Código de JavaScript - pincel lineal canvas

Requerimientos

Navegadores web compatibles, o posteriores obligatorio
Google Chrome 4.0
Internet Explorer/Edge 9.0
Firefox 2.0
Safari 3.1
Opera 9.0

Si es de tu ayuda y quieres aprender mas visita:
https://www.youtube.com/channel/UCWSKQyNDhvBVrddHIhzx5Zg?view_as=subscriber

0.8
estrellaestrellaestrellaestrellaestrella(3)

Actualizado el 5 de Diciembre del 2017 (Publicado el 24 de Septiembre del 2017)gráfica de visualizaciones de la versión: 0.8
2.350 visualizaciones desde el 24 de Septiembre del 2017
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<body>
<style type="text/css">
	*{
		margin: 0;
		padding: 0;
 
	}
	canvas{
		display: block;
		margin: auto;
	}
</style>
<script>
	window.onload = function(){
		var c = document.createElement("canvas");
		c.setAttribute("width", window.innerWidth);
    	c.setAttribute("height", window.innerHeight);
    	//c.setAttribute("style", "margin=auto");
    	lapiz("blue",4)
    	document.body.appendChild(c);
 
    	var ctx = c.getContext('2d');
    	var pintar;
    	function lapiz(color,tamaño){
    		c.onmousedown = function(e) {
    			ctx.moveTo(e.pageX - c.offsetLeft + tamaño, e.pageY - c.offsetTop);
				pintar = true;
			};
			c.onmousemove = function(e) {
				if (pintar) {
					ctx.lineTo(e.pageX - c.offsetLeft, e.pageY - c.offsetTop);
					ctx.lineWidth = tamaño;
					ctx.strokeStyle = color;
					ctx.stroke();
				}
			};
			c.onmouseup = function() {
				pintar = false;
			};
			c.onmouseout = function(){
				pintar = false;
			};
		}
 
	};
</script>
</body>
</html>



Comentarios sobre la versión: 0.8 (3)

Imágen de perfil
24 de Septiembre del 2017
estrellaestrellaestrellaestrellaestrella
No ha dejado ningún comentario
Responder
Imágen de perfil
5 de Diciembre del 2017
estrellaestrellaestrellaestrellaestrella
No ha dejado ningún comentario
Responder
Imágen de perfil
5 de Diciembre del 2017
estrellaestrellaestrellaestrellaestrella
No ha dejado ningún comentario
Responder

Comentar la versión: 0.8

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s4209