web--拉灯泡切换黑天与白夜的精美动画

news2025/1/31 22:53:44

功能:

进入界面会出现一个灯泡(下面有可以自由飘动也可以自由拉动的绳子),鼠标左键按住不松开可以拉动绳子,松开变化亮起,同时有拉响的清脆声响,把它放在web作业的设计里面绝对是非常非常不错的加分点!

代码:

dist/heml:

<!DOCTYPE html>

<html lang="en" >

<head>

  <meta charset="UTF-8">

  <title>CodePen - Tuggable Light Bulb! 💡(GSAP Draggable &amp;&amp; MorphSVG)</title>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">

<link rel="stylesheet" href="./style.css">

</head>

<body>

<!-- partial:index.partial.html -->

<svg class="toggle-scene" xmlns="http://www.w3.org/2000/svg" preserveaspectratio="xMinYMin" viewBox="0 0 197.451 481.081">

  <defs>

    <marker id="e" orient="auto" overflow="visible" refx="0" refy="0">

      <path class="toggle-scene__cord-end" fill-rule="evenodd" stroke-width=".2666" d="M.98 0a1 1 0 11-2 0 1 1 0 012 0z"></path>

    </marker>

    <marker id="d" orient="auto" overflow="visible" refx="0" refy="0">

      <path class="toggle-scene__cord-end" fill-rule="evenodd" stroke-width=".2666" d="M.98 0a1 1 0 11-2 0 1 1 0 012 0z"></path>

    </marker>

    <marker id="c" orient="auto" overflow="visible" refx="0" refy="0">

      <path class="toggle-scene__cord-end" fill-rule="evenodd" stroke-width=".2666" d="M.98 0a1 1 0 11-2 0 1 1 0 012 0z"></path>

    </marker>

    <marker id="b" orient="auto" overflow="visible" refx="0" refy="0">

      <path class="toggle-scene__cord-end" fill-rule="evenodd" stroke-width=".2666" d="M.98 0a1 1 0 11-2 0 1 1 0 012 0z"></path>

    </marker>

    <marker id="a" orient="auto" overflow="visible" refx="0" refy="0">

      <path class="toggle-scene__cord-end" fill-rule="evenodd" stroke-width=".2666" d="M.98 0a1 1 0 11-2 0 1 1 0 012 0z"></path>

    </marker>

    <clippath id="g" clippathunits="userSpaceOnUse">

      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="4.677" d="M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v53.6s-8.825 16-29.203 16c-21.674 0-29.203-16-29.203-16z"></path>

    </clippath>

    <clippath id="f" clippathunits="userSpaceOnUse">

      <path d="M-868.418 945.051c-4.188 73.011 78.255 53.244 150.216 52.941 82.387-.346 98.921-19.444 98.921-47.058 0-27.615-4.788-42.55-73.823-42.55-69.036 0-171.436-30.937-175.314 36.667z"></path>

    </clippath>

  </defs>

  <g class="toggle-scene__cords">

    <path class="toggle-scene__cord" marker-end="url(#a)" fill="none" stroke-linecap="square" stroke-width="6" d="M123.228-28.56v150.493" transform="translate(-24.503 256.106)"></path>

    <path class="toggle-scene__cord" marker-end="url(#a)" fill="none" stroke-linecap="square" stroke-width="6" d="M123.228-28.59s28 8.131 28 19.506-18.667 13.005-28 19.507c-9.333 6.502-28 8.131-28 19.506s28 19.507 28 19.507" transform="translate(-24.503 256.106)"></path>

    <path class="toggle-scene__cord" marker-end="url(#a)" fill="none" stroke-linecap="square" stroke-width="6" d="M123.228-28.575s-20 16.871-20 28.468c0 11.597 13.333 18.978 20 28.468 6.667 9.489 20 16.87 20 28.467 0 11.597-20 28.468-20 28.468" transform="translate(-24.503 256.106)"></path>

    <path class="toggle-scene__cord" marker-end="url(#a)" fill="none" stroke-linecap="square" stroke-width="6" d="M123.228-28.569s16 20.623 16 32.782c0 12.16-10.667 21.855-16 32.782-5.333 10.928-16 20.623-16 32.782 0 12.16 16 32.782 16 32.782" transform="translate(-24.503 256.106)"></path>

    <path class="toggle-scene__cord" marker-end="url(#a)" fill="none" stroke-linecap="square" stroke-width="6" d="M123.228-28.563s-10 24.647-10 37.623c0 12.977 6.667 25.082 10 37.623 3.333 12.541 10 24.647 10 37.623 0 12.977-10 37.623-10 37.623" transform="translate(-24.503 256.106)"></path>

    <g class="line toggle-scene__dummy-cord">

      <line marker-end="url(#a)" x1="98.7255" x2="98.7255" y1="240.5405" y2="380.5405"></line>

    </g>

    <circle class="toggle-scene__hit-spot" cx="98.7255" cy="380.5405" r="60" fill="transparent"></circle>

  </g>

  <g class="toggle-scene__bulb bulb" transform="translate(844.069 -645.213)">

    <path class="bulb__cap" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.677" d="M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v53.6s-8.825 16-29.203 16c-21.674 0-29.203-16-29.203-16z"></path>

    <path class="bulb__cap-shine" d="M-778.379 802.873h25.512v118.409h-25.512z" clip-path="url(#g)" transform="matrix(.52452 0 0 .90177 -368.282 82.976)"></path>

    <path class="bulb__cap" stroke-linecap="round" stroke-linejoin="round" stroke-width="4" d="M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v0s-8.439 10.115-28.817 10.115c-21.673 0-29.59-10.115-29.59-10.115z"></path>

    <path class="bulb__cap-outline" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.677" d="M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v53.6s-8.825 16-29.203 16c-21.674 0-29.203-16-29.203-16z"></path>

    <g class="bulb__filament" fill="none" stroke-linecap="round" stroke-width="5">

      <path d="M-752.914 823.875l-8.858-33.06"></path>

      <path d="M-737.772 823.875l8.858-33.06"></path>

    </g>

    <path class="bulb__bulb" stroke-linecap="round" stroke-width="5" d="M-783.192 803.855c5.251 8.815 5.295 21.32 13.272 27.774 12.299 8.045 36.46 8.115 49.127 0 7.976-6.454 8.022-18.96 13.273-27.774 3.992-6.7 14.408-19.811 14.408-19.811 8.276-11.539 12.769-24.594 12.769-38.699 0-35.898-29.102-65-65-65-35.899 0-65 29.102-65 65 0 13.667 4.217 26.348 12.405 38.2 0 0 10.754 13.61 14.746 20.31z"></path>

    <circle class="bulb__flash" cx="-745.343" cy="743.939" r="83.725" fill="none" stroke-dasharray="10,30" stroke-linecap="round" stroke-linejoin="round" stroke-width="10"></circle>

    <path class="bulb__shine" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="12" d="M-789.19 757.501a45.897 45.897 0 013.915-36.189 45.897 45.897 0 0129.031-21.957"></path>

  </g>

