i j 直接从0开始遍历,当blurR半径比较大的时候,越界的像素点用另一边的像素点补充,边缘就可以模糊一些了,虽然效率有点慢,哈哈哈,四层循环里面判断下x y的值就可以了
for(let k = 0; k < blurR; k++){
if( x < 0){
x += canvasb.height;
}else if(x > canvasb.height - 1){
x -= canvasb.height; }
if( y < 0){
y += canvasb.width;
}else if(y > canvasb.width - 1){
y -= canvasb.width;}
}
for(let k = 0; k < blurR; k++){
if( x < 0){
x += canvasb.height;
}else if(x > canvasb.height - 1){
x -= canvasb.height; }
if( y < 0){
y += canvasb.width;
}else if(y > canvasb.width - 1){
y -= canvasb.width;}
}
2018-04-03
第一个:
var imageWidth = canvas.width * scale;
var imageHeight = canvas.height * scale;
var x = (imageWidth - canvas.width) / (2*scale);
var y = (imageHeight - canvas.height)/ (2*scale);
context.drawImage( image , x , y , canvas.width/scale , canvas.height/scale , 0 , 0 , canvas.width , canvas.height )
var imageWidth = canvas.width * scale;
var imageHeight = canvas.height * scale;
var x = (imageWidth - canvas.width) / (2*scale);
var y = (imageHeight - canvas.height)/ (2*scale);
context.drawImage( image , x , y , canvas.width/scale , canvas.height/scale , 0 , 0 , canvas.width , canvas.height )
2018-03-19
第一种方法,只是假想扩大了,其实并没有,所以最后的坐标跟长宽还要改回去,应该是
context.drawImage( image , sx/scale , sy/scale , canvas.width/scale , canvas.height/scale , 0 , 0 , canvas.width , canvas.height )
context.drawImage( image , sx/scale , sy/scale , canvas.width/scale , canvas.height/scale , 0 , 0 , canvas.width , canvas.height )
2018-03-19
var mousedown = false
slider.onmousedown = function () {
mousedown = true
}
slider.onmouseup = function () {
mousedown = false
}
slider.onmousemove = function () {
if (mousedown) {
scale = this.value
drawImageByScale(scale)
}
}
slider.onmousedown = function () {
mousedown = true
}
slider.onmouseup = function () {
mousedown = false
}
slider.onmousemove = function () {
if (mousedown) {
scale = this.value
drawImageByScale(scale)
}
}
2018-02-02
温馨提示:img-lg这个图片本来是大的,绘制到canvas上的时候缩小了,使用放大镜绘制的时候,直接使用了这个图片,都是据此计算的
2018-01-11