Create a path with moveTo
and lineTo
(live demo):
var ctx = canvas.getContext('2d');
ctx.fillStyle="#f00";
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(100,50);
ctx.lineTo(50, 100);
ctx.lineTo(0, 90);
ctx.closePath();
ctx.fill();
More Related Contents:
- HTML5 Canvas Resize (Downscale) Image High Quality?
- Simulation background-size: cover in canvas
- How to save image from canvas with CSS filters
- make canvas as wide and as high as parent
- Is there a way to curve / arc text using CSS3 / Canvas
- How to style canvas elements with CSS
- How to create a translucent in React Native?
- How to get an HTML element’s style values in javascript?
- Resize image with javascript canvas (smoothly)
- Refresh/reload the content in Div using jquery/ajax
- Change :hover CSS properties with JavaScript
- Animate element to auto height with jQuery
- Prevent zoom cross-browser
- Convert SVG to PNG with applied images as background to svg elements
- How can you figure out the highest z-index in your document?
- How to ensure a form field is submitted when it is disabled?
- Capture frames from video with HTML5 and JavaScript
- How to auto-scroll to end of div when data is added? [duplicate]
- Disable dragging an image from an HTML page
- javascript change background color on click [closed]
- Use a new CSS file to override current website’s
- CSS: Change parent on focus of child
- Possible to disable @media queries or force a resolution? Reason: Allow an iphone to see the desktop site?
- Check if element is between 30% and 60% of the viewport
- Fade background image in and out with jQuery?
- DIV Vertical Scroll bar on left
- Convert dropdown to selection boxes with color and trigger drop down action
- CSS /JS to prevent dragging of ghost image?
- Google’s Imageless Buttons
- How to apply background-color to a selected option?