LightBulb
How do I make an lightbulb?
What is a lightbulb? How do you make a lightbulb? This script and codes were developed by Darryl Huffman on 07 January 2023, Saturday.
LightBulb - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>LightBulb</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
LightBulb - Script Codes CSS Codes
body { margin: 0; padding: 0; overflow:hidden; background-color: #222;
}
LightBulb - Script Codes JS Codes
// Config Variables
var cw = window.innerWidth, ch = window.innerHeight, shapex, shapey, cs = cw / 60, // Cube Size entities = {}, entitiesIndex = 0, bgcolor = "#222", entitieAmount = 90, canvas = $('<canvas/>').attr({width: cw, height: ch, id: "myCanvas"}).appendTo('body'), context = canvas.get(0).getContext("2d");
// End Config Variables
// Color Variables
var c1 = "transparent", c2 = "#ffff00", c3 = "#ffff79", c4 = "#bbbbbb";
// End Color Variables
// Entity Layout
var shapeProperty = [ [c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1], [c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1], [c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1], [c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1], [c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1], [c1,c1,c1,c1,c1,c3,c1,c1,c1,c1,c1], [c3,c1,c1,c1,c1,c3,c1,c1,c1,c1,c3], [c1,c3,c1,c1,c1,c3,c1,c1,c1,c3,c1], [c1,c1,c3,c1,c1,c1,c1,c1,c3,c1,c1], [c1,c1,c1,c1,c1,c1,c1,c1,c1,c1,c1], [c1,c1,c1,c1,c2,c2,c2,c1,c1,c1,c1], [c1,c1,c2,c2,c3,c3,c3,c2,c2,c1,c1], [c1,c2,c3,c3,c3,c3,c3,c3,c3,c2,c1], [c2,c3,c3,c3,c3,c3,c3,c3,c3,c3,c2], [c2,c3,c3,c3,c3,c3,c3,c3,c3,c3,c2], [c2,c3,c3,c3,c3,c3,c3,c3,c3,c3,c2], [c2,c3,c3,c3,c3,c3,c3,c3,c3,c3,c2], [c1,c2,c3,c3,c3,c3,c3,c3,c3,c2,c1], [c1,c2,c3,c3,c3,c3,c3,c3,c3,c2,c1], [c1,c1,c2,c3,c3,c3,c3,c3,c2,c1,c1], [c1,c1,c1,c2,c3,c3,c3,c2,c1,c1,c1], [c1,c1,c1,c2,c3,c3,c3,c2,c1,c1,c1], [c1,c1,c1,c2,c3,c3,c3,c2,c1,c1,c1], [c1,c1,c1,c4,c4,c4,c4,c4,c1,c1,c1], [c1,c1,c1,c4,c4,c4,c4,c4,c1,c1,c1], [c1,c1,c1,c4,c4,c4,c4,c4,c1,c1,c1], [c1,c1,c1,c1,c4,c4,c4,c1,c1,c1,c1]
];
var lgth = 0;
var longest;
for(var i=0; i < shapeProperty.length; i++){ if(shapeProperty[i].length > lgth){ var lgth = shapeProperty[i].length; longest = shapeProperty[i]; }
}
console.log(lgth);
// End Entity Layout
// Create Entity Object
function spawnEntity(shapex, shapey, shapevx, shapevy, lgth){ entitiesIndex++; this.id = entitiesIndex; this.width = cs; this.height = cs; entities[entitiesIndex] = this; this.color = shapex; this.y = ch + Math.floor((Math.random() * 1500) + 1); this.vy = -50; this.shapex = shapex; this.shapey = shapey; this.shapevx = shapevx; this.shapevy = shapevy;
}
//End Creating entity Object
// Entity Dawing Pramiters
spawnEntity.prototype.draw = function(){ this.y += this.vy; this.width = cs + 1; this.height = cs + 1; this.x = ((this.shapevx * cs) + (cw / 2)) - ((lgth * cs) / 2); this.toy = this.shapevy * cs; context.fillStyle = this.color; if(this.y <= this.toy){ this.y = this.toy; this.vy = 0; } context.fillRect(this.x,this.y,this.width,this.height);// Position and size object
};
// End Entity Drawing Peramiters
// For loop to spawn objects
for(var y = 0; y < shapeProperty.length; y++) { // Loop through rows in the var shape = shapeProperty[y]; // Grab the current row for(var x = 0; x < shape.length; x++) { // Loop through columns in the row new spawnEntity(shape[x], shape[y], x, y); }
}
// End for loop to spawn objects
// Draw Entity
setInterval(function(){ context.fillStyle = bgcolor; context.fillRect(0,0,cw,ch); for(var i in entities){ entities[i].draw(); }
}, 30);
// End Drawing
Developer | Darryl Huffman |
Username | darrylhuffman |
Uploaded | January 07, 2023 |
Rating | 3.5 |
Size | 2,561 Kb |
Views | 8,096 |
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 |
Spilled Galaxy | 2,163 Kb |
Math | 2,495 Kb |
Followers Solar System | 6,724 Kb |
Fur | 2,938 Kb |
Hot Arrrr Balloon. | 2,755 Kb |
Let it snow, let it snow, code the snow. | 2,884 Kb |
BLACKHOLE - A Canvas Experiment | 3,676 Kb |
Orbit | 3,173 Kb |
A Perfect Orbit | 3,411 Kb |
Simple SVG Charts | 6,694 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 |
Shop Talk logo made in CSS | Hugo | 19,368 Kb |
Simple animated hover effect | Pobee-norris | 3,044 Kb |
Process Accordion | Devilskitchen | 31,432 Kb |
Twinkling Stars | Ripley6811 | 2,750 Kb |
Border-radius animation | Yukulele | 2,480 Kb |
A cube | KyleDavidE | 18,627 Kb |
Scroll Arrow | Robooneus | 4,437 Kb |
Lightrays v2 | Sinthetyc | 2,903 Kb |
Kut D3 | Jellevrswk | 3,687 Kb |
Shopping cart | Andiio | 6,581 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!