</svg>

<!-- partial -->

  <script src='https://unpkg.co/gsap@3/dist/gsap.min.js'></script>

<script src='https://assets.codepen.io/16327/MorphSVGPlugin3.min.js'></script>

<script src='https://unpkg.com/gsap@3/dist/Draggable.min.js'></script><script  src="./script.js"></script>

</body>

</html>

dist/css

* {

  box-sizing: border-box;

}

:root {

  --on: 0;

  --bg: hsl(calc(200 - (var(--on) * 160)), calc((20 + (var(--on) * 50)) * 1%), calc((20 + (var(--on) * 60)) * 1%));

  --cord: hsl(0, 0%, calc((60 - (var(--on) * 50)) * 1%));

  --stroke: hsl(0, 0%, calc((60 - (var(--on) * 50)) * 1%));

  --shine: hsla(0, 0%, 100%, calc(0.75 - (var(--on) * 0.5)));

  --cap: hsl(0, 0%, calc((40 + (var(--on) * 30)) * 1%));

  --filament: hsl(45, calc(var(--on) * 80%), calc((25 + (var(--on) * 75)) * 1%));

}

body {

  min-height: 100vh;

  display: flex;

  align-items: center;

  justify-content: center;

  background: var(--bg);

}

.toggle-scene {

  overflow: visible !important;

  height: 50vmin;

  position: absolute;

}

