js实现canvas皇家斯图尔特格子背景效果代码
代码语言:html
所属分类:背景
代码描述:js实现canvas皇家斯图尔特格子背景效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
margin:0;
background:#034710;
}
#cvs {
border:solid black 4px;
border-radius:12px;
position:absolute;
left:50%;
top:50%;
transform:translate(-50%,-50%);
}
</style>
</head>
<body >
<canvas id="cvs" width="599" height="599"></canvas>
<script >
let ctx
const SQUARE_SIZE = 599
const MAIN_COLOR = '#AB0303'
const RED_WEAVE_COLOR = '#810303'
const BLUE_WEAVE_COLOR = '#2C215E'
const BLACK_WEAVE_COLOR = '#150B0B'
const YELLOW_WEAVE_COLOR = '#AB8D03'
const WHITE_WEAVE_COLOR = '#B9B9B9'
const GREEN_WEAVE_COLOR = '#094710'
const BLUE_BK_COLOR = '#25256D'
const BLACK_BK_COLOR = '#0C0C0C'
const GREEN_BK_COLOR = '#035613'
const YELLOW_BK_COLOR = '#C3A103'
const YELLOW_BK_WEAVE_COLOR = '#987E03'
const WHITE_BK_COLOR = '#D4D4D4'
const WHITE_BK_WEAVE_COLOR = '#A1A1A1'
function drawTartan() {
const cvsNd = document.getElementById("cvs")
ctx = cvsNd.getContext('2d')
solidWeave({x:0,y:0,w:SQUARE_SIZE,h:SQUARE_SIZE,c:MAIN_COLOR,wc:RED_WEAVE_COLOR})
let nNewY = 0
let nWidth = 72
let nNewX = 0
gapRow({y:nNewY,h:72})
nNewY = 180
gapRow({y:nNewY,h:20})
nNewY = nNewY + 26
gapRow({y:nNewY,h:8})
nNewY = nNewY + 16
gapRow({y:nNewY,h:8})
nNewY = nNewY + 16
gapRow({y:nNewY,h:20})
nNewY = nNewY + 130
gapRow({y:nNewY,h:152})
// ***
nNewX=0
nNewY=0
nNewY = 72
regRow({y:nNewY,h:18,c:BLUE_WEAVE_COLOR,bgc:BLUE_BK_COLOR})
nNewY=nNewY+18
regRow({y:nNewY,h:24,c:BLACK_WEAVE_COLOR,bgc:BLACK_BK_COLOR})
nNewY=nNewY+24
regRow({y:nNewY,h:8,c:YELLOW_WEAVE_COLOR})
nNewY=nNewY+8
regRow({y:nNewY,h:8,c:BLACK_WEAVE_COLOR,bgc:BLACK_BK_COLOR})
nNewY=nNewY+8
regRow({y:nNewY,h:8,c:WHITE_WEAVE_COLOR,bgc:BLUE_BK_COLOR})
nNewY=nNewY+8
regRow({y:nNewY,h:8,c:BLACK_WEAVE_COLOR,bgc:BLACK_BK_COLOR})
nNewY=nNewY+8.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0