javascript - Draw More Arc Canvas -
hello people i'd know how draw more arc inside canvas, need draw circles:
so write responsive code make canvas responsive:
var mycanvas = document.getelementbyid('mycanvas'); var ctx = mycanvas.getcontext('2d'); var centerx = mycanvas.width / 2; var centery = mycanvas.height / 2; var borderwidth = 20; var bordercolor = '#2dc36a'; var radius = (mycanvas.width / 2) - (borderwidth / 2); // days arc canvas background ctx.beginpath(); ctx.arc(centerx, centery, radius, 0, 2 * math.pi, false); ctx.linewidth = borderwidth; ctx.strokestyle = bordercolor; ctx.stroke(); ctx.closepath(); // make canvas responsive function makeresponsive() { var containerwidth = $('.progress-nested').width(); $('.progress-nested').height(containerwidth); var canvaselements = ['#mycanvas']; $('#mycanvas').width(containerwidth).height(containerwidth); } makeresponsive(); // make canvas responsive in document ready $(window).resize(function () { makeresponsive(); // make canvas responsive in window resize });
#progress { width: 100%; padding: 5px; } .progress-nested{ position:relative; border-radius:50%; } canvas { display:block; position:absolute; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div id="progress"> <div class="container"> <div class="row"> <div class="col-xs-3 col-md-2 col-md-offset-2"> <div class="progress-nested"> <canvas id="mycanvas" width="250" height="250"></canvas> </div> </div> </div> </div> </div>
Comments
Post a Comment