diff --git a/2-terrarium/terrarium-solution/.vscode/launch.json b/2-terrarium/terrarium-solution/.vscode/launch.json new file mode 100644 index 0000000..e69de29 diff --git a/2-terrarium/terrarium-solution/images/Screenshot from 2025-03-02 22-25-40.png b/2-terrarium/terrarium-solution/images/Screenshot from 2025-03-02 22-25-40.png new file mode 100644 index 0000000..da56cb0 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/Screenshot from 2025-03-02 22-25-40.png differ diff --git a/2-terrarium/terrarium-solution/images/Screenshot from 2025-03-02 22-32-59.png b/2-terrarium/terrarium-solution/images/Screenshot from 2025-03-02 22-32-59.png new file mode 100644 index 0000000..4b6cd96 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/Screenshot from 2025-03-02 22-32-59.png differ diff --git a/2-terrarium/terrarium-solution/images/plant1.png b/2-terrarium/terrarium-solution/images/plant1.png new file mode 100644 index 0000000..9baee27 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant1.png differ diff --git a/2-terrarium/terrarium-solution/images/plant10.png b/2-terrarium/terrarium-solution/images/plant10.png new file mode 100644 index 0000000..4b5136d Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant10.png differ diff --git a/2-terrarium/terrarium-solution/images/plant11.png b/2-terrarium/terrarium-solution/images/plant11.png new file mode 100644 index 0000000..3530fe5 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant11.png differ diff --git a/2-terrarium/terrarium-solution/images/plant12.png b/2-terrarium/terrarium-solution/images/plant12.png new file mode 100644 index 0000000..b7f6dfd Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant12.png differ diff --git a/2-terrarium/terrarium-solution/images/plant13.png b/2-terrarium/terrarium-solution/images/plant13.png new file mode 100644 index 0000000..18938b7 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant13.png differ diff --git a/2-terrarium/terrarium-solution/images/plant14.png b/2-terrarium/terrarium-solution/images/plant14.png new file mode 100644 index 0000000..87ccb62 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant14.png differ diff --git a/2-terrarium/terrarium-solution/images/plant2.png b/2-terrarium/terrarium-solution/images/plant2.png new file mode 100644 index 0000000..b90853f Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant2.png differ diff --git a/2-terrarium/terrarium-solution/images/plant3.png b/2-terrarium/terrarium-solution/images/plant3.png new file mode 100644 index 0000000..17e10d1 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant3.png differ diff --git a/2-terrarium/terrarium-solution/images/plant4.png b/2-terrarium/terrarium-solution/images/plant4.png new file mode 100644 index 0000000..4bbafad Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant4.png differ diff --git a/2-terrarium/terrarium-solution/images/plant5.png b/2-terrarium/terrarium-solution/images/plant5.png new file mode 100644 index 0000000..d303d40 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant5.png differ diff --git a/2-terrarium/terrarium-solution/images/plant6.png b/2-terrarium/terrarium-solution/images/plant6.png new file mode 100644 index 0000000..823eeed Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant6.png differ diff --git a/2-terrarium/terrarium-solution/images/plant7.png b/2-terrarium/terrarium-solution/images/plant7.png new file mode 100644 index 0000000..fceb7f2 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant7.png differ diff --git a/2-terrarium/terrarium-solution/images/plant8.png b/2-terrarium/terrarium-solution/images/plant8.png new file mode 100644 index 0000000..40b4f15 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant8.png differ diff --git a/2-terrarium/terrarium-solution/images/plant9.png b/2-terrarium/terrarium-solution/images/plant9.png new file mode 100644 index 0000000..17a3435 Binary files /dev/null and b/2-terrarium/terrarium-solution/images/plant9.png differ diff --git a/2-terrarium/terrarium-solution/index.html b/2-terrarium/terrarium-solution/index.html new file mode 100644 index 0000000..69cf4c7 --- /dev/null +++ b/2-terrarium/terrarium-solution/index.html @@ -0,0 +1,72 @@ + + + + Welcome to my Virtual Terrarium + + + + + + + +

My Terrarium

