Skip to content

Commit

Permalink
Solves #16
Browse files Browse the repository at this point in the history
  • Loading branch information
VBproDev committed Oct 11, 2024
1 parent 07a5480 commit eb2dd9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ function drawLines() {

function generateCode() {
const space = document.querySelector('.space');
const range = document.createRange();
const selection = window.getSelection();
let i = 0;
space.innerHTML = '';
space.innerHTML += `<div>const canvas = document.querySelector(\'canvas\');</div><div>const ctx = canvas.getContext(\'2d\');</div><div>ctx.beginPath();</div><div>ctx.strokeStyle = '#000000';</div><div>ctx.lineWidth = 1;</div>`
Expand Down Expand Up @@ -139,7 +141,9 @@ function generateCode() {
};
};
space.innerHTML += '<div>ctx.stroke();</div>';

selection.removeAllRanges();
range.selectNodeContents(space);
selection.addRange(range);
};

function resize(type, ...rest) {
Expand Down
2 changes: 1 addition & 1 deletion script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eb2dd9c

Please sign in to comment.