I need to make a JavaScript widget that lets the user click on a specific area of an image and then that section gets magnified. I don't want it in a popup or a new page - I want the magnified section to appear right on top of where it originally was in the image.
system
mujhe ek javascript vijet banane kii aavashyaktaa he jo upyogkarta ko ek chhavi ke ek vishisht kshetra par clic karne detaa he or phir vah anubhag bad jaataa he.main ise ek powep yaa ek nae prishth main nahin chahta - main chahta hum ki aavardhit anubhag sahi dikhaai de, jahaan yah mul rup se chhavi main tha.
user
aisa karne kaa ek aasaan tarika yah he ki chhavi ko HTML canvas tatv main rakhaa jaae.phir aap ek anubhag ko badhaane sahit chhavi ko sampadit karne ke liye canvas web epiai se droimage () cmand kaa upyog kar sakate hai.yahaan namoona code he jo upyogkarta ke clic jahaan bhi kul chhavi ke aakaar kaa ek varg 10% hota he:

`` `javascript
        class ZoomableCanvas {
            constructor (canvas_id, img_src, zoom_factor) {
                this.canvas = document.getElementByid (canvas_id);
                yah.
                this.area_size = math.max (this.canvas.width, this.canvas.height) * .1;
                this.zoom_size = this.area_size * zoom_factor;
                
                this.img = nai chhavi ();
                this.img.addeventListener ("lod", this.drawimage, false);
                this.img.src = img_src;

                this.iszoomed = false;
            }

            ZoomonClick = (e) => {
                if (this.iszoomed) {
                    this.iszoomed = false;
                    this.drawimage ();
                } anya {
                    this.iszoomed = true;
                    this.drawzoomsection (e.offsetx, e.offsety);
                }
            }

            drawzoomsection = (x, y) => {
                const ctx = this.canvas.getContext ("2d");
                ctx.drawimage (this.img, x - this.area_size/2, y - this.area_size/2, this.area_size, this.area_size, x - this.zoom_size/2, y - this.zoom_size/2, yah.zoom_size, this.zoom_size);
            }

            drawimage = () => {
                const ctx = this.canvas.getContext ("2d");
                ctx.clearrect (0, 0, this.canvas.width, this.canvas.height);
                ctx.drawimage (this.img, 0, 0);
            }
        }

        zc = new ZoomableCanvas ('zoomable_canvas', 'img/sunflowers.jpg', 3);
`` `
assistant
<|system|>
</s>
<|user|>
mujhe ek javascript vijet banane kii aavashyaktaa he jo upyogkarta ko ek chhavi ke ek vishisht kshetra par clic karne detaa he or phir vah anubhag bad jaataa he.main ise ek powep yaa ek nae prishth main nahin chahta - main chahta hum ki aavardhit anubhag sahi dikhaai de, jahaan yah mul rup se chhavi main tha.</s>
<|assistant|>
aisa karne kaa ek aasaan tarika yah he ki chhavi ko HTML canvas tatv main rakhaa jaae.phir aap ek anubhag ko badhaane sahit chhavi ko sampadit karne ke liye canvas web epiai se droimage () cmand kaa upyog kar sakate hai.yahaan namoona code he jo upyogkarta ke clic jahaan bhi kul chhavi ke aakaar kaa ek varg 10% hota he:

`` `javascript
        class ZoomableCanvas {
            constructor (canvas_id, img_src, zoom_factor) {
                this.canvas = document.getElementByid (canvas_id);
                yah.
                this.area_size = math.max (this.canvas.width, this.canvas.height) * .1;
                this.zoom_size = this.area_size * zoom_factor;
                
                this.img = nai chhavi ();
                this.img.addeventListener ("lod", this.drawimage, false);
                this.img.src = img_src;

                this.iszoomed = false;
            }

            ZoomonClick = (e) => {
                if (this.iszoomed) {
                    this.iszoomed = false;
                    this.drawimage ();
                } anya {
                    this.iszoomed = true;
                    this.drawzoomsection (e.offsetx, e.offsety);
                }
            }

            drawzoomsection = (x, y) => {
                const ctx = this.canvas.getContext ("2d");
                ctx.drawimage (this.img, x - this.area_size/2, y - this.area_size/2, this.area_size, this.area_size, x - this.zoom_size/2, y - this.zoom_size/2, yah.zoom_size, this.zoom_size);
            }

            drawimage = () => {
                const ctx = this.canvas.getContext ("2d");
                ctx.clearrect (0, 0, this.canvas.width, this.canvas.height);
                ctx.drawimage (this.img, 0, 0);
            }
        }

        zc = new ZoomableCanvas ('zoomable_canvas', 'img/sunflowers.jpg', 3);
`` `</s>
