Scatter letter on screen and image appearing on hover debug

I am having trouble with debugging the scatter letters and my project link aspects. I can’t figure out why on media screen it’s not working, and now I have also made the contact links disappear on both.

I am new to programming and would appreciate support to help me learn!

Below is the link to my repo.

https://github.com/milanawood/portfolio

Thank you,
Milana

I have tried changing CSS and is and keep making sure they’re correctly working together but each time I fix one thing I seem to create another issue.

VSCode Autocomplete Not Displaying

I am currently running Visual Studio Code in WSL, and for some reason autocomplete doesn’t work. I’m not sure why autocomplete isn’t working. Any solution would be greatly appreciated. It doesn’t even work when I’m not in WSL. So i’m not sure what the issue is.
clearBtn. only shows variables within the scope of the class

I have tried checking my settings to make sure that built in typescript and javascript features are enabled, which they are. In this case, when I want innerHTML to appear for clearBtn. I have to type everything in manually.

Can I load basemap without center or set view in map initialization

I have the center coming from a different layer, however, that layer is loading slowly so initially you see a blank map container.so, I want the basemap to be visible.

view.map = L.map('map_' + mapId, {
  gestureHandling: true,
  zoom: 8,
  layers: [osm, EsriStreets, EsriImagery, EsriTopo],
  fullscreenControl: {
    pseudoFullscreen: false // if true, fullscreen to page width and height
  }
});

react router dom only works when navigating via links but not back button window.scrollTo(0, 0) only works

I have a react app that I want to automatically start at the top of the page whenever I navigate to that page, regardless of how a user gets there (i.e. clicking a Link component that links to that page, or using back button to go back and forward)

I have a ScrollToTop component that uses window.scrollTo(0, 0) method that scrolls to the top whenever the pathname changes. However, this only works on navigating via Links but not back and forward buttons on the browser.

ScrollToTop.tsx

...Imports

const useBackButton = (): boolean => {
  const navType = useNavigationType()
  return navType === NavigationType.Pop
}

const ScrollToTop: React.FC = () => {
  const { pathname } = useLocation()
  const isPop = useBackButton()

  const scrollToTop = (): void => {
    window.scrollTo(0, 0)
  }

  useEffect(() => {
    console.log(pathname, isPop)
    scrollToTop()
  }, [pathname, isPop])

  useEffect(() => {
    window.addEventListener('beforeunload', scrollToTop)
    console.log('On Mount')
    return () => {
      window.removeEventListener('beforeunload', scrollToTop)
      console.log('On Unmount')
    }
  }, [])

  return (
    <>
      <Outlet />
    </>
  )
}

export default ScrollToTop

App.tsx

...Imports

const router = createBrowserRouter(
  createRoutesFromElements(
    <Route element={<ScrollToTop />}>
      <Route path='/' element={<RootLayout />}>
        <Route path='*' element={<NotFound />} />
        <Route index element={<Landing />} />
        <Route path='auth' element={<Auth />} />
        <Route path='ideate' element={<IdeatorLayout />}>
          <Route path=':sessionID' element={<Display />} />
        </Route>
        <Route path='privacy' element={<Privacy />} />
      </Route>
    </Route>
  )
)

export const App: React.FunctionComponent = () => {
  useAuthControl()

  return <RouterProvider router={router} />
}

Any help would be appreciated. Thanks in advance!

how can i get a clear roadmap to learn javascript? [closed]

My name is mohamed, I am a frontend developer, so I have good experience in HTML & CSS, Unfortunately, I started to learn coding & programming 5 years ago, and after all this time I still have experience in very easy programming languages.

that disappoints me, I have been started to learn programming languages like PHP & C# & JavaScript 2 – 3 years ago & and now I still trying to learn them but my very big problem is that every time I start a project with any of them a lot of errors break the projects.

