-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4ffc3b
commit fba5a14
Showing
9 changed files
with
564 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
|
||
<div class="container"> | ||
|
||
<button class="btn btn-primary"> | ||
Hello | ||
</button> | ||
|
||
|
||
<button class="btn btn-danger"> | ||
Hello | ||
</button> | ||
|
||
<button class="btn btn-outline-primary"> | ||
Hello | ||
</button> | ||
|
||
|
||
<div class="alert alert-danger my-5 mx-3"> | ||
hello ... | ||
</div> | ||
|
||
<div class="alert alert-success my-5 mx-3"> | ||
hello ... | ||
</div> | ||
|
||
|
||
|
||
|
||
<div class="accordion" id="accordionExample"> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header"> | ||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> | ||
Accordion Item #1 | ||
</button> | ||
</h2> | ||
<div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#accordionExample"> | ||
<div class="accordion-body"> | ||
<strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow. | ||
</div> | ||
</div> | ||
</div> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header"> | ||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> | ||
Accordion Item #2 | ||
</button> | ||
</h2> | ||
<div id="collapseTwo" class="accordion-collapse collapse" data-bs-parent="#accordionExample"> | ||
<div class="accordion-body"> | ||
<strong>This is the second item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow. | ||
</div> | ||
</div> | ||
</div> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header"> | ||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree"> | ||
Accordion Item #3 | ||
</button> | ||
</h2> | ||
<div id="collapseThree" class="accordion-collapse collapse" data-bs-parent="#accordionExample"> | ||
<div class="accordion-body"> | ||
<strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow. | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script> | ||
</head> | ||
<body> | ||
<button class="a"> | ||
A | ||
</button> | ||
<button class="b"> | ||
B | ||
</button> | ||
|
||
<button id="b"> | ||
B | ||
</button> | ||
<script> | ||
document.getElementsByName("button"); | ||
document.getElementsById("button"); | ||
|
||
document.querySelector(".a") | ||
document.querySelector("#b") | ||
document.querySelectorAll("button"); | ||
|
||
function callback(){ | ||
console.log('page is ready'); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", callback); | ||
|
||
|
||
const button = document.querySelector('button'); | ||
|
||
button.addEventListener('click', function() { | ||
//ffff | ||
}); | ||
|
||
$("button").click(function(){ | ||
console.log('button clicked'); | ||
}); | ||
|
||
$("button").on("click", () => { | ||
console.log('button clicked agian!!!'); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Canvas Recursive Drawings</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 20px; | ||
} | ||
h1 { | ||
color: #333; | ||
} | ||
h2 { | ||
margin-top: 40px; | ||
} | ||
canvas { | ||
border: 1px solid #000; | ||
margin-top: 20px; | ||
display: block; | ||
} | ||
.canvas-container { | ||
margin-bottom: 40px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<h1>Recursive Canvas Drawings</h1> | ||
|
||
<div class="canvas-container"> | ||
<h2>Example 1: Recursive Squares</h2> | ||
<canvas id="canvas1" width="300" height="300"></canvas> | ||
</div> | ||
|
||
<div class="canvas-container"> | ||
<h2>Example 2: Recursive Tree</h2> | ||
<canvas id="canvas2" width="300" height="300"></canvas> | ||
</div> | ||
|
||
<div class="canvas-container"> | ||
<h2>Example 3: Fractal Triangle</h2> | ||
<canvas id="canvas3" width="300" height="300"></canvas> | ||
</div> | ||
|
||
<div class="canvas-container"> | ||
<h2>Example 4: Spiral Pattern</h2> | ||
<canvas id="canvas4" width="300" height="300"></canvas> | ||
</div> | ||
|
||
<div class="canvas-container"> | ||
<h2>Example 5: Snowflake Pattern</h2> | ||
<canvas id="canvas5" width="300" height="300"></canvas> | ||
</div> | ||
|
||
<script> | ||
|
||
const brightColors = [ | ||
"#7DF9FF", // Electric Blue | ||
"#39FF14", // Neon Green | ||
"#FF69B4", // Hot Pink | ||
"#FF6700", // Bright Orange | ||
"#9F00FF", // Vivid Violet | ||
"#00FFFF", // Aqua | ||
"#FF0000", // Bright Red | ||
"#40E0D0", // Turquoise | ||
"#FF00FF" // Magenta | ||
]; | ||
|
||
function getRandomColor() { | ||
const randomIndex = Math.floor(Math.random() * brightColors.length); | ||
return brightColors[randomIndex]; | ||
} | ||
|
||
// Example 1: Recursive Squares | ||
const canvas1 = document.getElementById('canvas1'); | ||
const ctx1 = canvas1.getContext('2d'); | ||
|
||
const drawLeave = (x, y, ctx) => { | ||
ctx.strokeStyle = getRandomColor(); | ||
ctx.lineWidth = 1; | ||
|
||
ctx.beginPath(); | ||
ctx.arc(x, y, 2, 0, Math.PI * 2); | ||
ctx.stroke(); | ||
} | ||
|
||
function drawSquare(x, y, size) { | ||
if (size < 5) return; | ||
|
||
ctx1.strokeRect(x, y, size, size); | ||
|
||
// Draw smaller squares inside | ||
drawSquare(x + size * 0.1, y + size * 0.1, size * 0.8); | ||
} | ||
|
||
ctx1.strokeStyle = '#000'; | ||
drawSquare(50, 50, 200); | ||
|
||
// Example 2: Recursive Tree | ||
const canvas2 = document.getElementById('canvas2'); | ||
const ctx2 = canvas2.getContext('2d'); | ||
|
||
function drawBranch(x, y, length, angle, width) { | ||
console.log("drawBranch at", x, y, " with length ", length, "and angle ", angle, " width", width); | ||
if (length < 5) { | ||
drawLeave(x, y, ctx2); | ||
return; | ||
}; | ||
|
||
ctx2.strokeStyle = '#000'; | ||
ctx2.lineWidth = width; | ||
ctx2.beginPath(); | ||
ctx2.moveTo(x, y); | ||
|
||
const xEnd = x + length * Math.cos(angle); | ||
const yEnd = y + length * Math.sin(angle); | ||
|
||
ctx2.lineTo(xEnd, yEnd); | ||
ctx2.stroke(); | ||
|
||
// Draw smaller branches | ||
drawBranch(xEnd, yEnd, length * 0.7, angle - Math.PI / 6, width * 0.7);//left branch | ||
drawBranch(xEnd, yEnd, length * 0.7, angle + Math.PI / 6, width * 0.7); // right branch | ||
} | ||
|
||
drawBranch(150, 300, 80, -Math.PI / 2, 10); | ||
|
||
// Example 3: Fractal Triangle | ||
const canvas3 = document.getElementById('canvas3'); | ||
const ctx3 = canvas3.getContext('2d'); | ||
|
||
function drawTriangle(x, y, size) { | ||
if (size < 5) return; | ||
|
||
ctx3.beginPath(); | ||
ctx3.moveTo(x, y); | ||
ctx3.lineTo(x + size, y); | ||
ctx3.lineTo(x + size / 2, y - size * Math.sin(Math.PI / 3)); | ||
ctx3.closePath(); | ||
ctx3.stroke(); | ||
|
||
// Draw smaller triangles | ||
drawTriangle(x, y, size / 2); | ||
drawTriangle(x + size / 2, y, size / 2); | ||
drawTriangle(x + size / 4, y - size / 2 * Math.sin(Math.PI / 3), size / 2); | ||
} | ||
|
||
ctx3.strokeStyle = '#000'; | ||
drawTriangle(50, 250, 200); | ||
|
||
// Example 4: Spiral Pattern | ||
const canvas4 = document.getElementById('canvas4'); | ||
const ctx4 = canvas4.getContext('2d'); | ||
|
||
function drawSpiral(x, y, angle, length) { | ||
if (length < 5) return; | ||
|
||
const xEnd = x + length * Math.cos(angle); | ||
const yEnd = y + length * Math.sin(angle); | ||
|
||
ctx4.beginPath(); | ||
ctx4.moveTo(x, y); | ||
ctx4.lineTo(xEnd, yEnd); | ||
ctx4.stroke(); | ||
|
||
drawSpiral(xEnd, yEnd, angle + Math.PI / 6, length * 0.9); | ||
} | ||
|
||
ctx4.strokeStyle = '#000'; | ||
drawSpiral(150, 150, 0, 100); | ||
|
||
// Example 5: Snowflake Pattern | ||
const canvas5 = document.getElementById('canvas5'); | ||
const ctx5 = canvas5.getContext('2d'); | ||
|
||
function drawSnowflake(x, y, length, depth) { | ||
if (depth === 0) return; | ||
|
||
ctx5.beginPath(); | ||
ctx5.moveTo(x - length / 2, y); | ||
ctx5.lineTo(x + length / 2, y); | ||
ctx5.stroke(); | ||
|
||
const newLength = length / 3; | ||
const newDepth = depth - 1; | ||
|
||
drawSnowflake(x - length / 3, y - newLength, newLength, newDepth); | ||
drawSnowflake(x + length / 3, y - newLength, newLength, newDepth); | ||
drawSnowflake(x, y + newLength, newLength, newDepth); | ||
} | ||
|
||
ctx5.strokeStyle = '#000'; | ||
drawSnowflake(150, 150, 120, 4); | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>JavaScript Recursive Functions</title> | ||
</head> | ||
<body> | ||
<ul> | ||
<li> | ||
<a href="recursive.html">Recursive Functions</a> | ||
</li> | ||
|
||
<li> | ||
<a href="example.html">Examples</a> | ||
</li> | ||
</ul> | ||
</body> | ||
</html> |
Oops, something went wrong.