{"id":1799,"date":"2025-01-02T13:44:17","date_gmt":"2025-01-02T13:44:17","guid":{"rendered":"https:\/\/donhit.com\/en\/?p=1799"},"modified":"2025-02-06T01:42:49","modified_gmt":"2025-02-06T01:42:49","slug":"random-number-generator","status":"publish","type":"post","link":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/","title":{"rendered":"Random number generator 1-100"},"content":{"rendered":"<p><center> <div class=\"container123\">\r\n        <h2>Random Number Generator<\/h2>\r\n        \r\n        <div class=\"range-controls\">\r\n            <div class=\"range-group\">\r\n                <label for=\"minNumber\">Minimum Number:<\/label>\r\n                <div class=\"range-input\">\r\n                    <input type=\"number\" id=\"minNumber\" value=\"1\" \/>\r\n                <\/div>\r\n            <\/div>\r\n            <div class=\"range-group\">\r\n                <label for=\"maxNumber\">Maximum Number:<\/label>\r\n                <div class=\"range-input\">\r\n                    <input type=\"number\" id=\"maxNumber\" value=\"100\" \/>\r\n                <\/div>\r\n            <\/div>\r\n            <div class=\"error-message\" id=\"errorMessage\"><\/div>\r\n        <\/div>\r\n\r\n        <canvas id=\"canvas\" width=\"300\" height=\"300\"><\/canvas>\r\n        <div id=\"result\"><\/div>\r\n        <button id=\"generateBtn\">Generate Number<\/button>\r\n    <\/div>\r\n\r\n    <script>\r\n        const canvas = document.getElementById('canvas');\r\n        const ctx = canvas.getContext('2d');\r\n        const result = document.getElementById('result');\r\n        const generateBtn = document.getElementById('generateBtn');\r\n        const minInput = document.getElementById('minNumber');\r\n        const maxInput = document.getElementById('maxNumber');\r\n        const errorMessage = document.getElementById('errorMessage');\r\n        let animationId;\r\n        let particles = [];\r\n\r\n        class Particle {\r\n            constructor(x, y, color) {\r\n                this.x = x;\r\n                this.y = y;\r\n                this.color = color;\r\n                this.size = Math.random() * 3 + 2;\r\n                this.speedX = Math.random() * 6 - 3;\r\n                this.speedY = Math.random() * 6 - 3;\r\n                this.life = 1;\r\n            }\r\n\r\n            update() {\r\n                this.x += this.speedX;\r\n                this.y += this.speedY;\r\n                this.life -= 0.02;\r\n                if (this.size > 0.2) this.size -= 0.1;\r\n            }\r\n\r\n            draw() {\r\n                ctx.fillStyle = `rgba(${this.color}, ${this.life})`;\r\n                ctx.beginPath();\r\n                ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);\r\n                ctx.fill();\r\n            }\r\n        }\r\n\r\n        function validateRange() {\r\n            const min = parseInt(minInput.value);\r\n            const max = parseInt(maxInput.value);\r\n            \r\n            if (isNaN(min) || isNaN(max)) {\r\n                errorMessage.textContent = \"Please enter valid numbers\";\r\n                return false;\r\n            }\r\n            \r\n            if (min >= max) {\r\n                errorMessage.textContent = \"Maximum number must be greater than minimum number\";\r\n                return false;\r\n            }\r\n            \r\n            errorMessage.textContent = \"\";\r\n            return true;\r\n        }\r\n\r\n        function initCanvas() {\r\n            ctx.fillStyle = '#1a1a1a';\r\n            ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n            drawCircle();\r\n        }\r\n\r\n        function drawCircle() {\r\n            const centerX = canvas.width \/ 2;\r\n            const centerY = canvas.height \/ 2;\r\n            const radius = 130;\r\n\r\n            const gradient = ctx.createRadialGradient(centerX, centerY, radius - 10, centerX, centerY, radius + 10);\r\n            gradient.addColorStop(0, 'rgba(0, 168, 255, 0.3)');\r\n            gradient.addColorStop(1, 'rgba(0, 168, 255, 0)');\r\n            ctx.fillStyle = gradient;\r\n            ctx.beginPath();\r\n            ctx.arc(centerX, centerY, radius + 10, 0, Math.PI * 2);\r\n            ctx.fill();\r\n\r\n            ctx.fillStyle = '#2a2a2a';\r\n            ctx.beginPath();\r\n            ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);\r\n            ctx.fill();\r\n\r\n            ctx.fillStyle = '#fff';\r\n            ctx.font = '48px Arial';\r\n            ctx.textAlign = 'center';\r\n            ctx.textBaseline = 'middle';\r\n            ctx.fillText(result.textContent || '?', centerX, centerY);\r\n        }\r\n\r\n        function animate() {\r\n            ctx.fillStyle = 'rgba(26, 26, 26, 0.2)';\r\n            ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n            \r\n            drawCircle();\r\n\r\n            for (let i = particles.length - 1; i >= 0; i--) {\r\n                particles[i].update();\r\n                particles[i].draw();\r\n                if (particles[i].life <= 0) particles.splice(i, 1);\r\n            }\r\n\r\n            animationId = requestAnimationFrame(animate);\r\n        }\r\n\r\n        function generateParticles(num) {\r\n            const centerX = canvas.width \/ 2;\r\n            const centerY = canvas.height \/ 2;\r\n            for (let i = 0; i < num; i++) {\r\n                particles.push(new Particle(centerX, centerY, '0, 168, 255'));\r\n            }\r\n        }\r\n\r\n        function generateNumber() {\r\n            if (!validateRange()) return;\r\n\r\n            const min = parseInt(minInput.value);\r\n            const max = parseInt(maxInput.value);\r\n            \r\n            generateBtn.disabled = true;\r\n            let count = 0;\r\n            let duration = 30;\r\n            let interval = setInterval(() => {\r\n                const random = Math.floor(Math.random() * (max - min + 1)) + min;\r\n                result.textContent = random;\r\n                generateParticles(5);\r\n                \r\n                count++;\r\n                if (count >= duration) {\r\n                    clearInterval(interval);\r\n                    generateBtn.disabled = false;\r\n                }\r\n            }, 50);\r\n        }\r\n\r\n        \/\/ Input validation\r\n        minInput.addEventListener('input', validateRange);\r\n        maxInput.addEventListener('input', validateRange);\r\n\r\n        \/\/ Event listeners\r\n        generateBtn.addEventListener('click', generateNumber);\r\n        canvas.addEventListener('click', generateNumber);\r\n\r\n        \/\/ Initialize\r\n        initCanvas();\r\n        animate();\r\n    <\/script><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[187],"tags":[],"class_list":["post-1799","post","type-post","status-publish","format-standard","hentry","category-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Random number generator 1-100 - DonHit<\/title>\n<meta name=\"description\" content=\"Random number generators (RNGs) are algorithms or devices designed to produce sequences of numbers that lack any discernible pattern\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/donhit.com\/en\/tools\/random-number-generator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Random number generator 1-100 - DonHit\" \/>\n<meta property=\"og:description\" content=\"Random number generators (RNGs) are algorithms or devices designed to produce sequences of numbers that lack any discernible pattern\" \/>\n<meta property=\"og:url\" content=\"https:\/\/donhit.com\/en\/tools\/random-number-generator\/\" \/>\n<meta property=\"og:site_name\" content=\"DonHit - World of Tools\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-02T13:44:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-06T01:42:49+00:00\" \/>\n<meta name=\"author\" content=\"DonHit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DonHit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Random number generator 1-100 - DonHit","description":"Random number generators (RNGs) are algorithms or devices designed to produce sequences of numbers that lack any discernible pattern","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/","og_locale":"en_US","og_type":"article","og_title":"Random number generator 1-100 - DonHit","og_description":"Random number generators (RNGs) are algorithms or devices designed to produce sequences of numbers that lack any discernible pattern","og_url":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/","og_site_name":"DonHit - World of Tools","article_published_time":"2025-01-02T13:44:17+00:00","article_modified_time":"2025-02-06T01:42:49+00:00","author":"DonHit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"DonHit","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/#article","isPartOf":{"@id":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/"},"author":{"name":"DonHit","@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148"},"headline":"Random number generator 1-100","datePublished":"2025-01-02T13:44:17+00:00","dateModified":"2025-02-06T01:42:49+00:00","mainEntityOfPage":{"@id":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/"},"wordCount":8,"commentCount":0,"publisher":{"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148"},"articleSection":["Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/donhit.com\/en\/tools\/random-number-generator\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/","url":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/","name":"Random number generator 1-100 - DonHit","isPartOf":{"@id":"https:\/\/donhit.com\/en\/#website"},"datePublished":"2025-01-02T13:44:17+00:00","dateModified":"2025-02-06T01:42:49+00:00","description":"Random number generators (RNGs) are algorithms or devices designed to produce sequences of numbers that lack any discernible pattern","breadcrumb":{"@id":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/donhit.com\/en\/tools\/random-number-generator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/donhit.com\/en\/tools\/random-number-generator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Trang ch\u1ee7","item":"https:\/\/donhit.com\/en\/"},{"@type":"ListItem","position":2,"name":"Tools","item":"https:\/\/donhit.com\/en\/category\/tools\/"},{"@type":"ListItem","position":3,"name":"Random number generator 1-100"}]},{"@type":"WebSite","@id":"https:\/\/donhit.com\/en\/#website","url":"https:\/\/donhit.com\/en\/","name":"DonHit - World of tools","description":"","publisher":{"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/donhit.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148","name":"DonHit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/donhit.com\/en\/wp-content\/uploads\/2024\/11\/logo-donhit.webp","contentUrl":"https:\/\/donhit.com\/en\/wp-content\/uploads\/2024\/11\/logo-donhit.webp","width":400,"height":267,"caption":"DonHit"},"logo":{"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/image\/"},"description":"DonHit is a website designed to provide useful tools for everyone. Its primary goal is to support and empower the community. All the tools available on the site are completely free to use.","sameAs":["https:\/\/donhit.com\/en"],"url":"https:\/\/donhit.com\/en\/author\/admin_don\/"}]}},"_links":{"self":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts\/1799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/comments?post=1799"}],"version-history":[{"count":2,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts\/1799\/revisions"}],"predecessor-version":[{"id":2040,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts\/1799\/revisions\/2040"}],"wp:attachment":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/media?parent=1799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/categories?post=1799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/tags?post=1799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}