.toggle-scene__cord {

  stroke: var(--cord);

  cursor: move;

}

.toggle-scene__cord:nth-of-type(1) {

  display: none;

}

.toggle-scene__cord:nth-of-type(2),

.toggle-scene__cord:nth-of-type(3),

.toggle-scene__cord:nth-of-type(4),

.toggle-scene__cord:nth-of-type(5) {

  display: none;

}

.toggle-scene__cord-end {

  stroke: var(--cord);

  fill: var(--cord);

}

.toggle-scene__dummy-cord {

  stroke-width: 6;

  stroke: var(--cord);

}

.bulb__filament {

  stroke: var(--filament);

}

.bulb__shine {

  stroke: var(--shine);

}

.bulb__flash {

  stroke: #f5e0a3;

  display: none;

}

.bulb__bulb {

  stroke: var(--stroke);

  fill: hsla(calc(180 - (95 * var(--on))), 80%, 80%, calc(0.1 + (0.4 * var(--on))));

}

.bulb__cap {

  fill: var(--cap);

}

.bulb__cap-shine {

  fill: var(--shine);

}

.bulb__cap-outline {

  stroke: var(--stroke);

}

dist/js

const {

  gsap: { registerPlugin, set, to, timeline },

  MorphSVGPlugin,

  Draggable } =

window;

registerPlugin(MorphSVGPlugin);

// Used to calculate distance of "tug"

let startX;

let startY;

const AUDIO = {

  CLICK: new Audio('C:\Users\123\Desktop\webdayornight') };

const STATE = {

  ON: false };

const CORD_DURATION = 0.1;

const CORDS = document.querySelectorAll('.toggle-scene__cord');

const HIT = document.querySelector('.toggle-scene__hit-spot');

const DUMMY = document.querySelector('.toggle-scene__dummy-cord');

const DUMMY_CORD = document.querySelector('.toggle-scene__dummy-cord line');

const PROXY = document.createElement('div');

// set init position

const ENDX = DUMMY_CORD.getAttribute('x2');

const ENDY = DUMMY_CORD.getAttribute('y2');

const RESET = () => {

  set(PROXY, {

    x: ENDX,

    y: ENDY });

};

RESET();

const CORD_TL = timeline({

  paused: true,

  onStart: () => {

    STATE.ON = !STATE.ON;

    set(document.documentElement, { '--on': STATE.ON ? 1 : 0 });

    set([DUMMY, HIT], { display: 'none' });

    set(CORDS[0], { display: 'block' });

    AUDIO.CLICK.play();

  },

  onComplete: () => {

    set([DUMMY, HIT], { display: 'block' });

    set(CORDS[0], { display: 'none' });

    RESET();

  } });


 

for (let i = 1; i < CORDS.length; i++) {

  CORD_TL.add(

  to(CORDS[0], {

    morphSVG: CORDS[i],

    duration: CORD_DURATION,

    repeat: 1,

    yoyo: true }));


 

}

