Finished empty rectangle tool

This commit is contained in:
unsettledgames
2020-03-07 16:49:01 +01:00
parent 2024ddced6
commit 30282fe795
6 changed files with 76 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
//draw a line between two points on canvas
function line(x0,y0,x1,y1) {
function line(x0,y0,x1,y1, brushSize) {
var dx = Math.abs(x1-x0);
var dy = Math.abs(y1-y0);
@@ -10,7 +10,7 @@ function line(x0,y0,x1,y1) {
while (true) {
//set pixel
// If the current tool is the brush
if (currentTool == 'pencil') {
if (currentTool == 'pencil' || currentTool == 'rectangle') {
// I fill the rect
currentLayer.context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize);
} else if (currentTool == 'eraser') {