v-model not working with in Vue 3?

Why isn’t v-model binding to my input in the example below? Is there a limitation of <component>?

<script setup>
import { ref } from 'vue'

const config = ref({
  headers: [
    { field: 'id', label: 'Id', component: { type: 'input' } }, 
    { field: 'name', label: 'Name', component: { type: 'input' }  }
  ],
  data: [
    { id: 1, name: 'foo' },
    { id: 2, name: 'bar' }
  ]
})
</script>

<template>
  <table>
    <tr>
      <td v-for="header in config.headers">
        <b>{{ header.label }}</b>
      </td>
    </tr>
    <tr v-for="item in config.data">
      <td v-for="header in config.headers">
        <component :is="header.component.type" v-model="item[header.field]" />
      </td>
    </tr>
  </table>
  {{ config.data }}
</template>

Images not showing up in Vs Code folder or the browser when i link it on HTML or CSS from my path?

enter image description hereI want my images to show-up on my browser. But they don’t because for some reason the path is not either found or maybe writing it wrong.

I tried this multiple times, and not only in one project but multiple.
Usually on my CSS i would it as my background and it doesn’t show on the browser. I used developer tools but it show no error even the syntax. Also it does not show where the image folder is, i think that’s one of the problem.

React retain UI state of component instead of destroying and recreating every time

I have various components/sections on my page and at a time, only 1 section is supposed to be visible to the user. User clicks on different tabs to access the respective sections. As of now, my components are dynamically destroyed and shown based on the tab that is clicked.

{mySection1 && <div><MySection1 {...props} /></div>}
{mySection2 && <div><MySection2 {...props} /></div>}

Now the issue is within each section, there are different form fields and they even display inline error based on some validations (e.g. mandatory, regex, etc)

Now since I destroy and recreate the component on each tab click, I kind of loose the earlier component state and am finding it difficult to retain (e.g. retain the inline error on a field if user clears out a mandatory field)

I am trying to see if there can be another way to retain the UI state.

It would be great if someone could point out any reference example where I can try leveraging React.memo to somehow cache the UI state
Other is not sure if we can use visibility: hidden so that the component is not destroyed.

Three Js – Database for Model

Good day, everyone
Currently I am working on website implemented with Three.js, but I am curious about is that any suitable platform or online database to store the 3D model file and the website database together if possible?

I would be very appreciated it!

Currently I am using local storage for the website and host it on www.000webhost.com but I found that the web host did not provide option or way to upload model directly from my website

Polyline Tooltip disappears under Polygone – Leaflet

I´m struggling a bit with my tooltip for polylines.
I call them like this way:

 var Strecken = L.geoJSON(lineJson,{
        color: '#6a6a6a',
        weight: '1', 
        opacity: '1',
    }).bindTooltip(function (layer){
        return "Streckennummer: " + layer.feature.properties.STRECKE_NR + "</br>" + "Strecke: " + layer.feature.properties.STRECKE_KU + "</br>" + "Elektrfizierung: " + layer.feature.properties.ELEKTRIFIZ + "</br>" + "Gleisanzahl: " + layer.feature.properties.GLEISANZAH;
    },
    {className: 'popuptooltip'}).addTo(map);
    map.removeLayer(Strecken)

The tooltip is working fine, but only as long as my polygone layers are not chosen.
So while I have my polygones activated at the same time, the tooltip on my polylines doesn´t appear.

I tried to set them to different pane levels (polylines above polygones), but it didn´t solved the problem.
It´s kinda weird for me, because the point data aren´t affected from my polygones.

Any suggestions? Would be nice, thanks!

stream chat reset api

  1. uniapp use stream-chat-js. Running on a mobile phone, openning error Formdata is not defined
  2. uniapp use rest-api。 What is not in the United States, the request address?

Help me solve these problems, thank you

System vs User account. Why is one of them not working?