+ +
+
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/2-terrarium/terrarium-solution/script.js b/2-terrarium/terrarium-solution/script.js new file mode 100644 index 0000000..5c19383 --- /dev/null +++ b/2-terrarium/terrarium-solution/script.js @@ -0,0 +1,63 @@ +dragElement(document.getElementById('plant1')); +dragElement(document.getElementById('plant2')); +dragElement(document.getElementById('plant3')); +dragElement(document.getElementById('plant4')); +dragElement(document.getElementById('plant5')); +dragElement(document.getElementById('plant6')); +dragElement(document.getElementById('plant7')); +dragElement(document.getElementById('plant8')); +dragElement(document.getElementById('plant9')); +dragElement(document.getElementById('plant10')); +dragElement(document.getElementById('plant11')); +dragElement(document.getElementById('plant12')); +dragElement(document.getElementById('plant13')); +dragElement(document.getElementById('plant14')); +function dragElement(terrariumElement) { + let pos1 = 0, + pos2 = 0, + pos3 = 0, + pos4 = 0; + terrariumElement.onpointerdown = pointerDrag; + function pointerDrag(e) { + e.preventDefault(); + console.log(e); + pos3 = e.clientX; + pos4 = e.clientY; + document.onpointermove = elementDrag; + document.onpointerup = stopElementDrag; + } + function elementDrag(e) { + pos1 = pos3 - e.clientX; + pos2 = pos4 - e.clientY; + pos3 = e.clientX; + pos4 = e.clientY; + console.log(pos1, pos2, pos3, pos4); + terrariumElement.style.top = terrariumElement.offsetTop - pos2 + 'px'; + terrariumElement.style.left = terrariumElement.offsetLeft - pos1 + 'px'; + } + function stopElementDrag() { + document.onpointerup = null; + document.onpointermove = null; + } +} +document.getElementById("resetButton").addEventListener('click',()=>{ + location.reload(); +}) + +document.querySelectorAll(".plant").forEach((plant) => { + plant.addEventListener("dblclick", () => { + const interior = document.querySelector(".jar-walls"); + interior.appendChild(plant); + plant.style.position = "absolute"; + plant.style.zIndex = "3"; + + const jarRect = interior.getBoundingClientRect(); + + const randomX = Math.random() * (jarRect.width - plant.width); + const randomY = Math.random() * (jarRect.height - plant.height); + + + plant.style.left = `${randomX}px`; + plant.style.top = `${randomY}px`; + }); +}); diff --git a/2-terrarium/terrarium-solution/solution.md b/2-terrarium/terrarium-solution/solution.md new file mode 100644 index 0000000..a4b5540 --- /dev/null +++ b/2-terrarium/terrarium-solution/solution.md @@ -0,0 +1,271 @@ +# 1. Sub Topic 1 +## Assignment + +To make the title scroll horizontally using `` tag, we can include our `

` inside of the it. + +```html + + + + Welcome to my Virtual Terrarium + + + + + + +

Scrolling Heading

+
+
+
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+
+
+
+
+
+
+
+
+
+
+ +``` + +## Challenge + +### My personal website + +```html + + + + Resume + + +

Anandajith.S

+

B.Tech in Computer Science and Engineering

+

Contact information

+

Email Address: anandajiths2006@gmail.com

+

Phone: 8714399795

+

Linkedin Profile: Anandajith.S

+

Education

+

B.Tech

+

Branch: Computer Science and Engineering

+

Institution: Amrita Vishwa Vidyaapetham, Amritapuri

+

Skills

+

Languages known

+ +

Portflio

+

Github profile:anandajiths2006