Draggable.create(PROXY, {

  trigger: HIT,

  type: 'x,y',

  onPress: e => {

    startX = e.x;

    startY = e.y;

  },

  onDrag: function () {

    set(DUMMY_CORD, {

      attr: {

        x2: this.x,

        y2: this.y } });


 

  },

  onRelease: function (e) {

    const DISTX = Math.abs(e.x - startX);

    const DISTY = Math.abs(e.y - startY);

    const TRAVELLED = Math.sqrt(DISTX * DISTX + DISTY * DISTY);

    to(DUMMY_CORD, {

      attr: { x2: ENDX, y2: ENDY },

      duration: CORD_DURATION,

      onComplete: () => {

        if (TRAVELLED > 50) {

          CORD_TL.restart();

        } else {

          RESET();

        }

      } });

  } });

src/pug

svg(class="toggle-scene" xmlns='http://www.w3.org/2000/svg' preserveaspectratio='xMinYMin' viewBox='0 0 197.451 481.081')

  defs

    marker#e(orient='auto' overflow='visible' refx='0' refy='0')

      path.toggle-scene__cord-end(fill-rule='evenodd' stroke-width='.2666' d='M.98 0a1 1 0 11-2 0 1 1 0 012 0z')

    marker#d(orient='auto' overflow='visible' refx='0' refy='0')

      path.toggle-scene__cord-end(fill-rule='evenodd' stroke-width='.2666' d='M.98 0a1 1 0 11-2 0 1 1 0 012 0z')

    marker#c(orient='auto' overflow='visible' refx='0' refy='0')

      path.toggle-scene__cord-end(fill-rule='evenodd' stroke-width='.2666' d='M.98 0a1 1 0 11-2 0 1 1 0 012 0z')

    marker#b(orient='auto' overflow='visible' refx='0' refy='0')

      path.toggle-scene__cord-end(fill-rule='evenodd' stroke-width='.2666' d='M.98 0a1 1 0 11-2 0 1 1 0 012 0z')

    marker#a(orient='auto' overflow='visible' refx='0' refy='0')

      path.toggle-scene__cord-end(fill-rule='evenodd' stroke-width='.2666' d='M.98 0a1 1 0 11-2 0 1 1 0 012 0z')

    clippath#g(clippathunits='userSpaceOnUse')

      path(stroke-linecap='round' stroke-linejoin='round' stroke-width='4.677' d='M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v53.6s-8.825 16-29.203 16c-21.674 0-29.203-16-29.203-16z')

    clippath#f(clippathunits='userSpaceOnUse')

      path(d='M-868.418 945.051c-4.188 73.011 78.255 53.244 150.216 52.941 82.387-.346 98.921-19.444 98.921-47.058 0-27.615-4.788-42.55-73.823-42.55-69.036 0-171.436-30.937-175.314 36.667z')

  g.toggle-scene__cords

    path.toggle-scene__cord(marker-end="url(#a)" fill='none' stroke-linecap='square' stroke-width='6' d='M123.228-28.56v150.493' transform='translate(-24.503 256.106)')

    path.toggle-scene__cord(marker-end="url(#a)" fill='none' stroke-linecap='square' stroke-width='6' d='M123.228-28.59s28 8.131 28 19.506-18.667 13.005-28 19.507c-9.333 6.502-28 8.131-28 19.506s28 19.507 28 19.507' transform='translate(-24.503 256.106)')

    path.toggle-scene__cord(marker-end="url(#a)" fill='none' stroke-linecap='square' stroke-width='6' d='M123.228-28.575s-20 16.871-20 28.468c0 11.597 13.333 18.978 20 28.468 6.667 9.489 20 16.87 20 28.467 0 11.597-20 28.468-20 28.468' transform='translate(-24.503 256.106)')

    path.toggle-scene__cord(marker-end="url(#a)" fill='none' stroke-linecap='square' stroke-width='6' d='M123.228-28.569s16 20.623 16 32.782c0 12.16-10.667 21.855-16 32.782-5.333 10.928-16 20.623-16 32.782 0 12.16 16 32.782 16 32.782' transform='translate(-24.503 256.106)')

    path.toggle-scene__cord(marker-end="url(#a)" fill='none' stroke-linecap='square' stroke-width='6' d='M123.228-28.563s-10 24.647-10 37.623c0 12.977 6.667 25.082 10 37.623 3.333 12.541 10 24.647 10 37.623 0 12.977-10 37.623-10 37.623' transform='translate(-24.503 256.106)')

    g.line.toggle-scene__dummy-cord

      line(marker-end="url(#a)" x1="98.7255" x2="98.7255" y1="240.5405" y2="380.5405")

    circle.toggle-scene__hit-spot(cx="98.7255" cy="380.5405" r="60" fill="transparent")

  g.toggle-scene__bulb.bulb(transform='translate(844.069 -645.213)')

    path.bulb__cap(stroke-linecap='round' stroke-linejoin='round' stroke-width='4.677' d='M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v53.6s-8.825 16-29.203 16c-21.674 0-29.203-16-29.203-16z')

    path.bulb__cap-shine(d='M-778.379 802.873h25.512v118.409h-25.512z' clip-path='url(#g)' transform='matrix(.52452 0 0 .90177 -368.282 82.976)')

    path.bulb__cap(stroke-linecap='round' stroke-linejoin='round' stroke-width='4' d='M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v0s-8.439 10.115-28.817 10.115c-21.673 0-29.59-10.115-29.59-10.115z')

    path.bulb__cap-outline(fill='none' stroke-linecap='round' stroke-linejoin='round' stroke-width='4.677' d='M-774.546 827.629s12.917-13.473 29.203-13.412c16.53.062 29.203 13.412 29.203 13.412v53.6s-8.825 16-29.203 16c-21.674 0-29.203-16-29.203-16z')

    g.bulb__filament(fill='none' stroke-linecap='round' stroke-width='5')

      path(d='M-752.914 823.875l-8.858-33.06')

      path(d='M-737.772 823.875l8.858-33.06')

    path.bulb__bulb(stroke-linecap='round' stroke-width='5' d='M-783.192 803.855c5.251 8.815 5.295 21.32 13.272 27.774 12.299 8.045 36.46 8.115 49.127 0 7.976-6.454 8.022-18.96 13.273-27.774 3.992-6.7 14.408-19.811 14.408-19.811 8.276-11.539 12.769-24.594 12.769-38.699 0-35.898-29.102-65-65-65-35.899 0-65 29.102-65 65 0 13.667 4.217 26.348 12.405 38.2 0 0 10.754 13.61 14.746 20.31z')

    circle.bulb__flash(cx='-745.343' cy='743.939' r='83.725' fill='none' stroke-dasharray='10,30' stroke-linecap='round' stroke-linejoin='round' stroke-width='10')

    path.bulb__shine(fill='none' stroke-linecap='round' stroke-linejoin='round' stroke-width='12' d='M-789.19 757.501a45.897 45.897 0 013.915-36.189 45.897 45.897 0 0129.031-21.957')