I’ve saw something strange. When I use VScode and I try to create package.json file it won’t visualize if the file I’m working in is in a system user folder. It shows the package.json in the terminal but do not create the actual file in the folder. But when the file I’m working on is in user (person) folder it will create it. What can be the problem and how can i fix that?

Nothing shows on internet about this exact problem.

How to insert a jsonNode as a value to another jsonNode in java

I have a csv file,
Employee: Salutation,LegalEntityId,FirstName,MiddleName,LastName,DisplayName,WorkPhoneCountryCode,WorkPhoneAreaCode,WorkPhoneNumber,WorkMobilePhoneCountryCode,WorkMobilePhoneAreaCode,WorkMobilePhoneNumber,HomeFaxCountryCode,HomeFaxAreaCode,HomeFaxNumber,HomePhoneCountryCode,HomePhoneAreaCode,HomePhoneNumber,NameSuffix,NationalIdExpirationDate,WorkEmail,AddressLine1,AddressLine2,AddressLine3,City,Region,Region2,Country,PostalCode,CitizenshipLegislationCode,CitizenshipStatus,PassportNumber,PassportIssueDate,Religion,LicenseNumber,DateOfBirth,Ethnicity,Gender,MaritalStatus,NationalIdCountry,NationalId,NationalIdType,UserName,AssignmentName,BusinessUnitId,JobId,WorkerCategory,AssignmentCategory,WorkingAtHome,WorkingAsManager,SalaryCode,WorkingHours,Frequency,SalaryAmount,SalaryBasisId,ActionCode,ActionReasonCode,AssignmentStatus,ManagerType
MS.,3.00E+14,Ciran,Myle,Machell,Ciran Myle Machell,1,1,781-993-0000,1,1,581-993-0000,1,1,1111664,1,1,122933334,Jr.,1027428,[email protected],Oracle Corporation,500 Oracle Parkway,null,San Francisco,San Francisco,CA,US,94123,US,A,11553397,37621,CHRISTIAN,9955501858,33033,8,F,S,US,254-44-3022,SSN,MachellCira,Analyst,3.00E+14,3.00E+14,WC,FR,N,N,H,12,D,100000,3.00E+14,HIRE,NEWHIRE,ACTIVE,LINE_MANAGER

Please help me modify the code get the output of the form,

{
  "Salutation" : "MS.",
  "LegalEntityId" : "300100003448002",
  "FirstName": "Miranda",
  "MiddleName": "Kyle",
  "LastName": "Rachell",
  "DisplayName" : "Miranda Kyle Rachell",
  "WorkPhoneCountryCode" : "1",
  "WorkPhoneAreaCode" : "1",
  "WorkPhoneNumber" : "781-993-0000",
  "WorkMobilePhoneCountryCode" : "1",
  "WorkMobilePhoneAreaCode" : "1",
  "WorkMobilePhoneNumber" : "581-993-0000",
  "HomeFaxCountryCode":"1",
  "HomeFaxAreaCode":"1",
  "HomeFaxNumber":"1111663",
  "HomePhoneCountryCode":"1",
  "HomePhoneAreaCode":"1",
  "HomePhoneNumber":"122993333",
  "NameSuffix":"Jr.",
  "NationalIdExpirationDate" : "4712-12-31",    
  "WorkEmail" : "[email protected]",
  "AddressLine1" : "Oracle Corporation",
  "AddressLine2" : "500 Oracle Parkway",
  "AddressLine3" : null,
  "City" : "San Francisco",
  "Region" : "California",
  "Region2" : null,
  "Country" : "US",
  "PostalCode": "94065",
  "CitizenshipLegislationCode" : "US",
  "PassportNumber" : "11557799",
  "PassportIssueDate" : "2002-12-31",
  "Religion" : "CHRISTIAN",
  "LicenseNumber" : "9955500858",
  "DateOfBirth": "1990-09-09",
  "Ethnicity": "8",
  "Gender" : "F",
  "MaritalStatus" : "S",
  "NationalIdCountry": "US",
  "NationalId": "554-44-3025",
  "NationalIdType": "SSN",
  "UserName":"rachell",
  **"assignments" :  **
    [
    {
     "AssignmentName": "Rachell_Assignment_1",
     "BusinessUnitId" : "202",
     "JobId" : "18",
     "WorkerCategory" : "WC",
     "AssignmentCategory" : "FR",
     "WorkingAtHome" : "N",
     "WorkingAsManager" : "N",
     "SalaryCode" : "H",
     "WorkingHours" : "12",
     "Frequency" : "D",
     "SalaryAmount" : "100000",
     "SalaryBasisId" : "100010024999994",
     "ManagerAssignmentId" : "389",
     "ManagerId" : "383",
     "ActionCode" : "HIRE", 
     "ActionReasonCode" : "NEWHIRE",
     "AssignmentStatus" : "ACTIVE",
     "WorkTaxAddressId" : "300100011952957",
     "ManagerType" : "LINE_MANAGER" 
     }
     ]
}