Although I didn’t do anything wrong I copied the trainer same code exactly but I still have a lot of errors or one big error that broke me & the project because I couldn’t fix it, that doesn’t happen one time, every time I started to learn those languages the errors came to me, Throughout these years, I have been moving from one trainer to another and from one training course to another to no avail.

I fully realize that solving problems is one of the most important skills required to work as a programmer, but I feel that I am the only one who has had bad luck, for example when I go to the comments of the educational videos that I watch, I find that most or all of the comments It’s almost positive and no one faces any problems. I’m really tired and I can’t explain the amount of frustration I’m suffering from.

This has become a barrier between me and developing my skills. It’s frustrating and shameful for me that for five years I haven’t developed my programming skills, except in what is really simple. I hope to get a clear roadmap for learning a language like JavaScript because my job requirements need a language that is flexible, modern, fast, and can build complex web applications with modern features. I long sigh as I write this.
I’m really tired and I want to improve my skills as quickly as possible and I don’t want to waste any more time.
Note: I learned from respectable sources such as the W3 School website, and I benefited from the information, but I was not able to employ it all in an integrated project. In addition, my work requirements require building complex web applications or with characteristics similar to professional sites such as Amazon, eBay, Zillow, and others. Please do not ask me. What are the errors that I was facing, because they are countless.

I was also trying, for example, to delete previous versions of node and update them, but this does not work. I suffered from various problems previously, and it is not one problem at all.
If you got here, I appreciate your time and I hope I get advice that helps and benefits me
Thanks

Breaking Errors all the time

closing tab by left click, wihout clicking the X, just click tab and will closes

Good day,

I am managing this simple extension, that the tab will close if you just click it (left click), the middle click button can do this, but in this extension, when activated or reloaded, the mouse inputs will change.

some extensions, can do double click, but here we will test if we can do it by one left click. normally, when you left click the tab, it just goes there, but here will close.. hope you get this simple function..

How we code this?

Tried injecting some code, but nothing happens..

Love to hear from yous, keep a well day, blessings.

Can’t catch Web3.js’ contract error when calling a method and cancelling the transaction

I have a very simple React app that calls a Solidity smart contract’s method using Web3.js (4.3.2) with some data coming from a form. I’m trying to catch errors while calling the contract method or sending the transaction, such as the user closing the wallet modal, in order to display an error message.

This is the setup code (simplified):

window.ethereum.request({ method: "eth_requestAccounts" });

const web3 = new Web3(window.ethereum);

const factoryCampaignContract = new web3.eth.Contract(CAMPAIGN_ABI, CAMPAIGN_ADDRESS);

In the form’s submit handler I’ve tried 3 different options to catch the error.

try-catch

try {
  const receipt = await factoryCampaignContract.methods
    .createCampaign(minimumContribution)
    .send({ from: accounts[0] });
} catch(err) {
  console.log(err);
}

.then() + .catch()

factoryCampaignContract.methods
  .createCampaign(minimumContribution)
  .send({ from: accounts[0] })
  .then(receipt => console.log(receipt))
  .catch(err => console.log(err));

send()‘s PromiEvents

factoryCampaignContract.methods
  .createCampaign(minimumContribution)
  .send({ from: accounts[0] })
  .on('transactionHash', (hash) => console.log(hash))
  .on('confirmation', (confirmationNumber) => console.log(confirmationNumber))
  .on('receipt', (receipt) => console.log(receipt))
  .on('error', (error) => console.log(error));

As soon as I close the wallet modal, I see the following error in the console, but none of the blocks above where the error should have been caught are actually invoked:

Uncaught (in promise) Error: User rejected the request.
  at ap.<anonymous> (<anonymous>:7:4040)
  at Generator.next (<anonymous>)
  at u (<anonymous>:1:1048)

useLocation hook have bugs when I reload page

I use useLocation to get data from url, first time it worked fine. But when I reload page, string search of location will contain encode string.

Is this what the useLocation hook does?

first load
after reload

