Canvas Radar
How do I make an canvas radar?
What is a canvas radar? How do you make a canvas radar? This script and codes were developed by Jack Rugile on 11 August 2022, Thursday.
Canvas Radar - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Canvas Radar</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body { background: #111 url(/images/classy_fabric.png); overflow: hidden;
}
#bg { background: radial-gradient(hsla(0, 0%, 0%, 0), hsla(0, 0%, 0%, 1)); height: 100%; left: 0; position: absolute; width: 100%;
}
#radar { background: linear-gradient(#333, #111); box-shadow: 0 0 0 1px hsla(0, 0%, 0%, 0.5), inset 0 0 0 1px hsla(0, 0%, 100%, 0.15) ; padding: 14px; border-radius: 100%; display: block; left: 50%; position: absolute; top: 50%;
}
canvas { background: radial-gradient(#222, #111); border-radius: 100%; display: block;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="bg"></div>
<div id="radar"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://rawgithub.com/soulwire/sketch.js/master/js/sketch.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Canvas Radar - Script Codes CSS Codes
body { background: #111 url(/images/classy_fabric.png); overflow: hidden;
}
#bg { background: radial-gradient(hsla(0, 0%, 0%, 0), hsla(0, 0%, 0%, 1)); height: 100%; left: 0; position: absolute; width: 100%;
}
#radar { background: linear-gradient(#333, #111); box-shadow: 0 0 0 1px hsla(0, 0%, 0%, 0.5), inset 0 0 0 1px hsla(0, 0%, 100%, 0.15) ; padding: 14px; border-radius: 100%; display: block; left: 50%; position: absolute; top: 50%;
}
canvas { background: radial-gradient(#222, #111); border-radius: 100%; display: block;
}
Canvas Radar - Script Codes JS Codes
var radar = document.getElementById( 'radar' ),
diameter = 220,
radius = diameter / 2,
padding = 14,
ctx = Sketch.create({ container: radar, fullscreen: false, width: diameter, height: diameter
}),
dToR = function( degrees ){ return degrees * (Math.PI / 180);
},
sweepAngle = 270,
sweepSize = 2,
sweepSpeed = 1.2,
rings = 4,
hueStart = 120,
hueEnd = 170,
hueDiff = Math.abs( hueEnd - hueStart ),
saturation = 50,
lightness = 40,
lineWidth = 2,
gradient = ctx.createLinearGradient( radius, 0, 0, 0 );
radar.style.marginLeft = radar.style.marginTop = ( -diameter / 2 ) - padding + 'px';
gradient.addColorStop( 0, 'hsla( ' + hueStart + ', ' + saturation + '%, ' + lightness + '%, 1 )' );
gradient.addColorStop( 1, 'hsla( ' + hueEnd + ', ' + saturation + '%, ' + lightness + '%, 0.1 )' );
var renderRings = function(){ var i; for( i = 0; i < rings; i++ ){ ctx.beginPath(); ctx.arc( radius, radius, ( ( radius - ( lineWidth / 2) ) / rings) * ( i + 1 ), 0, TWO_PI, false ); ctx.strokeStyle = 'hsla(' + ( hueEnd - ( i * ( hueDiff / rings ) ) ) + ', ' + saturation + '%, ' + lightness + '%, 0.1)'; ctx.lineWidth = lineWidth; ctx.stroke(); };
};
var renderGrid = function(){ ctx.beginPath(); ctx.moveTo( radius - lineWidth / 2, lineWidth ); ctx.lineTo( radius - lineWidth / 2, diameter - lineWidth ); ctx.moveTo( lineWidth, radius - lineWidth / 2 ); ctx.lineTo( diameter - lineWidth, radius - lineWidth / 2 ); ctx.strokeStyle = 'hsla( ' + ( ( hueStart + hueEnd ) / 2) + ', ' + saturation + '%, ' + lightness + '%, .03 )'; ctx.stroke();
};
var renderSweep = function(){ ctx.save(); ctx.translate( radius, radius ); ctx.rotate( dToR(sweepAngle) ); ctx.beginPath(); ctx.moveTo( 0, 0 ); ctx.arc( 0, 0, radius, dToR( -sweepSize ), dToR( sweepSize ), false ); ctx.closePath(); ctx.fillStyle = gradient; ctx.fill(); ctx.restore();
};
var renderScanLines = function(){ var i; var j; ctx.beginPath(); for( i = 0; i < diameter; i += 2 ){ ctx.moveTo( 0, i + .5 ); ctx.lineTo( diameter, i + .5); }; ctx.lineWidth = 1; ctx.strokeStyle = 'hsla( 0, 0%, 0%, .02 )'; ctx.globalCompositeOperation = 'source-over'; ctx.stroke();
};
ctx.clear = function(){ ctx.globalCompositeOperation = 'destination-out'; ctx.fillStyle = 'hsla( 0, 0%, 0%, 0.1 )'; ctx.fillRect( 0, 0, diameter, diameter );
};
ctx.update = function(){ sweepAngle += sweepSpeed;
};
ctx.draw = function(){ ctx.globalCompositeOperation = 'lighter'; renderRings(); renderGrid(); renderSweep(); renderScanLines();
};
Developer | Jack Rugile |
Username | jackrugile |
Uploaded | August 11, 2022 |
Rating | 4 |
Size | 3,074 Kb |
Views | 74,888 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Fade and Blur on Hover Data Table | 3,399 Kb |
Canvas Parallax Skyline | 4,871 Kb |
Abstract Canvas Visualization | 3,459 Kb |
CSS3 Pseudo Sound Bars | 2,400 Kb |
Develop Denver Logo | 3,813 Kb |
Canvas Orbital Trails | 3,697 Kb |
Rainbow Loader | 2,022 Kb |
Glowing Pulse Form | 2,542 Kb |
Rainbow Grid | 2,760 Kb |
Canvas Sparkly Circle Loader | 2,446 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Spin | Elalemanyo | 8,262 Kb |
Arrow Navigation | Hinducows | 1,973 Kb |
Loading animation with css | Icebob | 2,947 Kb |
Slider | Mohammed-fawzy | 2,634 Kb |
Blog | Rottingroom | 1,430 Kb |
Content Changer | Cliffpyles | 4,538 Kb |
Scoreboard.js basic usage | Tbleckert | 1,733 Kb |
Matrix | Stathisnikolaidis | 1,922 Kb |
Flexbox Grid - equal height | DaveOrDead | 2,855 Kb |
OnScreenAction | Ozgursagiroglu | 2,647 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!