Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
multitouch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
multitouch
Commits
c9e6ef00
Commit
c9e6ef00
authored
Jun 17, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added margin to bounding box.
parent
3d940d14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
tests/testapp.py
tests/testapp.py
+15
-6
No files found.
tests/testapp.py
View file @
c9e6ef00
...
@@ -33,10 +33,11 @@ class Rectangle(mt.RectangularArea):
...
@@ -33,10 +33,11 @@ class Rectangle(mt.RectangularArea):
class
Polygon
(
BoundingBoxArea
):
class
Polygon
(
BoundingBoxArea
):
def
__init__
(
self
,
x
,
y
,
points
,
color
=
BLUE
,
border_color
=
RED
):
def
__init__
(
self
,
x
,
y
,
points
,
margin
=
0
,
color
=
BLUE
,
border_color
=
RED
):
super
(
Polygon
,
self
).
__init__
(
x
,
y
,
points
)
super
(
Polygon
,
self
).
__init__
(
x
,
y
,
points
)
self
.
fill_color
=
color
self
.
fill_color
=
color
self
.
border_color
=
border_color
self
.
border_color
=
border_color
self
.
margin
=
margin
self
.
on_drag
(
self
.
handle_drag
)
self
.
on_drag
(
self
.
handle_drag
)
self
.
on_pinch
(
self
.
handle_pinch
)
self
.
on_pinch
(
self
.
handle_pinch
)
...
@@ -59,10 +60,17 @@ class Polygon(BoundingBoxArea):
...
@@ -59,10 +60,17 @@ class Polygon(BoundingBoxArea):
self
.
update_bounds
()
self
.
update_bounds
()
refresh
()
refresh
()
def
contains
(
self
,
x
,
y
):
m
=
self
.
margin
return
self
.
x
-
m
<=
x
<
self
.
x
+
self
.
width
+
m
\
and
self
.
y
-
m
<=
y
<
self
.
y
+
self
.
height
+
m
def
draw
(
self
,
cr
):
def
draw
(
self
,
cr
):
# Draw bounding box
# Draw bounding box
if
draw_bounding_boxes
:
if
draw_bounding_boxes
:
cr
.
rectangle
(
self
.
x
,
self
.
y
,
self
.
width
,
self
.
height
)
m
=
self
.
margin
cr
.
rectangle
(
self
.
x
-
m
,
self
.
y
-
m
,
self
.
width
+
2
*
m
,
self
.
height
+
2
*
m
)
cr
.
set_source_rgb
(
*
self
.
border_color
)
cr
.
set_source_rgb
(
*
self
.
border_color
)
cr
.
set_line_width
(
3
)
cr
.
set_line_width
(
3
)
cr
.
stroke
()
cr
.
stroke
()
...
@@ -205,7 +213,7 @@ def on_show(window):
...
@@ -205,7 +213,7 @@ def on_show(window):
# Create blue rectangle
# Create blue rectangle
x
,
y
,
w
,
h
=
0
,
0
,
250
,
150
x
,
y
,
w
,
h
=
0
,
0
,
250
,
150
rect
=
Polygon
(
x
,
y
,
[(
0
,
0
),
(
0
,
h
),
(
w
,
h
),
(
w
,
0
)])
rect
=
Polygon
(
x
,
y
,
[(
0
,
0
),
(
0
,
h
),
(
w
,
h
),
(
w
,
0
)]
,
margin
=
20
)
draw_objects
.
append
(
rect
)
draw_objects
.
append
(
rect
)
root
.
add_area
(
rect
)
root
.
add_area
(
rect
)
...
@@ -215,7 +223,8 @@ def on_show(window):
...
@@ -215,7 +223,8 @@ def on_show(window):
# Create green triangle
# Create green triangle
x
,
y
,
w
=
400
,
400
,
200
x
,
y
,
w
=
400
,
400
,
200
h
=
triangle_height
(
w
)
h
=
triangle_height
(
w
)
triangle
=
Polygon
(
x
,
y
,
[(
0
,
h
),
(
w
,
h
),
(
w
/
2
,
0
)],
color
=
GREEN
)
triangle
=
Polygon
(
x
,
y
,
[(
0
,
h
),
(
w
,
h
),
(
w
/
2
,
0
)],
margin
=
20
,
color
=
GREEN
)
draw_objects
.
append
(
triangle
)
draw_objects
.
append
(
triangle
)
root
.
add_area
(
triangle
)
root
.
add_area
(
triangle
)
...
@@ -245,8 +254,8 @@ if __name__ == '__main__':
...
@@ -245,8 +254,8 @@ if __name__ == '__main__':
# Parse arguments
# Parse arguments
parser
=
create_parser
()
parser
=
create_parser
()
parser
.
add_argument
(
'-f'
,
'--fullscreen'
,
action
=
'store_true'
,
default
=
False
,
parser
.
add_argument
(
'-f'
,
'--fullscreen'
,
action
=
'store_true'
,
help
=
'run in fullscreen initially'
)
default
=
False
,
help
=
'run in fullscreen initially'
)
args
=
parse_args
(
parser
)
args
=
parse_args
(
parser
)
fullscreen
=
args
.
fullscreen
fullscreen
=
args
.
fullscreen
...
...
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