├── .gitattributes ├── Screenshots ├── ss1.png ├── ss2.png ├── ss3.png └── ss4.png ├── README.md ├── style.css ├── index.html └── main.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Screenshots/ss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snturk/Pattern-Creator/HEAD/Screenshots/ss1.png -------------------------------------------------------------------------------- /Screenshots/ss2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snturk/Pattern-Creator/HEAD/Screenshots/ss2.png -------------------------------------------------------------------------------- /Screenshots/ss3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snturk/Pattern-Creator/HEAD/Screenshots/ss3.png -------------------------------------------------------------------------------- /Screenshots/ss4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snturk/Pattern-Creator/HEAD/Screenshots/ss4.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pattern Creator 2 | 3 | How to use 4 | ------------------ 5 | 6 | It's pure Javascript, HTML and CSS. All you have to do is open index.html. 7 | 8 | Before you use, give a value to _VelocityX_ and _VelocityY_. 9 | 10 | After, just click "Run" button to start drawing. 11 | 12 | When process is going, you can stop it by "Pause" button or you can clear the canvas by "Clear". 13 | 14 | Also you can change values of _Process Speed_, _BallX_, _BallY_ and _Color_. 15 | 16 | **BallX and BallY**: It's values of the coordinates of our ball. 17 | 18 | **Ball Radius**: It changes radius of our ball. 19 | 20 | **Process Speed**: It effects the speed of our ball. 21 | 22 | **Color**: It changes color of the ball (Helps for better and sightly results.). 23 | 24 | Screenshots 25 | ------------------ 26 | 27 | ![Screenshot](Screenshots/ss1.png) 28 | 29 | ![Screenshot](Screenshots/ss2.png) 30 | 31 | ![Screenshot](Screenshots/ss3.png) 32 | 33 | ![Screenshot](Screenshots/ss4.png) 34 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background-color: rgba(19, 47, 100, 0.329); 3 | font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; 4 | transition-duration: 400ms; 5 | } 6 | #title{ 7 | font-size: 59px; 8 | font-weight: 200; 9 | margin: 1%; 10 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; 11 | font-style: italic; 12 | } 13 | #howToHeader{ 14 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; 15 | } 16 | #howTo{ 17 | background-color: white; 18 | float: left; 19 | border: 1.5px solid black; 20 | border-radius: 7px; 21 | width: fit-content; 22 | max-width: 22%; 23 | height: fit-content; 24 | padding: 10px; 25 | margin: 1.5%; 26 | transition-duration: 400ms; 27 | } 28 | #panelHeader{ 29 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; 30 | font-weight: 600; 31 | } 32 | #controlPanel{ 33 | background-color: white; 34 | float: left; 35 | border: 1.5px black solid; 36 | border-radius: 7px; 37 | height: fit-content; 38 | width: fit-content; 39 | max-width: 20%; 40 | padding: 10px; 41 | margin: 1.5%; 42 | text-align: center; 43 | transition-duration: 400ms; 44 | } 45 | button{ 46 | cursor: pointer; 47 | } 48 | .variables{ 49 | font-size: 20px; 50 | font-weight: 500; 51 | margin: 2px; 52 | } 53 | #darkMode{ 54 | padding: 8px; 55 | margin: 5px; 56 | font-size: 14px; 57 | border-radius: 10px; 58 | color: white; 59 | font-weight: 200; 60 | background-color: rgb(63, 63, 63); 61 | transition-duration: 400ms; 62 | } 63 | #myCanvas{ 64 | background-color: white; 65 | border-radius: 5px; 66 | float: left; 67 | margin: 2%; 68 | transition-duration: 400ms; 69 | } 70 | #alert{ 71 | font-size: 22px; 72 | font-weight: 900; 73 | margin: 15px; 74 | } 75 | #runButton, #pauseButton, #clearButton{ 76 | padding: 10px; 77 | border-radius: 10px; 78 | background-color: black; 79 | color: white; 80 | margin: 10px; 81 | font-size: 14px; 82 | } 83 | #repo{ 84 | font-weight: 100; 85 | color: black; 86 | transition-duration: 400ms; 87 | } 88 | #repo:hover{ 89 | color: rgb(49, 93, 151); 90 | } 91 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Pattern Creator 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 |
20 | < 21 | P 22 | a 23 | t 24 | t 25 | e 26 | r 27 | n 28 | 29 | C 30 | r 31 | e 32 | a 33 | t 34 | o 35 | r 36 | > 37 |
38 | 39 | 40 |
41 |

Control Panel

42 | Velocity X: 43 |
44 | Velocity Y: 45 |
46 | Ball X: 47 |
48 | Ball Y: 49 |
50 | Ball Radius: 51 |
52 | Progress Speed: 53 |
54 |
Color: 55 |
56 | 57 |
58 |
59 | 60 | 61 | 62 | 63 |
64 |
65 | 66 |
67 |

How to Use