src/stylus

*
  box-sizing border-box

:root
  --on 0
  --bg 'hsl(%s, %s, %s)' % (calc(200 - (var(--on) * 160)) calc((20 + (var(--on) * 50)) * 1%) calc((20 + (var(--on) * 60)) * 1%))
  --cord 'hsl(0, 0%, %s)' % (calc((60 - (var(--on) * 50)) * 1%))
  --stroke 'hsl(0, 0%, %s)' % (calc((60 - (var(--on) * 50)) * 1%))
  --shine 'hsla(0, 0%, 100%, %s)' % calc(0.75 - (var(--on) * 0.5))
  --cap 'hsl(0, 0%, %s)' % calc((40 + (var(--on) * 30)) * 1%)
  --filament 'hsl(45, %s, %s)' % (calc(var(--on) * 80%) calc((25 + (var(--on) * 75)) * 1%))

body
  min-height 100vh
  display flex
  align-items center
  justify-content center
  background var(--bg)

.toggle-scene
  // !important for CodePen
  overflow visible !important
  height 50vmin
  position absolute

  &__cord
    stroke var(--cord)
    cursor move

    // Hide all cords if there's no JavaScript?
    &:nth-of-type(1)
      display none

    // Hide cords by default
    &:nth-of-type(2)
    &:nth-of-type(3)
    &:nth-of-type(4)
    &:nth-of-type(5)
      display none

    &-end
      stroke var(--cord)
      fill var(--cord)

