canvas滚动多彩笔刷绘制白墙效果代码

代码语言:html

所属分类:加载滚动

代码描述:canvas滚动多彩笔刷绘制白墙效果代码

代码标签: canvas 笔刷 滚动 绘制 白墙

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style type="text/css">
    body {
      margin: 0;
      background: #eee;
      height: 100vh;
      min-height: 100vh;
    }

    .lines {
      display: block;
      margin: 0 auto;
      background: #fff;
      z-index: 2;
    }

    .brushes {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 1;
      background: transparent;
    }

    .status {
      position: fixed;
      top: 0;
      left: 10px;
      color: #777;
      font-size: 12px;
      font-family: monospace;
    }
  </style>
</head>
<body>
  <p class="status"></p>
  <script type="text/javascript">
    const dpr = Math.min( window.devicePixelRatio, 2 );
    const body = document.body;
    const status = document.querySelector( '.status' );
    const modes = [
      { id: 'brush', t: 0 },
      { id: 'line', t: 0 },
      { id: 'dash', t: 4 },
      { id: 'worm', t: 4 }
    ];

    let width,
        height,
        canvasWidth,
        canvasHeight;

    const brushDefaults = { x: 0.5, tx: 0.5, ttx: 0.5, y: 0, ty: 0.9, w: 1, tw: 1 };
    const brushCanvas = createCanvas( 'brushes' );
    const brushContext = brushCanvas.getContext( '2d' .........完整代码请登录后点击上方下载按钮下载查看

网友评论0