svg实现对video视频进行Cel Shaded风格化过滤效果代码

代码语言:html

所属分类:多媒体

代码描述:svg实现对video视频进行Cel Shaded风格化过滤效果代码

代码标签: video 视频 进行 Cel Shaded 风格化 过滤 效果

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


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

<head>

  <meta charset="UTF-8">

  
  
<style>
body,html {
  margin: 0;
  height: 100%;
}
body {
  max-width: 820px;
  margin: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  background: #000;
}
svg {
  position: absolute;
  width: 100%;
  height: 100%;
}
.wrap {
  overflow: hidden;
  border-radius: 10px;
  margin: 5px;
  max-width: 400px;
}
video {
  display: block;
  width: 100%;
  height: auto;
}
</style>



</head>

<body >
  <svg> 
<filter id="cel-shade" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse" primitiveUnits="userSpaceOnUse" x="0%" y="0%" width="100%" height="100%">
   
<feGaussianBlur stdDeviation="1" edgeMode="duplicate"  in="SourceGraphic" result="bg_blur"/>

<feComponentTransfer in="bg_blur" result="bg_color_reduce">
<feFuncR type="discrete" tableValues="0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1"/>
<feFuncG type="discrete" tableValues="0 1"/>  
<feFuncB type="discrete" tableValues="0 1"/>  
<feFuncA type="discrete" tableValues="1 1"/>
</feComponentTransfer>

<feColorMatrix type="matrix" values="1 0 0 0 0.1 0 1 0 0 0.35 0 0 1 0 0.1 0 0 0 1 0" in="bg_color_reduce" result="bg_color_corrected"/>
    
<feColorMatrix type="matrix" values="0.33 0.59 0.11 0 0 0.33 0.59 0.11 0 0 0.33 0.59 0.11 0 0 0 0 0 1 0" in="SourceGraphic" result="grayscale"/>

<feConvolveMatrix order="5 5" bias="1" divisor="10" kernelUnitLength="1" kernelMatrix="-5 -8 -10 -8 -5 -4 -10 -20 -10 -4 0 0 0 0 0 4 10 20 10 4 5 8 10 8 5" edgeMode="duplicate" in="grayscale" resullt="sobel_90"/>
<feColorMatrix type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" in="sobel_90" result="sobel_90_inverted"/>
    
<feConvolveMatrix order="5 5" bias="1" divisor="10" kernelUnitLength="1" kernelMatrix="5 8 10 8 5 4 10 20 10 4 0 0 0 0 0 -4 -10 -20 -10 -4 -5 -8 -10 -8 -5" edgeMode="duplicate" in="grayscale" resullt="sobel_270"/>
<feColorMatrix type="matrix" values=".........完整代码请登录后点击上方下载按钮下载查看

网友评论0