Math

Size
2,495 Kb
Views
8,096

How do I make an math?

What is a math? How do you make a math? This script and codes were developed by Darryl Huffman on 07 January 2023, Saturday.

Math Previews

Math - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Math</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Math - Script Codes CSS Codes

html, body { width: 100%; height: 100%; margin: 0px; padding: 0px; overflow: hidden; background-color: #111;
}
canvas { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}

Math - Script Codes JS Codes

// DICE ROLL = 1-6
var positions = {	1: [3,1],	2: [3,1],	3: [5,5],	4: [5,5],	5: [1,5],	6: [1,5]
};
var container = 'body';
var size = {	x: $(container).width(),	y: $(container).height(),	scale: 0
};
if(size.x >= size.y){	size.x = size.y;
} else {	size.y = size.x;
}
size.scale = size.x/5;
var pointer = {	x: Math.floor(Math.random() * 6 + 1),	y: Math.floor(Math.random() * 6 + 1)
}
var canvas = $('<canvas/>').attr({width: size.x, height: size.y}).appendTo(container), context = canvas.get(0).getContext("2d");
window.requestFrame = (function(){	return window.requestAnimationFrame ||	window.webkitRequestAnimationFrame ||	window.mozRequestAnimationFrame ||	function( callback ){	window.setTimeout(callback, 1000 / 60);	};
})();
context.clearRect(0,0,size.x,size.y);
context.fillStyle = "#FF0000";
context.fillRect((pointer.x-0.5)*size.scale, (pointer.y-0.5)*size.scale, 8, 8);
context.fillStyle = "#FFFFFF";
function render(){	var c = Math.floor(Math.random() * 6 + 1);	var toPos = positions[c];	var nextPointerPos = {};	nextPointerPos.x = pointer.x + (toPos[0] - pointer.x) / 2;	nextPointerPos.y = pointer.y + (toPos[1] - pointer.y) / 2;	context.fillRect((nextPointerPos.x-0.5)*size.scale, (nextPointerPos.y-0.5)*size.scale, 1, 1);	pointer = nextPointerPos;	//setTimeout(render, 1);	requestFrame(render);
}
render();
Math - Script Codes
Math - Script Codes
Home Page Home
Developer Darryl Huffman
Username darrylhuffman
Uploaded January 07, 2023
Rating 3.5
Size 2,495 Kb
Views 8,096
Do you need developer help for Math?

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!

Darryl Huffman (darrylhuffman) Script Codes
Create amazing SEO content with AI!

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!