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 |
A Perfect Orbit | 3,411 Kb |
Let it snow, let it snow, code the snow. | 2,884 Kb |
Hot Arrrr Balloon. | 2,755 Kb |
Followers Solar System | 6,724 Kb |
Red Oak | 4,332 Kb |
Blackhole | 4,946 Kb |
Simple SVG Charts | 6,694 Kb |
Math | 2,495 Kb |
LightBulb | 2,561 Kb |
BLACKHOLE - A Canvas Experiment | 3,676 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 |
RollOver Effect 2 | Lmack90 | 2,162 Kb |
Countdown with Rings | Ewganoel | 2,490 Kb |
Faux column absolute wrapper | Yurimorini | 1,823 Kb |
Simple Login Form | JoshBlackwood | 4,418 Kb |
Roman Numerical Converter | Vhall_io | 2,102 Kb |
To Do List with Delete | Mattlbrody | 2,068 Kb |
Form Labels | Bartuc | 2,717 Kb |
A Pen by Malith Hettiarachchi | MalZiiirA | 5,531 Kb |
A Pen by Jay | Jaycode | 3,784 Kb |
The Walking Raymarcher | Xorxor_hu | 7,934 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!