import React from 'react';
import { BrowserRouter as Router, Route, Link, Switch, useHistory, useLocation } from 'react-router-dom';

function Home() {
  const history = useHistory();

  const handleSearch = () => {
    history.push('/search?q=test 123'); 
  };

  return (
    <div>
      <button onClick={handleSearch}>Search "test 123"</button>
    </div>
  );
}

function SearchResults() {
  const location = useLocation();
  console.log(location);
  const search = location.search;
  const queryParams = new URLSearchParams(search);
  const query = queryParams.get('q');

  return (
    <div>
      <h2>Search Results</h2>
      <p>Displaying search results for: {query}</p>
    </div>
  );
}

function App() {
  return (
    <Router>
      <div>
        <nav>
          <ul>
            <li>
              <Link to="/">Home</Link>
            </li>
            <li>
              <Link to="/search?q=react test">Search</Link>
            </li>
          </ul>
        </nav>

        <Switch>
          <Route path="/" exact component={Home} />
          <Route path="/search" component={SearchResults} />
        </Switch>
      </div>
    </Router>
  );
}

export default App;

I want to know what’s going on here, why is it like that.

How to normalize the array of object for performance

I’m trying to learn Normalization concept using object. I’m having doubt in that

Normal Array of Object:

const state = {
users: [
    { id: 1, name: "Alice", posts: [{ id: 101, title: 'Post 1', comments: [{ id: 202, text: 'comment 2' }, { id: 201, text: 'comment 1' }] }] },
    { id: 2, name: "Bob", posts: [{ id: 102, title: 'Post 2', comments: [{ id: 202, text: 'comment 2' }] }] }
],
tags: [
    { id: 301, name: 'Tech', posts: [{ id: 101, title: 'Post 1' }, { id: 102, title: 'Post 2' }] },
     
]}

Normalized structure

const state1 = {
users: {
    byIds: {
        1: { id: 1, name: "Alice", posts: [101] },
        2: { id: 2, name: "Bob", posts: [102] }
    },
    allIds: [1, 2]
},
posts: {
    byIds: {
        101: { id: 101, title: 'Post 1', comments: [201] },
        102: { id: 102, title: 'Post 2', comments: [202] }
    },
    allIds: [101, 102]
},
comments: {
    byIds: {
        201: { id: 201, text: 'comment 1' },
        202: { id: 202, text: 'comment 2' }
    },
    allIds: [201, 202]
},
tags: {
    byIds: {
        301: { id: 301, name: 'Tech', posts: [101, 102] },
        302: { id: 302, name: 'Travel', posts: [102] }
    },
    allIds: [301, 302]
}}

Now, inside normalized structure

state1.tags.byIds[‘302’] = { id : 302, name: ‘Travel’ , posts:[102] }

inside posts [102] value it has,

state1.posts.byIds[‘102’] = { id : 102 , title: ‘Post 2’, comments: [202] }

inside comments[202] value will be like this

state1.posts.comments[‘202’] = { id : 202, title: ‘comment 2’ }


so the normalised output of tags[302] value will be

{ id: 302, name: 'Travel', posts: { id: 102, title: 'Post 2', comments: { id: 202, text: 'comment 2' } } }

but in the non-normalized structure tags 302 value will be

{ id: 302, name: 'Travel', posts: [{ id: 101, title: 'Post 1' }] } 

This both output is not same, how to normalize it correctly to get the same output ?

how to get values from 2 dropdown in javascript?

newbie here. I was wondering if you can help me figure this out. How do I get the array of dropdwon values and pass that value into js. I have only 2 values coming from the database which is the from (date started) and To (date ended). made a loop to display the date range.

front-end

Front-end view

here is my script

script

how do I loop so that it will return the specific value for each dropdown value?

thanks in advance

tried to have displayed the value of the dropdown I have chosen, however I am supposed to get the vaue per cell. what happened was I can only get whatever value I have chosen first and not on per cell

How to Extract the value on a auto suggestive dropdown using Javascript in selenium

