PHILLIP HANSON
  • Home
  • Writing
  • Image Archive
    • 2016-2017
    • 2015-2016
    • 2014
    • 2013.5+
    • 2010-2013.5
    • Drawings
    • Graduate Work
    • Security Envelope
    • Artings Quilt
    • Various
    • Pom Pom
    • Mandala
    • Sketches
    • Landscape
  • Flag Project
  • Teaching Dossier
    • Porfolio
    • Student Foundations >
      • Student Reflections
    • Demo Page
  • Flashlab Archive
  • AI Studies
  • AI Image Research
  • Paintings
  • Painting Surface Details
  • Student Foundations 1
  • AI Scope
  • Colors
  • sora
I asked chatGPT 4 to write some code with the following parameters:
Make a red ball that follows the mouseover, that when clicked links to a demonstration video for Openai Sora (I provided the youtube link).

Here is what it produced. 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mouse-Following Ball with Click Event to YouTube</title>
<style>
  #box {
    width: 400px;
    height: 400px;
    border: 2px solid black;
    position: relative;
    overflow: hidden;
    margin: 20px;
  }
  .ball {
    width: 50px;
    height: 50px;
    position: absolute;
    border-radius: 50%;
    background-color: red;
  }
</style>
</head>
<body>

<div id="box">
  <div class="ball"></div>
</div>

<script>
  const box = document.getElementById('box');
  const ball = document.querySelector('.ball');

  box.addEventListener('mousemove', function(e) {
    const boxRect = this.getBoundingClientRect();
    let mouseX = e.clientX - boxRect.left;
    let mouseY = e.clientY - boxRect.top;

    const ballX = Math.max(0, Math.min(boxRect.width - ball.offsetWidth, mouseX - ball.offsetWidth / 2));
    const ballY = Math.max(0, Math.min(boxRect.height - ball.offsetHeight, mouseY - ball.offsetHeight / 2));

    ball.style.left = ballX + 'px';
    ball.style.top = ballY + 'px';
  });

  // Add click event listener to open the specified YouTube video
  box.addEventListener('click', function() {
    window.open('https://www.youtube.com/watch?v=HK6y8DAPN_0', '_blank');
  });
</script>

</body>
</html>

Mouse-Following Ball with Click Event to YouTube


Interactive Wave with Cursor-Following Sailboat
copyright Phillip Hanson 2024
  • Home
  • Writing
  • Image Archive
    • 2016-2017
    • 2015-2016
    • 2014
    • 2013.5+
    • 2010-2013.5
    • Drawings
    • Graduate Work
    • Security Envelope
    • Artings Quilt
    • Various
    • Pom Pom
    • Mandala
    • Sketches
    • Landscape
  • Flag Project
  • Teaching Dossier
    • Porfolio
    • Student Foundations >
      • Student Reflections
    • Demo Page
  • Flashlab Archive
  • AI Studies
  • AI Image Research
  • Paintings
  • Painting Surface Details
  • Student Foundations 1
  • AI Scope
  • Colors
  • sora