.toggle-scene__dummy-cord
  stroke-width 6
  stroke var(--cord)

.bulb
  &__filament
    stroke var(--filament)
  &__shine
    stroke var(--shine)
  &__flash
    stroke hsl(45, 80%, 80%)
    display none
  &__bulb
    stroke var(--stroke)
    fill 'hsla(%s, 80%, 80%, %s)' % (calc(180 - (95 * var(--on))) calc(0.1 + (0.4 * var(--on))))
  &__cap
    fill var(--cap)
    &-shine
      fill var(--shine)
    &-outline
      stroke var(--stroke)

src/js

const {

  gsap: { registerPlugin, set, to, timeline },

  MorphSVGPlugin,

  Draggable,

} = window

registerPlugin(MorphSVGPlugin)

// Used to calculate distance of "tug"

let startX

let startY

const AUDIO = {

  CLICK: new Audio('C:\Users\123\Desktop\webdayornight'),

}

const STATE = {

  ON: false,

}

const CORD_DURATION = 0.1

const CORDS = document.querySelectorAll('.toggle-scene__cord')

const HIT = document.querySelector('.toggle-scene__hit-spot')

const DUMMY = document.querySelector('.toggle-scene__dummy-cord')

const DUMMY_CORD = document.querySelector('.toggle-scene__dummy-cord line')

const PROXY = document.createElement('div')

// set init position

const ENDX = DUMMY_CORD.getAttribute('x2')

const ENDY = DUMMY_CORD.getAttribute('y2')

const RESET = () => {

  set(PROXY, {

    x: ENDX,

    y: ENDY,

  })

}

RESET()

const CORD_TL = timeline({

  paused: true,

  onStart: () => {

    STATE.ON = !STATE.ON

    set(document.documentElement, { '--on': STATE.ON ? 1 : 0 })

    set([DUMMY, HIT], { display: 'none' })

    set(CORDS[0], { display: 'block' })

    AUDIO.CLICK.play()

  },

  onComplete: () => {

    set([DUMMY, HIT], { display: 'block' })

    set(CORDS[0], { display: 'none' })

    RESET()

  },

})

for (let i = 1; i < CORDS.length; i++) {

  CORD_TL.add(

    to(CORDS[0], {

      morphSVG: CORDS[i],

      duration: CORD_DURATION,

      repeat: 1,

      yoyo: true,

    })

  )

}

Draggable.create(PROXY, {

  trigger: HIT,

  type: 'x,y',

  onPress: e => {

    startX = e.x

    startY = e.y

  },

  onDrag: function() {

    set(DUMMY_CORD, {

      attr: {

        x2: this.x,

        y2: this.y,

      },

    })

  },

  onRelease: function(e) {

    const DISTX = Math.abs(e.x - startX)

    const DISTY = Math.abs(e.y - startY)

    const TRAVELLED = Math.sqrt(DISTX * DISTX + DISTY * DISTY)

    to(DUMMY_CORD, {

      attr: { x2: ENDX, y2: ENDY },

      duration: CORD_DURATION,

      onComplete: () => {

        if (TRAVELLED > 50) {

          CORD_TL.restart()

        } else {

          RESET()

        }

      },

    })

  },

})

部分截图:

 

 

  

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/104595.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SQL注入总结复习