I want to particularly solve this problem using javascript executor which am not very familiar with. I have a auto suggestive dropdown(not select) where am sending sendkeys("ind") and using keysdown am iterating through the options.

Autosuggestive dropdown HTML:
<input type="text" id="autocomplete" class="inputs ui-autocomplete-input" placeholder="Type to Select Countries" autocomplete="off">

The dropdown options HTML:
<ul id="ui-id-1" tabindex="0" class="ui-menu ui-widget ui-widget-content ui-autocomplete ui-front" style="display: none; top: 325.792px; left: 264.52px; width: 231px;"> <li class="ui-menu-item"><div id="ui-id-81" tabindex="-1" class="ui-menu-item-wrapper">British Indian Ocean Territory</div></li><li class="ui-menu-item"><div id="ui-id-82" tabindex="-1" class="ui-menu-item-wrapper">India</div></li>
<li class="ui-menu-item"><div id="ui-id-83" tabindex="-1" class="ui-menu-item-wrapper">Indonesia</div></li></ul>

TODO Auto-generated method stub

driver.get("https://rahulshettyacademy.com/AutomationPractice/");

JavascriptExecutor js = (JavascriptExecutor) driver;    

int count = 0;

WebElement autocomplete = driver.findElement(By.id("autocomplete"));

trying to send the text via senkeys & keysdown

driver.findElement(By.id("autocomplete")).sendKeys("ind");

driver.findElement(By.id("autocomplete")).sendKeys(Keys.DOWN);

this is the lie with issue. am trying to fetch the values of the HTML
tag with dropwdown options. how should this line be corrected?

String actualValue = (String) js.executeScript("return Document.querySelectorAll('#ui-id-1 li');");