+ + +``` +# 2. Sub Topic 2 +## Assignment + +```css +.jar-glossy-long{ + position: absolute; + background: #e0fffb; + border-radius: 1rem 1rem 1rem 1rem; + z-index:-1; + bottom: 15%; + left: 5%; + height: 20%; + width: 3.5%; + opacity:0.9; + +} +.jar-glossy-short{ + position: absolute; + background: #e0fffb; + border-radius: 1rem 1rem 1rem 1rem; + z-index:-1; + bottom: 40%; + left: 5%; + height: 5%; + width: 3.5%; + opacity:0.9; +} +``` + +## Challenge + +For this challenge, I created a class called `.container`. I applied it to `#left-container` and `#right-container`. +I used Flexbox for this + +```html +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+
+ plant +
+``` + +```css +#left-container { + background-color: #eee; + width: 200px; + left: 0px; + top: 0px; + position: absolute; + height: 940px; + padding: 10px; +} + +#right-container { + background-color: #eee; + width: 200px; + right: 0px; + top: 0px; + position: absolute; + height: 940px; + padding: 10px; +} + + +.container{ + display: flex; + flex-direction: column; + justify-content: space-evenly; + align-content: center; +} +``` + +I made sure to check if the elements are aligning properly in different browsers + +**Chrome** +![Chrome screenshot](./images/Screenshot%20from%202025-03-02%2022-25-40.png) + +**Firefox** +![Firefox screenshot](./images/Screenshot%20from%202025-03-02%2022-32-59.png) + +# 3. Sub Topic +## Assignment + + +**MutationObserver** +The `MutationObserver` interface provides the ability to watch for changes being made in +a webpage. We can define a callback function which will be executed when the element being +watched undergoes some specific changes. It is extremely useful as it reacts instantly to updates, hence it is used extensively in chat applications. An example of this when +a person sends a message to another person, the `MutationObserver` will detect it and +immediately trigger notifications. + + +## Challenge + +I added an event listener which makes the plants go inside the container when they are +double clicked. The event listener sets a random position for the plant based on the +dimensions of the container to ensure that they dont clutter up at a single point. + +```javascript + +document.querySelectorAll(".plant").forEach((plant) => { + plant.addEventListener("dblclick", () => { + const interior = document.querySelector(".jar-walls"); + interior.appendChild(plant); + plant.style.position = "absolute"; + plant.style.zIndex = "3"; + + const jarRect = interior.getBoundingClientRect(); + + const randomX = Math.random() * (jarRect.width - plant.width); + const randomY = Math.random() * (jarRect.height - plant.height); + + + plant.style.left = `${randomX}px`; + plant.style.top = `${randomY}px`; + }); +}); +``` diff --git a/2-terrarium/terrarium-solution/style.css b/2-terrarium/terrarium-solution/style.css new file mode 100644 index 0000000..2510741 --- /dev/null +++ b/2-terrarium/terrarium-solution/style.css @@ -0,0 +1,135 @@ +body { + font-family: helvetica, arial, sans-serif; +} + +h1 { + color: #3a241d; + text-align: center; +} + +button{ + border-radius: 30px; + width: 80px; + color:black; + background-color: grey; + display: block; + margin: 0 auto; +} + +button:hover{ + color:white; + background-color: rgb(189, 38, 0); +} +#left-container { + background-color: #eee; + width: 200px; + left: 0px; + top: 0px; + position: absolute; + height: 940px; + padding: 10px; +} + +#right-container { + background-color: #eee; + width: 200px; + right: 0px; + top: 0px; + position: absolute; + height: 940px; + padding: 10px; +} + + +.container{ + display: flex; + flex-direction: column; + justify-content: space-evenly; + align-content: center; +} + +.plant-holder { + position: relative; + height: 11%; + left: -10px; + +} + +.plant { + position: absolute; + max-width: 150%; + max-height: 150%; + z-index: 3; + +} +.jar-walls { + height: 80%; + width: 60%; + border-radius: 1rem; + position: absolute; + bottom: 5px; + left: 20%; + background: rgba(209, 225, 223, 0.5); + transform: scale(1); + opacity: 1; + z-index: 1; +} + +.jar-top { + width: 50%; + height: 5%; + background: #d1e1df; + position: absolute; + bottom: 80.5%; + left: 25%; + opacity: 0.7; + z-index: 1; +} + +.jar-bottom { + width: 50%; + height: 1%; + background: #d1e1df; + position: absolute; + bottom: 0%; + left: 25%; + opacity: 0.7; +} + +.dirt { + width: 60%; + height: 5%; + background: #3a241d; + position: absolute; + border-radius: 0 0 1rem 1rem; + bottom: 1%; + left: 20%; + opacity: 0.7; + z-index: -1; +} +.jar-glossy-long{ + position: absolute; + background: #e0fffb; + border-radius: 1rem 1rem 1rem 1rem; + z-index:-1; + bottom: 15%; + left: 5%; + height: 20%; + width: 3.5%; + opacity:0.9; + +} +.jar-glossy-short{ + position: absolute; + background: #e0fffb; + border-radius: 1rem 1rem 1rem 1rem; + z-index:-1; + bottom: 40%; + left: 5%; + height: 5%; + width: 3.5%; + opacity:0.9; + +} + +.jar-walls .plant{ transform: scale(0.4) !important;} \ No newline at end of file