<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<meta name="description" content="timeline" />
<meta charset=utf-8 />
<title>Avinash</title>
<style>
</style>
</head>
<body>
<canvas id="canvas">yyuygyyuytytttyytytytyyyy
hjvvvjyyu</canvas>
</body>
</html>
$(function() {
var canvas = $('canvas')[0];
var ctx = canvas.getContext('2d');
var w = canvas.width = 700;
var h = canvas.height = 400;
var x0 = w/2;
var starti=-10;
var endi=10;
var interval = 20;
var step = 2;
var steps = 5;
function drawOperation(x, step, steps){
drawPoint(x);
for(var i = 0; i < steps; i++){
drawCurve(x+i*step*interval,x+(i+1)*step*interval);
}
drawPoint(x+steps*step*interval);
}
canvas.addEventListener("mousedown", getPosition, false);
function drawPoint(x1){
ctx.beginPath();
ctx.arc(x1,h/2,2,0,2*Math.PI);
ctx.fill();
ctx.stroke();
}
function drawArc(p1,dir){
}
function getPosition(e){
var x = e.clientX;
var xe = x-x%interval+10;
if(x0===0){
drawPoint(xe);
x0=xe;
}
else{
drawPoint(xe);
drawCurve(x0,xe);
x0=xe;
}
}
function drawCurve(x1,x2){
ctx.moveTo(x1,h/2);
ctx.quadraticCurveTo(x1+(x2-x1)/2,h/2-Math.abs(x2-x1),x2,h/2);
var text;
var s = (x2 - x1)/interval;
if(s>0){
text="+" +s.toString();
}
else {
text = (x2 - x1)/interval;
}
ctx.fillText(text,x1+(x2-x1)/2,h/2-Math.abs(x2-x1)*0.5-10);
ctx.stroke();
}
with(ctx) {
fillStyle = '#FFFFFF';
fillRect(0, 0, w, h);
fill();
beginPath();
lineWidth = 2;
strokeStyle = '#f00';
moveTo(w/7, h/2);
lineTo(6*w/7, h/2);
stroke();
moveTo(w/7, h/2);
lineTo(w/7+10, h/2+10);
stroke();
moveTo(w/7, h/2);
lineTo(w/7+10, h/2-10);
stroke();
moveTo(6*w/7, h/2);
lineTo(6*w/7-10, h/2+10);
stroke();
moveTo(6*w/7, h/2);
lineTo(6*w/7-10, h/2-10);
stroke();
for(var i = starti;i <= endi; i++) {
beginPath();
strokeStyle = '#0f0';
lineWidth = 2;
moveTo(w/2 + i * interval, h/2 - 10);
lineTo(w/2 + i * interval, h/2 + 10);
fillStyle = '#0f0';
fillText(i, (w/2 + i * interval )- 5, h/2 + 25);
if(!i) {
strokeStyle = '#f0f';
}
fill();
stroke();
}
}
drawOperation(x0,step, steps);
});
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |