_(chng) mȻڌ(sh)H_l(f)҂ȥL̈D Ҫ҂Ҳ(hu)ͨ^(gu)3ȥ(sh)F(xin) ҂(li)(jin)Ό(sh)F(xin)̈DкСһ ք(dng)Lƾ Lһ(g)ε˼· ҂@Lƾ (hu)ʹõcanvas.strokeRect(x,y, w, h)Lһ(g)߅ x:c(din) x S(bio) y:
mȻڌ(sh)H_l(f)҂ȥL̈D
Ҫ҂Ҳ(hu)ͨ^(gu)3ȥ(sh)F(xin)
҂(li)(jin)Ό(sh)F(xin)̈DкСһ
ք(dng)Lƾ
҂@Lƾ
(hu)ʹõcanvas.strokeRect(x,y, w, h)Lһ(g)߅
x:c(din) x S(bio)
y:c(din) y S(bio)
width:εČȡֵ߅ؓ(f)ֵ߅
height:εĸ߶ֵ½ؓ(f)ֵ
עһw,h@ɂ(g)(sh)ֱؓ(f)ֵ
w,hؓ(f)(sh)(hu)F(xin)2(g)б(du)Qľ
Document
ͨK�K�K�K�K�(sh)K�K˾�B(ti)K�Kƾ�KI�
K�K�K�K�KҪ�ֶK�Kһ�K�K�K?K�Ҫ(sh)K�K�Kq|K�K�K�
1.K�canvasעK�K�_(d)K�K?K(ji)ͿKq�r(sh)K�Kq|K�εK�Kg|K�K?x,y)
K�Kͬʱ�K�K�KҪ�xK�Kgע�K�K�KӞKq|K�̧K�Kq|K�
2.K�K�K�ؚK�Kg�Kͨ�K�K�KC�K�KIĿ�Kߡ�
K�K�K�εĿK�Ⱥ߶Kg�K�K�KҪʹ�VK�Kֵ�K�мK�?
K�K�K�K�K�K�{K�K?
3.K�K�Ķ�Kg�K�ƳK֮ǰע�K�K�K�ؚK�K�Ķ�K�K?
ͨK�K�K�K�K�DƬK�K�K�K�ȻK�K�KӞK�KƻIK˾�KI�
K�KǻIK�K�Kظ�K�·K�K�
K�K�KPK�һKqIK�Kظ�·K�K�ԭK�
K�K�K�ÿK�KӞKe�K�KУ�K�K�K�{K�ΡK?
ֻҪK�K�K(ji)�K�ǰK�K�վK�K�DzK�NͿK�ԽK�K�K�K�K?
K�K�K�K�K�һK�
function drawRect(x1,y1,x2,y2){
// K(ji)|K�K�εĿK�Kg�K�K�K�KҪʹ�VK�Kֵ�K�K�мK�K? // K�r(sh)K˿�KӞK�K�K�K�K�K�Kq�K�K�K�NK�εĿK�K? let rectWidth = Math.abs(x2-x1)
let rectHeight = Math.abs(y2-y1)
// K惦(ch)K�KI�K�K�K�Ϣ
rectArr = [x1,y1,rectWidth,rectHeight]
// K(ji)�Kƾ�K�ǰK�K�Kǽ�K�K�K�գK�K�՟K�ƣK�ͲK�K�KӞK�KqPK�K? ctx.clearRect(0,0, canvasEle.width, canvasEle.height)
// K�Kq�Kƾ�K�
ctx.strokeRect(...rectArr)
}
K�ЩK�Kǵ�СK��K?
K�K�K�Kg|K�K�K�K?Kյ�K�K�K^ǡ�
K�:KC�K�(900, 1000)K^ӞK�(50, 50)K�K�K�K?
K�K�K�K�KePK�K�{K�ΣK�DzK�ǻK�K�K�K�Kأ�
_(sh)K�K�K�K�?
K�r(sh)K�KƵľ�KIԌK�K�K�K�KǵPK�K�xK�ơK�_(d)K�K�D
K�δK�K�K�K�K�Kأ�
canvas.rect(x,y,w,h)KCPK�K�K�һK�K�K�·K�
x:K�K�K�K� x K�K�K
y:K�K�K�K� y K�K�K
width:K�KIĿ�K�K�ֵK�K߅�K�ֵK�K�ߡK?
height:K�KIĸ߶ȡ�K�ֵKq�K�K�ֵK�K�K�
K�K�K�K�lK�Kһ�K�K�KqPK�K�K�K�KqPK�K�K�Kֱ�xK�K�՟K�K�ϡK?
K�ҪK�K�stroke()K�fill()K�K�K�ʾK(ji)�K�K^�
function drawRect(x1,y1,x2,y2){
let rectWidth = Math.abs(x2-x1)
let rectHeight = Math.abs(y2-y1)
// K�K�֮ǰK�K�K֮ǰʵʱ�ؚK�K�K�K�Ke�K�·K�
ctx.clearRect(0,0, canvasEle.width, canvasEle.height)
// K�ʼK�K�
ctx.beginPath();
// K�K�·K�K�K�
ctx.rect(Math.min(x1, x2), Math.min(y1, y2), rectWidth, rectHeight);
// K�K�K�K�K�K�K�
ctx.stroke();
}
K�K�1K�K�K�: canvas.strokeRect:K�KƵ�K߅�canvas.rectK�K�K�KI�·K�(K�K�K�K�K�K�K(ji)�K�K�)
K�K�2K�r(sh)K�: canvas.strokeRectK�K�K�K�Kơ�canvas.rectK�K�K�K�K�Kƣ�K�ҪK�K�stroke()K�fill()K�Kܻ�K�
K�ͬK㣺
1.K�Kǻ�Kƾ�K�
2.K�KܵԌK�K�ͬ
3.K�K�ͨK�strokeStyle(K�ɫ)K�lineWidth(Kߵ_(d)(x))K�K�K�K�K�ʽ
function drawRect(x1,y1,x2,y2){
let rectWidth = Math.abs(x2-x1)
let rectHeight = Math.abs(y2-y1)
let endX = Math.min(x1, x2)
let endY = Math.min(y1, y2)
// K�K�֮ǰK�K�K֮ǰʵʱ�ؚK�K�K�K�Ke�K�·K�
ctx.clearRect(0,0, canvasEle.width, canvasEle.height)
// K�K�֮ǰK�ЩK惦(ch)K� beforeRectArr K�K�Kеľ�K�
allRectInfoArr = [endX, endY, rectWidth, rectHeight]
ctx.clearRect(0,0, canvasEle.width, canvasEle.height)
beforeRectArr.forEach(element => {
ctx.beginPath();
ctx.strokeRect(...element)
ctx.stroke();
});
// K�ʼK�K�·K�
ctx.beginPath();
// K�KƱ�KIľ�K�·K�
ctx.rect(...allRectInfoArr);
// K�ʼK�K�K�
ctx.stroke();
}
// K�K�K�K�Ķ�K�r(sh)K�ҪKƻI֮ǰעK�KӞKq|K�̧K�Kq|
function canvasMouseUpHandler(){
savaBeforeRect()
canvasEle.removeEventListener('mousemove', canvasMoveHandler)
canvasEle.removeEventListener('mouseup', canvasMouseUpHandler)
}
function savaBeforeRect(){
beforeRectArr.push(allRectInfoArr)
}
Document
K�KС�K�K�K�K_(d)IJK�K�ĻK?
K�KԸ�Kҵ�K�K�wKл�ˡK?
K�K�K�K�:
K�Kѡ�оK�ΣK�K�ľK�δKС�K?
K�K�aK�K�K�K�K�K�K?
K�λK�KԌK�KPK�ZK?
K�K�W(xu)(x)K�K�K�K瘋(gu)K�K�Kq�
KeӞK�MateƷK�ʢK䣺HarmonyOS NEXTKӻIK�K�K�Kܵõ�K�K�^K?/a>
KeӞ(sh)KӞK�K�DataTableK�KD(zhun)K�
KeӞK�K�NEXTԪK�K�K�K�K�Kѿ�K�K^|K�Ʒ
KeӞK�K�KArcMapK�K�Kн�K�K�DK�KԌK�K�K�
KeӞK�ӍK�K�K߿PK�I(yng)K�ϵy(tng)K�K�
KeӞK�K(ji)�K�NEXTK�ѪK�K__(d)K�K�K�K�K�K�K�
KeӞ5. Spring Cloud OpenFeign K�K�ʽ WebService Kͻ�K˵ĻIK�(x)ʹK�
KeӞJavaK�K�ģʽK�K�B(ti)K�K�KӞB(ti)K�K�Ke(du)PK�
KeӞWin11Kgӛ�K�KӞK�K�(yng)KC�K�ɫK�K�ʾK�K�
KeӞK�վK�K�K�K�K�K�K�K�K�K^_(d)K�K�K�KPK�İK�K�뷢�ʼK?a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dabbbeb7b3b49ab2bbb5aebff4b9b5b7">[email protected]
K�ICPK�2022002427K�-10 K湫K�K�K�K�43070202000427K�© 2013~2025 haote.com K�K�K