css布局实现锯齿状V形背景图案效果代码

代码语言:html

所属分类:背景

代码描述:css布局实现锯齿状V形背景图案效果代码

代码标签: 锯齿状 V 背景 图案 效果

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

<html lang="en">
<head>

    <meta charset="UTF-8">


    <style>
        body, html {
            margin: 0;
            overflow: hidden;
        }

        canvas {
            display: block;
        }
    </style>



</head>

<body>
    <canvas id="canvas" width="360" height="671"></canvas>


    <script>
        /*
  Johan Karlsson, 2021
  https://twitter.com/DonKarlssonSan
  MIT License, see Details View
  Inspired by:
  http://thepatternlibrary.com/#leather-nunchuck
  by https://twitter.com/claudioguglieri
*/
        let canvas;
        let ctx;
        let canvasOffscreen;
        let ctxOffscreen;
        let w, h
        let wOff, hOff;
        let colors;
        let xStep;
        let nrOfSteps;
        let yStep;
        let nrOfStepsY;

        function setup() {
            canvas = document.querySelector("#canvas");
            ctx = canvas.getContext("2d");
            canvasOffscreen = document.createElement("canvas");
            ctxOffscreen = canvasOffscreen.getContext("2d");
            reset();
            window.addEventListener("resize", () => {
                reset();
                draw();
            });
            setupColors();
        }

        function reset() {
            w = canvas.width = window.innerWidth;
            h = canvas.height = window.innerHeight;

            xStep = 120;
            nrOfSteps = 4;
            yStep = 50;
            nrOfStepsY = 10;
            wOff = canvasOffscreen.width = xStep * nrOfSteps;
            hOff = canvasOffscreen.height = yStep * nrOfStepsY;

            ctxOffscreen.fillRect(0, 0, wOff, hOff);
            ctxOffscreen.lineWidth = 40
            ctxOffscreen.shadowColor = "black";
            ctxOffscreen.shadowBlur.........完整代码请登录后点击上方下载按钮下载查看

网友评论0