SQL注入总结复习 一、前提 1、web三层架构 学习SQL注入&#xff0c;前提必须要了解web程序的三层架构。 数据访问层&#xff08;DAL&#xff09;&#xff1a;主要负责对数据库进行增删改查&#xff0c;将存储在数据库中的数据提交给业务层&#xff0c;同时将业务层处理的数据…

第七章 集合相关知识

什么是集合 为了存储不同类型的多个对象, Java提供了一系列特殊的类, 这些类可以存储任意类型的对象&#xff0c;并且存储的长度可变,被统称为集合。集合可以简单理解为一个长度可变可以存储不同数据类型的动态数组。集合都位于java.uti包中,使用集合时必须导入java.util包。 …

前端二面必会手写面试题汇总

实现Vue reactive响应式 // Dep module class Dep {static stack []static target nulldeps nullconstructor() {this.deps new Set()}depend() {if (Dep.target) {this.deps.add(Dep.target)}}notify() {this.deps.forEach(w > w.update())}static pushTarget(t) {if …

LeetCode刷题复盘笔记—一文搞懂动态规划之300. 最长递增子序列问题(动态规划系列第二十七篇)

今日主要总结一下动态规划的一道题目&#xff0c;300. 最长递增子序列 题目&#xff1a;300. 最长递增子序列 Leetcode题目地址 题目描述&#xff1a; 给你一个整数数组 nums &#xff0c;找到其中最长严格递增子序列的长度。 子序列 是由数组派生而来的序列&#xff0c;删除…

想要月入过万?不防尝试一下Python这个职业!

自从20世纪90年代初发布以来&#xff0c;Python一直相当火爆&#xff0c;在这二十多年里&#xff0c;它的流行程度远远超过了C、C#、Java甚至Javascript。 Python为什么受欢迎&#xff1f; Python迅猛发展背后的一个主要驱动力是它学习起来相当容易&#xff0c;使用起来功能强…

程序员需要了解的硬核知识CPU

大家都是程序员&#xff0c;大家都是和计算机打交道的程序员&#xff0c;大家都是和计算机中软件硬件打交道的程序员&#xff0c;大家都是和CPU打交道的程序员&#xff0c;所以&#xff0c;不管你是玩儿硬件的还是做软件的&#xff0c;你的世界都少不了计算机最核心的 - CPU C…

【C语言进阶】通讯录不好用?进来,零基础带你写出自己的通讯录

目录 &#x1f929;前言&#x1f929;&#xff1a; &#x1f60e;正文&#xff1a;编写通讯录&#x1f60e;&#xff1a; 1.文件建立&#xff1a; ①.头文件Contact.h&#xff1a; ②.函数定义文件Contact.c&#xff1a; ③.工程测试文件test.c&#xff1a; 2.通讯录整体执行…

A White Paper on Neural Network Quantization--阅读笔记1

A White Paper on Neural Network Quantization--阅读笔记1一、模型量化的意义二、量化主要做什么三、目前量化主要分类四、量化基本知识介绍0、基本知识1、误差来源2、量化范围的设定五、量化方法介绍1、均匀仿射量化(Uniform affine quantization)2、对称均匀量化(Symmetric …

热门技术中的应用:微服务相关协议-第35讲-二进制类RPC协议:还是叫NBA吧,总说全称多费劲

前面我们讲了两个常用文本类的RPC协议,对于陌生人之间的沟通,用NBA、CBA这样的缩略语,会使得协议约定非常不方便。 在讲CDN和DNS的时候,我们讲过接入层的设计,对于静态资源或者动态资源静态化的部分都可以做缓存。但是对于下单、支付等交易场景,还是需要调用API。 对于…

基于yolov5的智慧交通监测系统

本项目实现了智慧交通监测、红绿灯监测、行人监测、车辆识别、斑马线闯红灯监测等多种监测功能。 目录 背景 演示效果&#xff1a; 检测代码样例&#xff1a; 最后的检测效果如图所示 项目具体的工作流程为&#xff1a; 总结&#xff1a; 背景 针对城市交通拥堵问题&#x…

Effective C++条款33:避免遮掩继承而来的名称(Avoid hiding inherited names)

Effective C条款33&#xff1a;避免遮掩继承而来的名称&#xff08;Avoid hiding inherited names&#xff09;条款33&#xff1a;避免遮掩继承而来的名称1、同名全局变量在局部作用域中被隐藏2、继承中的隐藏3、进一步论证——继承中的函数的隐藏4、如何将隐藏的行为进行覆盖4…

vTESTstudio入门到精通 - 如何自动化控制Simulation节点_03

我们工作中经常会遇到需要仿真大量的CAN/CANFD报文的情况,通常我们只能通过人工去测试,因为很难实现仿真控制大量报文的发送和停止?那我们该如何去解决呢? 今天我们主要来解决这个问题,通过CAPL去控制simulation节点的仿真发送和停止,最大限度的在实验室仿真实车的报文数…

段错误产生原因

嵌入式C开发&#xff0c;或多或少都遇到段错误&#xff08;segmentation fault &#xff09;。 下面是一些典型的段错误产生的原因&#xff1a; 访问不存在的内存地址 访问只读的内存地址 栈溢出 内存越界 …… 实例 1. 访问不存在的内存地址 #include <stdio.h>in…

小学生C++编程基础 课程7(A)

897.a到b (课程7&#xff09; 难度&#xff1a;1 登录 898.2位偶数 &#xff08;课程7&#xff09; 难度&#xff1a;1 登录 899.从0开始&#xff08;课程7&#xff09; 登录 900.前面数 &#xff08;课程7&#xff09; 登录 901.奇数 (课程7) 登录 902.7的倍数 (课程7) …

第二证券|新冠药销售占比不到1.5%,三连板医药龙头跌停!

今天早盘&#xff0c;A股商场延续调整态势&#xff0c;沪指震动失守3100点整数关口&#xff0c;深证成指、创业板指跌幅在1%左右。 虽然指数体现不佳&#xff0c;但个股层面不乏亮点。从涨跌份额来看&#xff0c;早盘A股商场有2695只股票上涨&#xff0c;2017只股票跌落&#x…

计算机毕设Python+Vue学生在线请假管理系统(程序+LW+部署)

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

双向扩散模型

🍿*★,*:.☆欢迎您/$:*.★* 🍿 简单的描述是一个图先扩散为噪声而后 噪声扩散为另一个图 这样的思路类似如 当人类看到图之后 开始联想和脑补 不断的脑补 一步一步的 脑补出另一幅图 比如给定图的一部分 脑补出另一部分 与传统的扩散模型 不同的点在于 初始给定的是一个…

2022 UUCTF Web

目录 <1> Web (1) websign(禁用js绕过) (2) ez_rce(?>闭合 rce) (3) ez_unser(引用传递) (4) ez_upload(apache后缀解析漏洞) (5) ezsql(union注入) (6) funmd5(代码审计 %0a绕过preg_replace) (7) phonecode(伪随机数漏洞) (8) ezpop(反序列化字符串逃逸) …

Sharding-JDBC(三)按月分表

目录1.Maven 依赖2.创建表结构3.yml 配置4.TimeShardingAlgorithm.java 分片算法类5.ShardingAlgorithmTool.java 分片工具类6.ShardingTablesLoadRunner.java 初始化缓存类7.SpringUtil.java Spring工具类8.代码测试9.测试结果背景&#xff1a; 项目用户数据库表量太大&#x…

20221220英语学习

今日新词&#xff1a; hurt adj.&#xff08;身体上&#xff09;受伤的, &#xff08;感情上&#xff09;受伤的 blood n.血, 血统, 有…类型的血的, 家世 sister adj.姐妹的, 同类(型)的 humour n.&#xff08; humor&#xff09;幽默, 心情, 情绪, 脾气 holiness n.神圣…