js+css实现相机镜头对焦范围滑块拖动旋转效果代码

代码语言:html

所属分类:拖放

代码描述: js+css实现相机镜头对焦范围滑块拖动旋转效果代码

代码标签: js css 相机 镜头 对焦 范围 滑块 拖动 旋转

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  


<style>
:root {
  --primary: #166496;
}

* {
  box-sizing: border-box;
}

body {
  background-color: #041827;
  color: white;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  margin: 0;
}

line {
  --deg: 0deg;
  --h: 135;
  --s: 10%;
  --a: 0.2;
  stroke-width: 2px;
  stroke: #c2d4e2;
  transform: rotate(var(--deg));
  transform-origin: 50% 50%;
}
line.line2 {
  stroke-linecap: round;
  stroke-width: 16px;
  stroke: #003657;
}

#dragable {
  --deg: -110.25deg;
  cursor: grab;
  user-select: none !important;
  transform-origin: 50% 50%;
  transform: rotate(var(--deg));
  touch-action: none;
}

.gradateLineWithText {
  --deg: 0deg;
  transform: rotate(var(--deg));
  transform-origin: 50% 50%;
}
.gradateLineWithText line {
  stroke: #ffc071;
}
.gradateLineWithText text {
  fill: #ffc071;
  transform: translate(0, 5px);
  font-family: "Courier New", Courier, monospace;
  font-weight: bold;
  font-size: x-small;
}

