Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

draw line in javascript

// Using Canvas
function draw() {
    const canvas = document.querySelector('#canvas');
    if (!canvas.getContext) {
        return;
    }
    // define variable 
    const ctx = canvas.getContext('2d');
    // set line stroke and line width
    ctx.strokeStyle = 'red';
    ctx.lineWidth = 5;
    // draw a red line
    ctx.beginPath();
    ctx.moveTo(100, 100);
    ctx.lineTo(300, 100);
    ctx.stroke();
}
draw();
Comment

PREVIOUS NEXT
Code Example
Javascript :: JavaScript Built-in Constructors 
Javascript :: how to make a rectangle in javascript 
Javascript :: javascript:void 
Javascript :: vertical align text canvas 
Javascript :: download canvas js 
Javascript :: jquery set width 
Javascript :: ngchange angular 8 
Javascript :: jquery select clear options 
Javascript :: node.js for windows 7 
Javascript :: javascript change dataset value 
Javascript :: decompile electron app 
Javascript :: nativescript absolutelayout bottom 
Javascript :: regex for company name 
Javascript :: find lowest number in array js 
Javascript :: auto closing parenthese not working on vscode 
Javascript :: random int javascript 
Javascript :: nodejs wait event loop to finish 
Javascript :: toast in react native 
Javascript :: jquery get request with headers 
Javascript :: get all links from html javascript 
Javascript :: JS retrieve a String’s size 
Javascript :: redirect with javascript 
Javascript :: Generate Random Whole Numbers within a Range 
Javascript :: on hover add class on children jquery 
Javascript :: search text in div jquery 
Javascript :: var_dump in javascript 
Javascript :: body click function removeclass 
Javascript :: javascript check if required 
Javascript :: js how to print 
Javascript :: select all checkbox jquery 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =