diff options
Diffstat (limited to 'src/quick/doc/snippets/qml/item/containmentMask-circle-js.qml')
-rw-r--r-- | src/quick/doc/snippets/qml/item/containmentMask-circle-js.qml | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/quick/doc/snippets/qml/item/containmentMask-circle-js.qml b/src/quick/doc/snippets/qml/item/containmentMask-circle-js.qml new file mode 100644 index 0000000000..9aa8ddcc75 --- /dev/null +++ b/src/quick/doc/snippets/qml/item/containmentMask-circle-js.qml @@ -0,0 +1,24 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQml +import QtQuick + +//![0] +Rectangle { + id: circle + width: 100; height: width + radius: width / 2 + color: tapHandler.pressed ? "tomato" : hoverHandler.hovered ? "darkgray" : "lightgray" + + TapHandler { id: tapHandler } + HoverHandler { id: hoverHandler } + + containmentMask: QtObject { + property alias radius: circle.radius + function contains(point: point) : bool { + return (Math.pow(point.x - radius, 2) + Math.pow(point.y - radius, 2)) < Math.pow(radius, 2) + } + } +} +//![0] |