The data given is a demo data. I am not that into Java.

The code is given below

package post;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.io.BufferedInputStream;
import org.apache.commons.io.IOUtils;
import java.io.InputStream;
//import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class PostEmployee {
    public static void main(String[] args) throws IOException {
        String file1Path = "Employee.csv";
        String username = "hcm_imp9";
        String password = "pwd";
        
        List<JsonNode> jsonArray = new ArrayList<>();
        BufferedReader br = new BufferedReader(new FileReader(file1Path));
        String line;
        JsonNode jsonObject;
        String[] headers = null;
        while ((line = br.readLine()) != null) {
            String[] values = line.split(",");
            if (headers == null) {
                headers = values;
            } else {
                ObjectMapper objectMapper = new ObjectMapper();
                jsonObject = objectMapper.convertValue(headersZip(values, headers), JsonNode.class);
                jsonArray.add(jsonObject);
            }
        }
            br.close();
       
        String jsonString = jsonArray.toString();
        jsonString = jsonString.replace(":", ": ");
        System.out.println(jsonString);
        }
private static JsonNode headersZip(String[] values, String[] headers) {
    if (values == null || headers == null || values.length != headers.length) {
        return null;
    }
    ObjectMapper objectMapper = new ObjectMapper();
    JsonNode json = objectMapper.createObjectNode();
    for (int i = 0; i < values.length; i++) {
        ((ObjectNode) json).put(headers[i], values[i]);
    }
    return json;
}
            }

The Result:

[{"Salutation": "MS.","LegalEntityId": "3.00E+14","FirstName": "Ciran","MiddleName": "Myle","LastName": "Machell","DisplayName": "Ciran Myle Machell","WorkPhoneCountryCode": "1","WorkPhoneAreaCode": "1","WorkPhoneNumber": "781-993-0000","WorkMobilePhoneCountryCode": "1","WorkMobilePhoneAreaCode": "1","WorkMobilePhoneNumber": "581-993-0000","HomeFaxCountryCode": "1","HomeFaxAreaCode": "1","HomeFaxNumber": "1111664","HomePhoneCountryCode": "1","HomePhoneAreaCode": "1","HomePhoneNumber": "122933334","NameSuffix": "Jr.","NationalIdExpirationDate": "1027428","WorkEmail": "[email protected]","AddressLine1": "Oracle Corporation","AddressLine2": "500 Oracle Parkway","AddressLine3": "null","City": "San Francisco","Region": "San Francisco","Region2": "CA","Country": "US","PostalCode": "94123","CitizenshipLegislationCode": "US","CitizenshipStatus": "A","PassportNumber": "11553397","PassportIssueDate": "37621","Religion": "CHRISTIAN","LicenseNumber": "9955501858","DateOfBirth": "33033","Ethnicity": "8","Gender": "F","MaritalStatus": "S","NationalIdCountry": "US","NationalId": "254-44-3022","NationalIdType": "SSN","UserName": "MachellCira","AssignmentName": "Analyst","BusinessUnitId": "3.00E+14","JobId": "3.00E+14","WorkerCategory": "WC","AssignmentCategory": "FR","WorkingAtHome": "N","WorkingAsManager": "N","SalaryCode": "H","WorkingHours": "12","Frequency": "D","SalaryAmount": "100000","SalaryBasisId": "3.00E+14","ActionCode": "HIRE","ActionReasonCode": "NEWHIRE","AssignmentStatus": "ACTIVE","ManagerType": "LINE_MANAGER"}]