68 |

69 |

74 | 75 |

76 | 77 |
78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | var canvas = document.getElementById('myCanvas'); 2 | var draw = canvas.getContext('2d'); 3 | 4 | var ballX; 5 | var ballY; 6 | var ballRadius; 7 | var velocityX; 8 | var velocityY; 9 | var ballColor; 10 | var progSpeed; 11 | var refreshInterval; 12 | var panels = ["myCanvas", "controlPanel", "howTo"]; 13 | var isDarkModeActive = false; 14 | var isCleared; 15 | 16 | function run(){ 17 | document.getElementById("runButton").style.opacity = 0.4; 18 | document.getElementById("runButton").disabled = true; 19 | velocityX = parseFloat(document.getElementById("velocityX").value); 20 | velocityY = parseFloat(document.getElementById("velocityY").value); 21 | ballX = parseFloat(document.getElementById("ballX").value); 22 | ballY = parseFloat(document.getElementById("ballY").value); 23 | ballRadius = parseFloat(document.getElementById("ballRadius").value); 24 | ballColor = document.getElementById("ballColor").value; 25 | progSpeed = parseFloat(document.getElementById("progSpeed").value); 26 | 27 | if(Math.abs(velocityX) < 10 && Math.abs(velocityY) < 10){ 28 | refreshInterval = setInterval(drawBall, 1000/progSpeed); 29 | }else{ 30 | refreshInterval = setInterval(drawBall, 200/progSpeed); 31 | } 32 | console.log("Progress Speed: " + progSpeed); 33 | 34 | } 35 | function pause() { 36 | velocityX = 0; 37 | velocityY = 0; 38 | document.getElementById("runButton").disabled = false; 39 | document.getElementById("runButton").style.opacity = 1; 40 | clearInterval(refreshInterval); 41 | } 42 | function clearCanvas(){ 43 | velocityX = 0; 44 | velocityY = 0; 45 | ballX =parseFloat(document.getElementById("ballX").value); 46 | ballY =parseFloat(document.getElementById("ballY").value); 47 | document.getElementById("runButton").disabled = false; 48 | document.getElementById("runButton").style.opacity = 1; 49 | draw.clearRect(0, 0, canvas.width, canvas.height); 50 | clearInterval(refreshInterval); 51 | } 52 | 53 | function modeChange(){ 54 | 55 | if(!isDarkModeActive){ 56 | isDarkModeActive = true; 57 | document.getElementById("darkMode").innerHTML = "Light Mode"; 58 | document.body.style.backgroundColor = "#333333"; 59 | document.getElementById("myCanvas").style.backgroundColor = "#282828"; 60 | 61 | panels.forEach(function(element){ 62 | document.getElementById(element).style.backgroundColor = "#282828"; 63 | document.getElementById(element).style.color = "white"; 64 | }); 65 | 66 | document.getElementById("repo").style.color = "white"; 67 | document.getElementById("darkMode").style.color = "black"; 68 | document.getElementById("darkMode").style.backgroundColor = "white"; 69 | } 70 | else{ 71 | 72 | isDarkModeActive = false; 73 | document.getElementById("darkMode").innerHTML = "Dark Mode"; 74 | document.body.style.backgroundColor = "rgba(19, 47, 100, 0.329)"; 75 | document.getElementById("myCanvas").style.backgroundColor = "white"; 76 | 77 | panels.forEach(function(element){ 78 | document.getElementById(element).style.backgroundColor = "white"; 79 | document.getElementById(element).style.color = "black"; 80 | }); 81 | 82 | document.getElementById("repo").style.color = "black"; 83 | document.getElementById("darkMode").style.color = "white"; 84 | document.getElementById("darkMode").style.backgroundColor = "black"; 85 | } 86 | 87 | } 88 | function drawBall(){ 89 | 90 | document.getElementById("ballX").value = parseInt(ballX); 91 | document.getElementById("ballY").value = parseInt(ballY); 92 | 93 | draw.beginPath(); 94 | draw.fillStyle = ballColor; 95 | draw.arc(ballX, ballY, ballRadius, 0, Math.PI*2); 96 | draw.closePath(); 97 | 98 | if(Math.abs(velocityX) < 10 && Math.abs(velocityY) < 10){ 99 | ballX += velocityX; 100 | ballY += velocityY; 101 | }else{ 102 | ballX += velocityX/20; 103 | ballY += velocityY/20; 104 | } 105 | 106 | draw.fill(); 107 | 108 | if (ballX > canvas.height - ballRadius || ballX < ballRadius){ 109 | velocityX *=-1; 110 | document.getElementById("velocityX").value = velocityX; 111 | } 112 | 113 | if(ballY > canvas.width - ballRadius || ballY < ballRadius){ 114 | velocityY *= -1; 115 | document.getElementById("velocityY").value = velocityY; 116 | } 117 | 118 | } 119 | --------------------------------------------------------------------------------