91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

canvas做的圖片查看器1

發布時間:2020-08-06 15:56:49 來源:網絡 閱讀:436 作者:素顏豬 欄目:開發技術

效果圖

canvas做的圖片查看器1

html結構

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>Canvas</title>

<link rel="stylesheet" href="">

<style>

body{

background-color: #000;

}


#canvas{

display: block;

margin: 0 auto;

border: 1px solid #aaa;

}


.range-style{

display: block;

margin: 20px auto;

width: 800px;

}


.watermark-canvas-style{

display: block;

margin: 0 auto;

border: 1px solid #aaa;

}

</style>

</head>

<body>

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

<input type="range" class="range-style" id="scale-range" min="0.5" max="3.0" step = "0.01" value="0.5">

<canvas id="watermark-canvas" class="watermark-canvas-style"></canvas>

</body>

</html>

js腳本

<script>

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

var slider = document.getElementById("scale-range");

var watermarkCanvas = document.getElementById("watermark-canvas");


var context = canvas.getContext("2d");

var watermarkContext = watermarkCanvas.getContext("2d");


var image = new Image();


window.onload = function(){

canvas.width = 600;

canvas.height = 450;


var scale = slider.value;

console.log(scale);


image.src = "20170122161717.png";

image.onload = function(){

// context.drawImage(image,0,0,canvas.width,canvas.height);

drawImageByScale(scale);


slider. = function(){

scale = slider.value;

drawImageByScale(scale);

}

}


watermarkCanvas.width = 500;

watermarkCanvas.height = 100;


watermarkContext.font = "bold 50px Arial";

watermarkContext.fillStyle = "rgba(255,255,255,0.5)";

watermarkContext.textBaseline = "middle";

watermarkContext.fillText("%:)%yunshuo%:)%",20,50);

}



function drawImageByScale(scale){

var imageWidth = 600 * scale;

var imageHeight = 450 * scale;


// var sx = imageWidth / 2 - canvas.width / 2;

// var sy = imageHeight / 2 - canvas.height / 2;


// context.drawImage(image,sx,sy,canvas.width,canvas.height,0,0,canvas.width,canvas.height);

var dx = canvas.width / 2 - imageWidth / 2;

var dy = canvas.height / 2 - imageHeight / 2;

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

context.drawImage(image,dx,dy,imageWidth,imageHeight);

context.drawImage(watermarkCanvas,canvas.width - watermarkCanvas.width,canvas.height - watermarkCanvas.height);


}


</script>

canvas做的圖片查看器1

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

平湖市| 老河口市| 石渠县| 广西| 黎城县| 莎车县| 达孜县| 镇雄县| 万盛区| 寿宁县| 云林县| 布拖县| 绥棱县| 博乐市| 大港区| 德格县| 乌兰察布市| 恩施市| 天祝| 哈巴河县| 彰武县| 青浦区| 永登县| 六枝特区| 海门市| 中宁县| 富蕴县| 深州市| 河曲县| 长汀县| 海门市| 民权县| 庐江县| 田林县| 文水县| 五莲县| 麟游县| 广灵县| 大新县| 志丹县| 象州县|