第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

附上一個(gè)demo,我想要讓文字浮上來,探照燈部分高亮,大神給我一點(diǎn)思路吧?。?/h1>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>剪輯區(qū)域--demo4</title>

<style>

*{margin: 0;padding: 0}

canvas{display: block;margin: 50px auto;border:solid 1px grey;}

</style>

</head>

<body>

<canvas id="canvas"></canvas>

<script>

var canvas = document.getElementById('canvas');

canvas.width = 800;

canvas.height = 500;

var cxt = canvas.getContext('2d');

//填充canvas

function drawRect(cxt){

cxt.fillStyle = 'rgba(1,1,1)';

cxt.fillRect(0,0,canvas.width,canvas.height);


}


//探照燈,x,y為鼠標(biāo)相對(duì)canvas的坐標(biāo)

function drawArc(cxt,x,y,r){

cxt.clearRect(0,0,canvas.width,canvas.height);

drawRect(cxt);


cxt.save();

cxt.arc(x,y,r,0,2*Math.PI);

cxt.fillStyle = '#fff';

cxt.fill();

cxt.clip();


drawText(cxt)

cxt.restore();

}

//繪制文字

function drawText(cxt){

//繪制三行文字

cxt.clearRect(0,0,canvas.width,canvas.height)

cxt.beginPath();

cxt.font = '20px 隸書';

cxt.fillStyle = 'green';

cxt.fillText('生命,就像是一張借記卡,從你呱呱墜地,還未有名字的時(shí)候,你生命的借記卡就已經(jīng)毫不延遲的啟動(dòng)了它的業(yè)務(wù)。',0,50)

cxt.fillText('儲(chǔ)存在生命借記卡上的數(shù)字,就是你這一生所有的時(shí)光。',0,100)

cxt.fillText('幸好不知道,我們才會(huì)一邊消費(fèi)著卡額,一邊無憂無慮的生活。',0,150)

}

canvas.onmousemove = function(event){

//計(jì)算出鼠標(biāo)相對(duì)canvas的位置

clientX = event.clientX;

clientY = event.clientY;

curX = clientX - this.offsetLeft;

curY = clientY - this.offsetTop;


drawArc(cxt,curX,curY,50)


}

canvas.onmouseout = function(){

cxt.clearRect(0,0,canvas.width,canvas.height);

drawRect(cxt);

}

drawRect(cxt)

</script>

</body>

</html>


正在回答

1 回答

不太清楚你到底想要什么效果,看看這個(gè)行不行吧

<!DOCTYPE?html>
<html>
<head>
	<meta?charset="UTF-8">
	<title>剪輯區(qū)域--demo4</title>
	<style>
		*?{
			margin:?0;
			padding:?0
		}
		
		canvas?{
			display:?block;
			margin:?50px?auto;
			border:?solid?1px?grey;
		}
	</style>
</head>

<body>
	<canvas?id="canvas"></canvas>
	<script>
		var?canvas?=?document.getElementById('canvas');
		canvas.width?=?800;
		canvas.height?=?500;
		var?cxt?=?canvas.getContext('2d');
		//探照燈,x,y為鼠標(biāo)相對(duì)canvas的坐標(biāo)
		function?drawArc(cxt,?x,?y,?r)?{
			cxt.clearRect(0,?0,?canvas.width,?canvas.height);
			drawText(cxt);

			cxt.save();
			cxt.arc(x,?y,?r,?0,?2?*?Math.PI);
			cxt.fillStyle?=?'#fff';
			cxt.fill();
			cxt.clip();

			drawText(cxt,'green')
			cxt.restore();
		}
		//繪制文字
		function?drawText(cxt,color)?{
			//繪制三行文字
			cxt.clearRect(0,?0,?canvas.width,?canvas.height)
			cxt.beginPath();
			cxt.font?=?'20px?隸書';
			cxt.fillStyle?=?color?||?'black';
			cxt.fillText('生命,就像是一張借記卡,從你呱呱墜地,還未有名字的時(shí)候,你生命的借記卡就已經(jīng)毫不延遲的啟動(dòng)了它的業(yè)務(wù)。',?0,?50)
			cxt.fillText('儲(chǔ)存在生命借記卡上的數(shù)字,就是你這一生所有的時(shí)光。',?0,?100)
			cxt.fillText('幸好不知道,我們才會(huì)一邊消費(fèi)著卡額,一邊無憂無慮的生活。',?0,?150)
		}
		canvas.onmousemove?=?function(event)?{
			//計(jì)算出鼠標(biāo)相對(duì)canvas的位置
			clientX?=?event.clientX;
			clientY?=?event.clientY;
			curX?=?clientX?-?this.offsetLeft;
			curY?=?clientY?-?this.offsetTop;

			drawArc(cxt,?curX,?curY,?50)

		}
		canvas.onmouseout?=?function()?{
			cxt.clearRect(0,?0,?canvas.width,?canvas.height);
			drawText(cxt);
		}
	</script>
</body>
</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

附上一個(gè)demo,我想要讓文字浮上來,探照燈部分高亮,大神給我一點(diǎn)思路吧?。?/h1> 我要回答 關(guān)注問題

微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)