main {
  position: relative;
  aspect-ratio: 1;
}
main svg {
  display: block;
  position: relative;
  z-index: 1000;
  height: auto;
  width: min(100vw, 100vh);
}
main .lensView {
  position: absolute;
  z-index: 0;
  aspect-ratio: 1;
  inset: 13%;
  border-radius: 50%;
  overflow: hidden;
  filter: sepia(1);
}
main .lensView img {
  user-select: none !important;
  aspect-ratio: 1;
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  object-fit: cover;
}
main .lensView img.back {
  filter: url(#circleBlurBack);
}
main .lensView img.front {
  filter: url(#circleBlurFront);
}

.focus {
  position: absolute;
  z-index: 10000;
  aspect-ratio: 1;
  inset: 5%;
  border-radius: 50%;
  pointer-events: none;
}

.input-range {
  position: fixed;
  left: 0;
  bottom: 1rem;
  opacity: 0;
  z-index: -1000;
}

body:has(.input-range:focus) .focus {
  outline: 2px dashed #ffc071;
}
</style>


  
  
</head>

<body>
  <input class="input-range" type="range" min="0" max="100"  value="40" id="radiusInput">

    <main>
			
        <div class="lensView">
            <img class="back" src="https://i.imgur.com/zkiBnLJ.png" >
            <img class="front" src="https://i.imgur.com/i8AipNG.png" >
        </div>
        <svg xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 600 600">
            <defs>
                <path id="textPath" transform="translate(50 50)"
                d="M250,0C388.071,0,500,111.929,500,250S388.071,500,250,500,0,388.071,0,250,111.929,0,250,0Z"
                stroke="none" fill="none" />
                <filter id="dropShadow" >
                    <feDropShadow stdDeviation="10" in="SourceGraphic" flood-color="#041827" flood-opacity=".6"/>
                </filter>
            </defs>
            <path d="M17,0,34,30H0Z" transform="translate(317 30) rotate(180)" fill="var(--primary)" />



            <g id="dragable" >
                <path filter="url(#dropShadow)" transform="translate(30 30)" fill="var(--primary)"
                    d="M 270 539.5 C 251.7147369384766 539.5 233.4407958984375 537.6578369140625 215.6860046386719 534.024658203125 C 198.3823394775391 530.48388671875 181.3623352050781 525.2005615234375 165.0988006591797 518.3214721679688 C 149.1298675537109 511.5672607421875 133.7278594970703 503.207275390625 119.3206024169922 493.4737854003906 C 105.0500640869141 483.8328552246094 91.63053131103516 472.7608032226562 79.43479919433594 460.565185546875 C 67.23933410644531 448.3695983886719 56.16726684570312 434.9501342773438 46.52619934082031 420.6794738769531 C 36.79266738891602 406.2720031738281 28.43266677856445 390.8699951171875 21.67853355407715 374.9012756347656 C 14.7993335723877 358.6371459960938 9.515999794006348 341.6171264648438 5.975333213806152 324.3140563964844 C 2.342133283615112 306.5592041015625 0.5 288.2852783203125 0.5 270 C 0.5 251.7147369384766 2.342133283615112 233.4407958984375 5.975333213806152 215.6860046386719 C 9.515999794006348 198.3829345703125 14.7993335723877 181.3629302978516 21.67853355407715 165.0988006591797 C 28.4327335357666 149.1298675537109 36.79273223876953 133.7278594970703 46.52619934082031 119.3206024169922 C 56.16713333129883 105.0500640869141 67.23919677734375 91.63053131103516 79.43479919433594 79.43479919433594 C 91.63053131103516 67.23919677734375 105.0500640869141 56.16713333129883 119.3206024169922 46.52619934082031 C 133.7278594970703 36.79273223876953 149.1298675537109 28.4327335357666 165.0988006591797 21.67853355407715 C 181.3629302978516 14.7993335723877 198.3829345703125 9.515999794006348 215.6860046386719 5.975333213806152 C 233.4407958984375 2.342133283615112 251.7147369384766 0.5 270 0.5 C 288.2852783203125 0.5 306.5592041015625 2.342133283615112 324.3140563964844 5.975333213806152 C 341.6171264648438 9.515999794006348 358.6371459960938 14.7993335723877 374.9012756347656 21.67853355407715 C 390.8699951171875 28.43266677856445 406.2720031738281 36.79266738891602 420.6794738769531 46.52619934082031 C 434.9501342773438 56.16726684570312 448.3695983886719 67.23933410644531 460.565185546875 79.43479919433594 C 472.7608032226562 91.63053131103516 483.8328552246094 105.0500640869141 493.4737854003906 119.3206024169922 C 503.207275390625 133.7278594970703 511.5672607421875 149.1298675537109 518.3214721679688 165.0988006591797 C 525.2005615234375 181.3623352050781 530.48388671875 198.3823394775391 534.024658203125 215.6860046386719 C 537.6578369140625 233.4407958984375 539.5 251.7147369384766 539.5 270 C 539.5 288.2852783203125 537.6578369140625 306.5592041015625 534.024658203125 324.3140563964844 C 530.48388671875 341.6177368164062 525.2005615234375 358.6377258300781 518.3214721679688 374.9012756347656 C 511.5673217773438 390.8699951171875 503.2073364257812 406.2720031738281 493.4737854003906 420.6794738769531 C 483.8327331542969 434.9501342773438 472.7606811523438 448.3695983886719 460.565185546875 460.565185546875 C 448.3695983886719 472.7606811523438 434.9501342773438 483.8327331542969 420.6794738769531 493.4737854003906 C 406.2720031738281 503.2073364257812 390.8699951171875 511.5673217773438 374.9012756347656 518.3214721679688 C 358.6377258300781 525.2005615234375 341.6177368164062 530.48388671875 324.3140563964844 534.024658203125 C 306.5592041015625 537.6578369140625 288.2852783203125 539.5 270 539.5 Z M 270 49.50040054321289 C 148.4161376953125 49.50040054321289 49.50040054321289 148.4161376953125 49.50040054321289 270 C 49.50040054321289 391.5838623046875 148.4161376953125 490.4996032714844 270 490.4996032714844 C 391.5838623046875 490.4996032714844 490.4996032714844 391.5838623046875 490.4996032714844 270 C 490.4996032714844 148.4161376953125 391.5838623046875 49.50040054321289 270 49.50040054321289 Z" />

                <g id="gradateLines"></g>

            </g>

        </svg>
			<div class="focus"></div>
    </main>

      <script type="module">
"use strict";
const SAMPLS = 15;
class CircleBlurFilter {
    constructor(id, radius = 5, el = undefined) {
        this.namespace = "http://www.w3.org/2000/svg";
        this.defs = undefined;
        this.circleBlurFilters = {};
        if (!el)
            el = document.documentElement;
        this.initSvg(el);
        this.createFilter(id, radius);
    }
    initSvg(element) {
        const svg = documen.........完整代码请登录后点击上方下载按钮下载查看

网友评论0