Mandala drawing concept
How do I make an mandala drawing concept?
Based on Mandala penPerformance was improvedMirror functionality was added. What is a mandala drawing concept? How do you make a mandala drawing concept? This script and codes were developed by Massimo on 17 September 2022, Saturday.
Mandala drawing concept - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Mandala drawing concept</title> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<canvas id="c"></canvas> <script src='https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/dat.gui.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Mandala drawing concept - Script Codes CSS Codes
@import url("https://fonts.googleapis.com/css?family=Open+Sans");
body { margin: 0; overflow: hidden; background: #000;
}
body .dg.ac { transition: opacity .35s;
}
body .dg li.title { background-color: #1a1a1a;
}
body canvas { cursor: default;
}
body canvas:active ~ .dg.ac { opacity: .2; pointer-events: none;
}
body a { display: none;
}
body li, body .close-button { font-family: 'Open Sans', sans-serif; font-size: 14px; text-transform: capitalize;
}
Mandala drawing concept - Script Codes JS Codes
var c = document.getElementById('c'), link = document.createElement('a'), ctx = c.getContext('2d'), last = {x: null, y: null}, current = {x: null, y: null}, drawing = false, isMirror = false, cx, cy, r, angle, _2PI = 2*Math.PI, s = { 'sectors': 10, 'line width': 3, 'background': '#000', 'brush': '#00d1ff', 'mirror': false, 'clear': function() { resize(); }, 'save': function() { link.click(); } };
link.addEventListener('click', function() { link.href = c.toDataURL(); link.download = "mandala.png";
});
document.body.appendChild(link);
function resize() { c.width = window.innerWidth; c.height = window.innerHeight; cx = c.width/2; cy = c.height/2; r = Math.min(cx, cy) - 4; angle = _2PI/s.sectors; drawSectors(); ctx.translate(cx, cy);
}
resize();
window.addEventListener("resize", resize);
var gui = new dat.GUI(), col = gui.addFolder('Colors');
col.addColor(s, "background").onChange(resize);
col.addColor(s, "brush");
gui.add(s, "sectors", 2, 20, 1).onChange(resize);
gui.add(s, "line width", 1, 10, 1);
gui.add(s, "mirror").onChange(function() { isMirror = !isMirror;
});
gui.add(s, "clear");
gui.add(s, "save");
function drawSectors() { ctx.fillStyle = s.background; ctx.arc(cx, cy, r, 0, _2PI); ctx.fill(); for(var i=0; i<_2PI; i+=angle) { ctx.beginPath(); ctx.lineWidth = 1; ctx.strokeStyle = 'rgba(255, 255, 255, .15)'; ctx.moveTo(cx, cy); ctx.arc(cx, cy, r, i, i + angle); ctx.lineTo(cx, cy); ctx.stroke(); }
}
function d(x1, y1, x2, y2) { return Math.sqrt( Math.pow(x1-x2, 2) + Math.pow(y1-y2, 2) );
}
function reset() { drawing = false; last.x = null; last.y = null;
}
function draw(e) { if(drawing) { var x = e.touches ? e.touches[0].clientX : e.clientX, y = e.touches ? e.touches[0].clientY : e.clientY; x-= c.offsetLeft; y-= c.offsetTop; if(d(x, y, cx, cy) < r) { current.x = x - cx; current.y = y - cy; drawLine(); } else { reset(); } }
}
c.addEventListener('mousedown', function() { drawing = true;
});
c.addEventListener('touchstart', function() { drawing = true;
});
c.addEventListener('mousemove', draw);
c.addEventListener('touchmove', draw);
c.addEventListener('mouseup', reset);
c.addEventListener('touchend', reset);
function drawLine() { ctx.lineWidth = s['line width']; ctx.lineCap = 'round'; ctx.strokeStyle = s.brush; for(var i=0; i<_2PI; i+=angle) { ctx.rotate(angle); if(last.x != null && last.y != null) { ctx.beginPath(); ctx.moveTo(last.x, last.y); ctx.lineTo(current.x, current.y); if (isMirror) { ctx.moveTo(-last.x, last.y); ctx.lineTo(-current.x, current.y); } ctx.stroke(); } } last.x = current.x; last.y = current.y;
}
Developer | Massimo |
Username | _massimo |
Uploaded | September 17, 2022 |
Rating | 4.5 |
Size | 3,474 Kb |
Views | 30,360 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Underwater particles | 3,401 Kb |
Cat loader | 3,899 Kb |
Batman | 6,875 Kb |
Bernard the polar bear | 4,070 Kb |
Spinner | 3,072 Kb |
Record button | 4,905 Kb |
Melting ice cream | 3,839 Kb |
Css wave | 3,157 Kb |
Spinner | 3,015 Kb |
Css carousel | 2,977 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
A Pen by Rob Levin | Roblevin | 2,787 Kb |
Sticky notes with CSS3 | HaiNguyen007 | 2,146 Kb |
V.35 The Monolith Update - Hero Release Notes | Jordan | 12,045 Kb |
Sample Profile Screen | OurDailyBread | 5,375 Kb |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
Starting out with Ember.JS | Cfleschhut | 4,808 Kb |
SnappySnippet Test | Elmsoftware | 8,385 Kb |
Drifting Clouds | Benedikte | 2,247 Kb |
Bootstrap Carousel Fade Transition | Rowno | 2,484 Kb |
Simple jQuery Slider | Jurbank | 2,874 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!