while (!actualValue.equals("India")) {

driver.findElement(By.id("ui-id-1")).sendKeys(Keys.DOWN);
driver.findElement(By.id("ui-id-1")).sendKeys(Keys.ENTER);

count++;
Thread.sleep(1000); 

System.out.println(count);

if (!actualValue.equalsIgnoreCase("india")) {
String d = "return document.querySelectorAll('#ui-id-1 li');";

String n = (String) js.executeScript(d);

System.out.println(n);

System.out.println(count);

Render list of arrays inside an object into divs with up to four items in React

I have an object like this:

export const dataEstrenos = [
    {
      id: 1, product: "any product", title: "any title"
    },
    {
      id: 2, product: "any product", title: "any title"
    },
    {
      id: 3, product: "any product", title: "any title"
    },
    {
      id: 4, product: "any product", title: "any title"
    },
    {
      id: 5, product: "any product", title: "any title"
    },
    {
      id: 6, product: "any product", title: "any title"
    },
    {
      id: 7, product: "any product", title: "any title"
    }  
  ];

I want to display items in groups of four elements inside a container div, like this:

<div>
    <div>Here data from first item</div>      
    <div>Here data from second item</div>      
    <div>Here data from third item</div>      
    <div>Here data from fourth item</div> 
</div>
<div>      
    <div>Here data from fifth item</div>      
    <div>Here data from sixth item</div>     
    <div>Here data from seventh item</div>
</div>

…Items inside object may be any quantity, and the last container div may not have four items depending on how many items are left in the array/object (like the example above).

How can I achieve this in react? I am new to React so my attempts to achieve this are not worth showing here. Thank you!

How do I code a pair of CSS stylesheet change buttons (one button for each stylesheet) in my HTML document?

I have an HTML sheet I created for a fictional business website as part of an assignment last week for my Internet GIS class. My assignment this week (due tonight at 11:59 PM MST) is to improve upon the page in two of four ways listed on the assignment’s Canvas page, the two ways I chose being to use Javascript to change HTML styles (option #3) via an interactive button (option #4). I’ve decided to do this by duplicating my original CSS stylesheet and replacing the normal-contrast color names therein (background color: linen; text color: maroon) to high-contrast color names (background color: black; text color: yellow). I tried a one-button solution but couldn’t figure out how to make it work, so I’ve now decided to try a two-button solution. However, I’m still just as stumped with getting a two-button solution to work. I’ve been unable to find any useful information elsewhere on the internet, so I thought I’d ask you all here for help. I’m including my HTML page’s code below, but will be changing the name of the business and CEO for privacy purposes (the business is named after myself).

<!DOCTYPE html>
<html>
<head>
<title>Services – John Smith Consulting</title>
<link rel="stylesheet" type="text/css" href="JohnSmith_InternetGIS_SP2024_Lab121.css id="theme1">
<link rel="stylesheet" type="text/css" href="JohnSmith_InternetGIS_SP2024_Lab122.css" id="theme2">

</head>
<body>

<button type="button">Switch to high contrast</button>
<button type="button">Switch to regular colors</button>


<h1>Our Services</h1>
<p1>We offer cartography using ArcGIS Pro and web app development using ArcGIS Online.</p1>

<h2>Service Requirements</h2>
<p2>All we ask is that you simply provide us with GIS data up front. We here at John Smith Consulting are either fresh out of college or otherwise inexperienced with GIS outside of a classroom environment.</p2>

<h2>Which File Types do We Accept?</h2>
<p2>We accept any file type compatible with ArcGIS Pro or ArcGIS Online, including but not limited to</p2>
<ul>
  <li>Shapefiles – SHP</li>
  <li>Comma Separated Values files – CSV</li>
  <li>GeoJSON files</li>
  <li>Layer package files – LPK</li>
</ul>

<h2>Examples of Past Projects</h2>
<img src="C:UserssmithOneDrivePicturesScreenshotsJohnSmith-UCCS-InternetGIS-SP2024-Lab11-Screenshot1.png" style="width:320px;height:180px;">
<a href="https://experience.arcgis.com/experience/7db76a91198841349a8ccd6c005537c1/">World War II Naval Battles and Shipwrecks ArcGIS Web Experience</a>

<h1>Our CEO</h1>
<img src="C:UserssmithOneDrivePicturesJohnSmith_Selfie_04042023.jpg" alt="JohnSmith" style="width:290px;height:386px;">
<p1>John Smith is the CEO of John Smith Consulting, which he founded on 15 May 2024 after graduating from the University of Colorado Colorado Springs with a BA in Geography and a GIS certificate.</p1>

JavaScript Triangles Not Scaling Correctly

I am working on a an effect that create many point and triangulates them to create a simple background animation. However, when I try to scale them down, not all lines are scaled accordingly and are often mismatched.

Here is the code that creates everything

const numNodes = 40;

let ac = [];
let moveAC = [];


const gradient = {
    len: 6,
    gradients: [
        [225, 238, 88],
        [0, 188, 212],
        [229, 115, 115],
        [74, 20, 140],
        [129, 199, 132],
        [255, 255, 255]
    ]
}

let grad1 = Math.round(Math.random() * (gradient.len - 1));
let grad2 = Math.round(Math.random() * (gradient.len - 1));

while (grad1 == grad2) {
    grad2 = Math.round(Math.random() * (gradient.len - 1));
}

console.log(grad1, grad2);

grad1 = gradient.gradients[grad1];
grad2 = gradient.gradients[grad2];

function initialize_background() {
    for (let i = 0; i < numNodes; i++) {
        let posX = Math.random() * 100;
        let posY = Math.random() * 100;
        let coord = [posX, posY]
        ac.push(coord);

        let vecX = Math.random() * 2 - 1;
        let vecY = Math.random() * 2 - 1;
        let vector = [vecX, vecY];
        moveAC.push(vector);
    }

    let edgeSmooth = 10;

    for (let i = 1; i < edgeSmooth; i++) {
        let pos = (i / edgeSmooth) * 100;
        ac.push([pos, 0]);
        ac.push([pos, 100]);
        ac.push([0, pos]);
        ac.push([100, pos]);
        moveAC.push([0, 0]);
        moveAC.push([0, 0]);
        moveAC.push([0, 0]);
        moveAC.push([0, 0]);
    }

    ac.push([0, 0]);
    ac.push([0, 100]);
    ac.push([100, 0]);
    ac.push([100, 100]);
    moveAC.push([0, 0]);
    moveAC.push([0, 0]);
    moveAC.push([0, 0]);
    moveAC.push([0, 0]);

    updateBackground();
}

function updateElementPosition(element, index) {
    let speed = 0.1;
    let newX = element[0] + moveAC[index][0]*speed;
    let newY = element[1] + moveAC[index][1]*speed;

    newX = (newX < 0)? 100 : ((newX > 100)? 0 : newX);
    newY = (newY < 0)? 100 : ((newY > 100)? 0 : newY);

    ac[index] = [newX, newY];
}

async function updateBackground() {
    document.querySelectorAll(".triangle").forEach((element) => {
        element.remove();
    });

    for (let i = 0; i < ac.length; i++) {
        updateElementPosition(ac[i], i);
    }

    let triangles = orderCoordinatesToTriangles();

    const docFrag = document.createDocumentFragment();

    triangles.forEach((element) => {
         let child = createTriangle(ac[element[0]], ac[element[1]], ac[element[2]], element[4]);
         if (child != null) docFrag.appendChild(child);
    });

    document.getElementById("background-container").appendChild(docFrag);

    await delay(25);
    updateBackground();
    
}

function orderCoordinatesToTriangles() {
    let triangles = [];
    for (let e1 = 0; e1 < ac.length; e1 ++) {
        for (let e2 = e1+1; e2 < ac.length; e2 ++) {
            for (let e3 = e2+1; e3 < ac.length; e3 ++) {
                let coord = sortToCounterClockwise(e1, e2, e3, ac);
                let anyPointsWithin = false;

                for (let e4 = 0; e4 < ac.length; e4 ++) {
                    if (e1 == e4 || e2 == e4 || e3 == e4) {
                        continue;
                    }
                    if (calculateDeterminant3x3(coord, e4)) {
                        anyPointsWithin = true;
                        break;
                    }
                }

                if (!anyPointsWithin) {
                    triangles.push(coord);
                }
            }
        }
    }

    return triangles;
}

function calculateDeterminant3x3(coord, e4) {
    const ax = ac[(coord[0])][0];
    const ay = ac[coord[0]][1];
    const bx = ac[coord[1]][0];
    const by = ac[coord[1]][1];
    const cx = ac[coord[2]][0];
    const cy = ac[coord[2]][1];
    const dx = ac[e4][0];
    const dy = ac[e4][1];

    const det1 = (ax-dx) * calculateDeterminant2x2((by-dy), calcDifferentDet(bx, dx, by, dy), (cy-dy), calcDifferentDet(cx, dx, cy, dy));
    const det2 = (ay-dy) * calculateDeterminant2x2((bx-dx), calcDifferentDet(bx, dx, by, dy), (cx-dx), calcDifferentDet(cx, dx, cy, dy));
    const det3 = calcDifferentDet(ax, dx, ay, dy) * calculateDeterminant2x2((bx-dx), (by-dy), (cx-dx), (cy-dy));

    const result = det1 - det2 + det3;
    return (result > 0);
}

// returns (e1 - e2)^2 + (e3 - e4)^2
function calcDifferentDet(e1, e2, e3, e4) {
    return Math.pow(e1 - e2, 2) + Math.pow(e3 - e4, 2);
}

// | e1, e2 |
// | e3, e4 |
function calculateDeterminant2x2(e1, e2, e3, e4) {
    return ((e1 * e4) - (e2*e3));
}

function sortToCounterClockwise(e1, e2, e3, ac) {
    let coord = [];
    const centerX = (ac[e1][0] + ac[e2][0] + ac[e3][0])/3;
    const centerY = (ac[e1][1] + ac[e2][1] + ac[e3][1])/3;

    let angle1 = get_angle([ac[e1][0] - centerX, ac[e1][1] - centerY]);
    let angle2 = get_angle([ac[e2][0] - centerX, ac[e2][1] - centerY]);
    let angle3 = get_angle([ac[e3][0] - centerX, ac[e3][1] - centerY]);

    if (angle1 < 90) angle1 += 360;
    if (angle2 < 90) angle2 += 360;
    if (angle3 < 90) angle3 += 360;

    if (angle1 < angle2 && angle1 < angle3) {
        coord.push(e1);
        if (angle2 < angle3) {coord.push(e2); coord.push(e3);}
        else {coord.push(e3); coord.push(e2);}
    }
    else if (angle2 < angle1 && angle2 < angle3) {
        coord.push(e2);
        if (angle1 < angle3) {coord.push(e1); coord.push(e3);}
        else {coord.push(e3); coord.push(e1);}
    }
    else {
        coord.push(e3);
        if (angle1 < angle2) {coord.push(e1); coord.push(e2);}
        else {coord.push(e2); coord.push(e1);}
    }

    coord.push(centerX);
    coord.push(centerY);

    return coord;
}

const getScale = (cX, cY, pX, pY, s) => {
    sSx = window.innerWidth;
    sSy = window.innerHeight;

    v = make_vector([pX, pY], [cX, cY]);
    u = unit_vector(v);

    return (pX + s*u[0])*sSx/100 + "px " + (pY+ s*u[1])*sSy/100 + "px";
}

function createTriangle(p1, p2, p3, centerY) {
    const newTriangle = document.createElement("div");
    newTriangle.className = "triangle";
    let cX = (p1[0] + p2[0] + p3[0]) / 3;
    let cY = ((p1[1]) + (p2[1]) + (p3[1])) / 3;
    let scale = 0.2;
    
    coord1 = getScale(cX, cY, p1[0], (p1[1]), scale);
    coord2 = getScale(cX, cY, p2[0], (p2[1]), scale);
    coord3 = getScale(cX, cY, p3[0], (p3[1]), scale);
    newTriangle.style.backgroundColor = "rgb(" + colourFunction(0, centerY) + ", " + colourFunction(1, centerY) + ", " + colourFunction(2, centerY) + ")";
    newTriangle.style.clipPath = "polygon(" + coord1 + ", " + coord2 + ", " + coord3 + ")";

    if (!newTriangle.style.clipPath) {
        return null;
    }

    return newTriangle;
}

function colourFunction(i, cY) {
    return (grad1[i] + ((grad2[i] - grad1[i]) * (1 - (cY / 100))));
}

And the code for the vectors is as follows

//Turn current position into a vector given a vector matrix
const get_vector = (e1, e2, a) => {
    const wa = a[e2][1] - a[e1][1];
    const wb = a[e2][0] - a[e1][0];
    return [wb, wa];
};

//make a vector given arrays
const make_vector = (e1, e2) => {
    const wa = e2[1] - e1[1];
    const wb = e2[0] - e1[0];
    return [wb, wa];
};

//Get current width of a vector
const get_width = (v) => {
    const wa = Math.pow(v[0], 2);
    const wb = Math.pow(v[1], 2);
    return Math.sqrt(wa + wb);
};


//Get current angle of a vector with the line <1, 0>
const get_angle = (v) => {
    let angle = Math.acos((v[0] / get_width(v)))*180/Math.PI;
    if (v[1] < 0) {angle = 360 - angle;}
    return angle;
};

//get unit vector
const unit_vector= (v) => {
    let width = get_width(v);
    return [v[0]/width, v[1]/width];
};

However, I get something similar to this as the following output
Single frame of the animation

Some boarders are thicker than others, and I’m not sure what the issue is