Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BELOW CODE ADDED BY AGLOVALE.NEKOWEB.ORG */
- let colors = ["black", "white", "lightgrey", "crimson", "orange", "gold", "lightgreen",
- "cyan", "royalblue", "mediumorchid", "violet", "pink"];
- function changeColor(e){
- let id = e.id;
- if (id){
- id = id.replace('hash-code-', '#');
- }
- updateQueue(id);
- }
- function updateQueue(c){
- stroke_color = c;
- if (colors.includes(c)){
- colors = colors.filter(function(color) {
- return color !== c;
- });
- } else {
- colors.pop();
- }
- colors.unshift(c);
- renderColor();
- }
- function renderColor(){
- let container = document.getElementById('drawbox-stroke-colors');
- container.textContent = '';
- colors.forEach((c) => {
- let color = document.createElement('div');
- color.setAttribute('onclick', 'changeColor(this)');
- color.setAttribute('style',`background:${c}`);
- color.setAttribute('id', c.replace('#','hash-code-'));
- color.setAttribute('class', 'stroke-color');
- container.appendChild(color);
- });
- }
- renderColor();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement