10 examples of 'how to make a circle in javascript' in JavaScript

Every line of 'how to make a circle in javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
90function Circle(radius)
91{
92 this.radius = radius;
93}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

44function circle(x, y, r) {
45 ctx.beginPath();
46 ctx.arc(x, y, r, 0, Math.PI * 2, true);
47 ctx.stroke();
48}
38function Circle(x, y, r) {
39 this.x = x;
40 this.y = y;
41 this.r = r;
42
43 Circle.prototype.draw = function() {
44 for (var i = 0; i < this.r; i += density) {
45 ellipse(this.x, this.y, i);
46 }
47 };
48}
64function addCircle( x, y, deg, cx, cy )
65{
66 color = "0x000000";
67 if ( cx > 24 && cx < 57 && cy > 9 && cy < 15
68 && dreamirl[ cy - 10 ][ cx - 25 ] )
69 {
70 color = "0xFF0000";
71 }
72 var circle = new DE.GameObject( {
73 "x": x, "y": y
74 } );
75 var box = new DE.GameObject( {
76 x: 50
77 ,renderer: new DE.RectRenderer( {
78 fillColor : color
79 ,width : 20
80 , height : 20
81 } )
82 } );
83 circle.rotate( deg / 10 );
84 circle.addAutomatism( "move", "rotate", { value1: 0.04 } );
85 circle.add( box );
86 Game.scene.add( circle );
87}
40function addCircle() {
41 var c = document.createElement('div');
42 c.style = 'position: absolute; top: 203px; left: 628px; width: 100px; height: 100px; z-index: 200; border-radius: 50%; transform: scale(1); background: maroon;';
43 c.id = 'hypno';
44 document.body.appendChild(c);
45}
54function generateSomeCircle( howManyCircle ) {
55 for ( var counter = 0; counter < howManyCircle; counter++ ) {
56 circles.push( generateRandomCircle( counter ) );
57 }
58}
257function Circle(pos, r) {
258 this['pos'] = pos || new Vector();
259 this['r'] = r || 0;
260 this['offset'] = new Vector();
261}
69function makeCircle() {
70 var positions = [];
71 var indices = [];
72 var numVertices = 24;
73 for (var ii = 0; ii < numVertices; ++ii) {
74 var angle = ii * Math.PI * 2 / numVertices;
75 positions.push(Math.cos(angle), Math.sin(angle));
76 };
77 for (var ii = 1; ii < numVertices; ++ii) {
78 indices.push(0, ii, (ii + 1) % numVertices);
79 }
80 var arrays = {
81 position: new tdl.primitives.AttribBuffer(2, positions),
82 indices: new tdl.primitives.AttribBuffer(3, indices, 'Uint16Array'),
83 };
84 var textures = {
85 };
86 var program = tdl.programs.loadProgramFromScriptTags(
87 "screenVertexShader", "screenFragmentShader");
88 return new tdl.models.Model(program, arrays, textures);
89}
303function putCircle(id) {
304 $.ajax({
305 url: "http://localhost:5000/circles/" + id,
306 headers: {'Authorization': 'Bearer ' + token},
307 type: 'PUT',
308 dataType: 'json',
309 success: function(data) {
310 console.log(data);
311 }
312 });
313}
43function Circle(px, py, pr) {
44 this.x = px;
45 this.y = py;
46 this.r = pr;
47
48 this.update = function() {
49 noFill();
50 stroke(0);
51 ellipse(this.x, this.y, this.r, this.r);
52 }
53}

Related snippets