The Desired Output:

{
  "Salutation" : "MS.",
  "LegalEntityId" : "300100003448002",
  "FirstName": "Miranda",
  "MiddleName": "Kyle",
  "LastName": "Rachell",
  "DisplayName" : "Miranda Kyle Rachell",
  "WorkPhoneCountryCode" : "1",
  "WorkPhoneAreaCode" : "1",
  "WorkPhoneNumber" : "781-993-0000",
  "WorkMobilePhoneCountryCode" : "1",
  "WorkMobilePhoneAreaCode" : "1",
  "WorkMobilePhoneNumber" : "581-993-0000",
  "HomeFaxCountryCode":"1",
  "HomeFaxAreaCode":"1",
  "HomeFaxNumber":"1111663",
  "HomePhoneCountryCode":"1",
  "HomePhoneAreaCode":"1",
  "HomePhoneNumber":"122993333",
  "NameSuffix":"Jr.",
  "NationalIdExpirationDate" : "4712-12-31",    
  "WorkEmail" : "[email protected]",
  "AddressLine1" : "Oracle Corporation",
  "AddressLine2" : "500 Oracle Parkway",
  "AddressLine3" : null,
  "City" : "San Francisco",
  "Region" : "California",
  "Region2" : null,
  "Country" : "US",
  "PostalCode": "94065",
  "CitizenshipLegislationCode" : "US",
  "PassportNumber" : "11557799",
  "PassportIssueDate" : "2002-12-31",
  "Religion" : "CHRISTIAN",
  "LicenseNumber" : "9955500858",
  "DateOfBirth": "1990-09-09",
  "Ethnicity": "8",
  "Gender" : "F",
  "MaritalStatus" : "S",
  "NationalIdCountry": "US",
  "NationalId": "554-44-3025",
  "NationalIdType": "SSN",
  "UserName":"rachell",
  **"assignments" :  **
    [
    {
     "AssignmentName": "Rachell_Assignment_1",
     "BusinessUnitId" : "202",
     "JobId" : "18",
     "WorkerCategory" : "WC",
     "AssignmentCategory" : "FR",
     "WorkingAtHome" : "N",
     "WorkingAsManager" : "N",
     "SalaryCode" : "H",
     "WorkingHours" : "12",
     "Frequency" : "D",
     "SalaryAmount" : "100000",
     "SalaryBasisId" : "100010024999994",
     "ManagerAssignmentId" : "389",
     "ManagerId" : "383",
     "ActionCode" : "HIRE", 
     "ActionReasonCode" : "NEWHIRE",
     "AssignmentStatus" : "ACTIVE",
     "WorkTaxAddressId" : "300100011952957",
     "ManagerType" : "LINE_MANAGER" 
     }
     ]
}```

Live stream a react component

Is it possible to live stream (youtube) a specific react component? I have some financial charts using web sockets that I would like to put on a live youtube channel, but not sure where to start.

I can only find documentation and packages around youtube to react, rather than the other way around.


I know that I could make my webcam stream my desktop and broadcast live that way, but I still need to use my computer and don’t want to show mouse movements, different tabs etc.

Thanks

TCP Communications on Browser

I am porting an Electron app for use in a static browser page (basically an html file and will be ran using the file:// protocol).

This Electron app is communicating with another app through TCP (127.0.0.1:port). For NodeJS, I am using the net module and it works perfectly fine.

But then, net module is not accessible in the browser and I can’t seem to find a module that supports TCP protocol on the browser (I’ve read that there is chrome tcp sockets, but it is already deprecated). Then there is also new technologies such as WebTransport but it feels like it is still in its very early stages and it seems to be using the http protocol somehow.

Instead, I tried using the native browser API for WebSockets (client-side). A pre-requisite for this is I need to run a server, so I used wc to create a server on the node side.

Now, my problem is, how can the external app (desktop app built using python) communicate with my server using TCP?

Another option I think I have is just create a local server using express and Axios and then still retain the TCP connectivity on the server side. I will use REST API to communicate between server-client.

But is there any other way to do this? Any other modules/technologies that allow using TCP on the browser?

Is it possible to implement this in React?

https://codepen.io/quill/pen/qNJMYB

I’m trying to implement this codepen in React Typescript but I’m getting so many bugs to the extent where if I post the code here, I think it’ll actually set people 10 steps back.

How do I go about re-implementing this in React from the start? I would put a bounty but i don’t have enough :/

this is the last stable version of my code

import React, { useRef, useEffect } from 'react';
import Quill, { RangeStatic } from 'quill';
import 'quill/dist/quill.snow.css';

interface Props {
  content: string;
  onChange: (value: string) => void;
}

const Editor2: React.FC<Props> = ({ content, onChange }) => {
    const editorRef = useRef<HTMLDivElement>(null);
    const toolbarRef = useRef<HTMLDivElement>(null);

    useEffect(() => {
        if (editorRef.current) {
            const editor = new Quill(editorRef.current, {
                theme: 'snow',
                modules: {
                    
                    toolbar: [
                        ["bold", "italic", "underline", "strike"],
                        ["blockquote", "code-block"],
                        [{ header: 1 }, { header: 2 }],
                        [{ list: "ordered" }, { list: "bullet" }],
                        [{ script: "sub" }, { script: "super" }],
                        [{ indent: "-1" }, { indent: "+1" }],
                        [{ direction: "rtl" }],
                        [{ size: ["small", false, "large", "huge"] }],
                        [{ header: [1, 2, 3, 4, 5, 6, false] }],
                        [{ color: [] }, { background: [] }],
                        [{ align: [] }],
                        ["clean"],
                    ],
                },
            });

            editor.on('text-change', () => {
                onChange(editor.root.innerHTML);
            });

            editor.root.style.backgroundColor = 'black';

            editor.root.addEventListener('mouseup', () => {
                const selection = editor.getSelection() as RangeStatic;
                if (selection && selection.length > 0) {
                    toolbarRef.current?.classList.add('show-toolbar');
                    // toolbarRef.current &&  toolbarRef.current?.style.top = `${selection.y + selection.height}px`;
                    // toolbarRef.current && toolbarRef.current.style.left = `${selection.x + selection.width / 2}px`;
                } else {
                    toolbarRef.current?.classList.remove('show-toolbar');
                }
            });

            editor.root.addEventListener('keydown', () => {
                toolbarRef.current?.classList.remove('show-toolbar');
            });

            editor.setContents(editor.clipboard.convert(content), 'silent');
        }
    }, []);

    const handleLink = () => {
        const url = window.prompt('Enter the URL');
        if (url) {
            const selection = (window as any).quill.getSelection() as RangeStatic;
            if (selection) {
                (window as any).quill.format('link', url);
            }
        }
    };

    return (
        <div>
            <div ref={toolbarRef} className="editor-toolbar">
                <button onClick={handleLink}>Link</button>
            </div>
            <div ref={editorRef} />
        </div>
    );
};

export default Editor2;

I’m a bit lost on how to implement the classes/blots.

Why .includes on string doesn’t detect lower case letters?

I wrote this to detect if the url contain this particular keyword i.e. recordId but if url contains it in lower i.e. recordid then it doesn’t detect.

How do I make them detect both because data can have both recordid or recordId.

if(url && url.includes("recordId") && url.includes("rt")){
      this._geRecordId(url);
    } 

 private async geRecordId(url){
    const linkedId = this._getURLValue('recordId' , url);
    if(!linkedId){
      return;
    }

private _getURLValue( name, url ) {
    if (!url) url = location.href;
    name = name.replace(/[[]/,"\[").replace(/[]]/,"\]");
    var regexS = "[\;]"+name+"=([^;]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( url );
    return results == null ? null : results[1];
 }

I tried changing regex

ImageData is different when getting one pixel

I am making a 2d light ray simulator with html canvas and i was creating a 1 pixel ImageData every time a ray moved so when i made it so it only created one at the start, it stopped working normally. The top is the old version that works and the bottom is the new version that doesn’t work. I expect it to do the same thing but in the new version the collisions are messed up.

const canvas = document.getElementById("canvas");
        const ctx = canvas.getContext("2d");
        var mouseX = 0;
        var mouseY = 0;

        canvas.width = innerWidth;
        canvas.height = innerHeight;

        ctx.fillStyle = "rgb(10, 10, 10)";
        ctx.strokeStyle = "rgba(255, 255, 0)";
        ctx.lineWidth = 3;

        ImageData.prototype.getPixel = function(x, y, offset) {
            return this.data[(y * this.width + x) * 4 + offset];
        };
        
        function drawLine(first, second) {
            ctx.beginPath();
            ctx.moveTo(first[0], first[1]);
            ctx.lineTo(second[0], second[1]);
            ctx.stroke();
        };
        function mousemove(e) {
            mouseX = e.clientX;
            mouseY = e.clientY;
        };
        function drawScene() {
            ctx.fillStyle = "rgba(50, 50, 50, 1)";
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            ctx.fillStyle = "rgba(10, 10, 10, 1)";

            ctx.fillRect(0, canvas.height-10, 200, 10);
            ctx.fillRect(0, canvas.height-210, 10, 200);
            ctx.fillRect(10, canvas.height-210, 200, 10);
            ctx.fillRect(200, canvas.height-190, 10, canvas.height-190);
        };
        drawScene();
        function render() {
            drawScene();
            let rays = [];
            var data;
            for (let angle = 0; angle < 360; angle += 3) { // for every ray
                let xv = Math.sin(angle*(Math.PI/180))*5;
                let yv = Math.cos(angle*(Math.PI/180))*5;
                let x = mouseX;
                let y = mouseY;
                let rayinitx = x;
                let rayinity = y;
                let collisions = 0;
                let opacity = 1;
                while (x > 0 && x < canvas.width && y > 0 && y < canvas.height) { // for every movement of every ray
                    x += xv;
                    data = ctx.getImageData(x, y, 1, 1);
                    let collide = false;
                    if (data.getPixel(0, 0, 0) === 10 && data.getPixel(0, 0, 1) === 10 && data.getPixel(0, 0, 2) === 10 && data.getPixel(0, 0, 3) === 255) {
                        xv *= -1;
                        x += xv;
                        collide = true;
                    };

                    y += yv;
                    data = ctx.getImageData(x, y, 1, 1);
                    if (data.getPixel(0, 0, 0) === 10 && data.getPixel(0, 0, 1) == 10 && data.getPixel(0, 0, 2) === 10 && data.getPixel(0, 0, 3) === 255) {
                        yv *= -1;
                        y += yv;
                        collide = true;
                    };
                    if (collide) {
                        rays.push([[rayinitx, rayinity], [x, y], opacity]);
                        opacity -= 1/5;
                        rayinitx = x;
                        rayinity = y;
                        if (opacity <= 0) {
                            break;
                        };
                    };
                };
                rays.push([[rayinitx, rayinity], [x, y], opacity]);
                rayinitx = x;
                rayinity = y;
            };
            rays.forEach(ray => {
                ctx.strokeStyle = `rgba(255, 255, 0, ${ray[2]})`;
                drawLine(ray[0], ray[1]);
            });
        };
        document.body.addEventListener("keypress", function(e){
            if (e.code == "Space") render();
        });
* {
                box-sizing: border-box;
            }
            html,body {
                width: 100%;
                height: 100%;
            }
            body {
                margin: 0;
                overflow: hidden;
            }
            canvas {
                width: 100vw;
                height: 100vh;
            }
<!DOCTYPE html>
<html lang="en">
    <body onmousemove="mousemove(event);">
        <canvas id="canvas"></canvas>
    </body>
</html>
const canvas = document.getElementById("canvas");
        const ctx = canvas.getContext("2d");
        var mouseX = 0;
        var mouseY = 0;

        canvas.width = innerWidth;
        canvas.height = innerHeight;

        ctx.fillStyle = "rgb(10, 10, 10)";
        ctx.strokeStyle = "rgba(255, 255, 0)";
        ctx.lineWidth = 3;

        ImageData.prototype.getPixel = function(x, y, offset) {
            return this.data[(y * this.width + x) * 4 + offset];
        };
        
        function drawLine(first, second) {
            ctx.beginPath();
            ctx.moveTo(first[0], first[1]);
            ctx.lineTo(second[0], second[1]);
            ctx.stroke();
        };
        function mousemove(e) {
            mouseX = e.clientX;
            mouseY = e.clientY;
        };
        function drawScene() {
            ctx.fillStyle = "rgba(50, 50, 50, 1)";
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            ctx.fillStyle = "rgba(10, 10, 10, 1)";

            ctx.fillRect(0, canvas.height-10, 200, 10);
            ctx.fillRect(0, canvas.height-210, 10, 200);
            ctx.fillRect(10, canvas.height-210, 200, 10);
            ctx.fillRect(200, canvas.height-190, 10, canvas.height-190);
        };
        drawScene();
        function render() {
            drawScene();
            let rays = [];
            var data = ctx.getImageData(0, 0, canvas.width, canvas.height);
            for (let angle = 0; angle < 360; angle += 3) { // for every ray
                let xv = Math.sin(angle*(Math.PI/180))*5;
                let yv = Math.cos(angle*(Math.PI/180))*5;
                let x = mouseX;
                let y = mouseY;
                let rayinitx = x;
                let rayinity = y;
                let collisions = 0;
                let opacity = 1;
                while (x > 0 && x < canvas.width && y > 0 && y < canvas.height) { // for every movement of every ray
                    x += xv;
                    let collide = false;
                    if (data.getPixel(x, y, 0) === 10 && data.getPixel(x, y, 1) === 10 && data.getPixel(x, y, 2) === 10 && data.getPixel(x, y, 3) === 255) {
                        xv *= -1;
                        x += xv;
                        collide = true;
                    };

                    y += yv;
                    if (data.getPixel(x, y, 0) === 10 && data.getPixel(x, y, 1) == 10 && data.getPixel(x, y, 2) === 10 && data.getPixel(x, y, 3) === 255) {
                        yv *= -1;
                        y += yv;
                        collide = true;
                    };
                    if (collide) {
                        rays.push([[rayinitx, rayinity], [x, y], opacity]);
                        opacity -= 1/5;
                        rayinitx = x;
                        rayinity = y;
                        if (opacity <= 0) {
                            break;
                        };
                    };
                };
                rays.push([[rayinitx, rayinity], [x, y], opacity]);
                rayinitx = x;
                rayinity = y;
            };
            rays.forEach(ray => {
                ctx.strokeStyle = `rgba(255, 255, 0, ${ray[2]})`;
                drawLine(ray[0], ray[1]);
            });
        };
        document.body.addEventListener("keypress", function(e){
            if (e.code == "Space") render();
        });
* {
                box-sizing: border-box;
            }
            html,body {
                width: 100%;
                height: 100%;
            }
            body {
                margin: 0;
                overflow: hidden;
            }
            canvas {
                width: 100vw;
                height: 100vh;
            }
<!DOCTYPE html>
<html lang="en">
    <body onmousemove="mousemove(event);">
        <canvas id="canvas"></canvas>
    </body>
</html>