Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
V
vue3-quasar-ts-study01
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hucy
vue3-quasar-ts-study01
Commits
9a82021a
Commit
9a82021a
authored
Mar 31, 2023
by
hucy
☘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:不重要的提交
parent
481607b1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
IndexPage.vue
src/modules/vue-konva/IndexPage.vue
+20
-12
No files found.
src/modules/vue-konva/IndexPage.vue
View file @
9a82021a
...
@@ -87,10 +87,10 @@ function createShape() {
...
@@ -87,10 +87,10 @@ function createShape() {
draggable
:
true
,
draggable
:
true
,
});
});
state
.
shape
=
new
Konva
.
Rect
({
state
.
shape
=
new
Konva
.
Rect
({
width
:
3
0
+
Math
.
random
()
*
30
,
width
:
6
0
+
Math
.
random
()
*
30
,
height
:
3
0
+
Math
.
random
()
*
30
,
height
:
6
0
+
Math
.
random
()
*
30
,
fill
:
'grey'
,
fill
:
'grey'
,
rotation
:
360
*
Math
.
random
(),
//
rotation: 360 * Math.random(),
name
:
'fillShape'
,
name
:
'fillShape'
,
});
});
state
.
group
.
add
(
state
.
shape
);
state
.
group
.
add
(
state
.
shape
);
...
@@ -117,10 +117,10 @@ function haveIntersection(r1: any, r2: any) {
...
@@ -117,10 +117,10 @@ function haveIntersection(r1: any, r2: any) {
c
:
false
,
c
:
false
,
d
:
false
,
d
:
false
,
};
};
let
pos
:
any
=
{
//
let pos: any = {
x
:
r2
.
x
+
r2
.
width
,
//
x: r2.x + r2.width,
y
:
r2
.
y
+
r2
.
height
,
//
y: r2.y + r2.height,
};
//
};
if
(
r2
.
x
>
r1
.
x
+
r1
.
width
)
{
if
(
r2
.
x
>
r1
.
x
+
r1
.
width
)
{
obj
.
a
=
true
;
obj
.
a
=
true
;
}
}
...
@@ -133,11 +133,11 @@ function haveIntersection(r1: any, r2: any) {
...
@@ -133,11 +133,11 @@ function haveIntersection(r1: any, r2: any) {
if
(
r2
.
y
+
r2
.
height
<
r1
.
y
)
{
if
(
r2
.
y
+
r2
.
height
<
r1
.
y
)
{
obj
.
d
=
true
;
obj
.
d
=
true
;
}
}
console
.
log
(
'obj'
,
obj
,
obj
.
a
||
obj
.
b
||
obj
.
c
||
obj
.
d
);
//
console.log('obj', obj, obj.a || obj.b || obj.c || obj.d);
return
{
return
{
value
:
!
(
obj
.
a
||
obj
.
b
||
obj
.
c
||
obj
.
d
),
value
:
!
(
obj
.
a
||
obj
.
b
||
obj
.
c
||
obj
.
d
),
pos
,
//
pos,
};
};
// return !(
// return !(
...
@@ -156,13 +156,21 @@ function layerDragmove(e: any) {
...
@@ -156,13 +156,21 @@ function layerDragmove(e: any) {
if
(
group
.
_id
==
target
.
_id
)
{
if
(
group
.
_id
==
target
.
_id
)
{
return
;
return
;
}
}
// r1当前循环的可视矩形区域 r2当前移动目标的可视矩形区域
let
r1
=
group
.
getClientRect
();
let
r1
=
group
.
getClientRect
();
let
r2
=
targetRect
;
let
r2
=
targetRect
;
let
result
=
haveIntersection
(
r1
,
r2
);
let
result
=
haveIntersection
(
r1
,
r2
);
if
(
result
.
value
)
{
if
(
result
.
value
)
{
console
.
log
(
'1'
,
target
.
_lastPos
);
// 有碰撞
// target.x(result.pos.x);
console
.
log
(
'1'
,
target
);
// target.y(result.pos.y);
if
(
r2
.
x
<
r1
.
x
+
r1
.
width
/
2
)
{
target
.
x
(
r1
.
x
-
r2
.
width
);
}
else
{
target
.
x
(
r1
.
x
+
r1
.
width
);
}
// target.x(100);
// target.y(100);
group
.
findOne
(
'.fillShape'
).
fill
(
'red'
);
group
.
findOne
(
'.fillShape'
).
fill
(
'red'
);
}
else
{
}
else
{
group
.
findOne
(
'.fillShape'
).
fill
(
'grey'
);
group
.
findOne
(
'.fillShape'
).
fill
(
'grey'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment