重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
效果图
创新互联是一家专业提供香河企业网站建设,专注与成都网站建设、网站制作、H5技术、小程序制作等业务。10年已为香河众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。html结构
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;
}
js脚本
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);
}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。