1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/zhongbin-QmlBook-In-Chinese

Клонировать/Скачать
convenient_api.md 890
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
cwc Отправлено 09.09.2014 09:26 11420b0

便捷的接口(Convenient API)

在绘制矩形时,我们提供了一个便捷的接口,而不需要调用stroke或者fill来完成。

// convenient.qml

import QtQuick 2.0

Canvas {
    id: root
    width: 120; height: 120
    onPaint: {
        var ctx = getContext("2d")
        ctx.fillStyle = 'green'
        ctx.strokeStyle = "blue"
        ctx.lineWidth = 4

        // draw a filles rectangle
        ctx.fillRect(20, 20, 80, 80)
        // cut our an inner rectangle
        ctx.clearRect(30,30, 60, 60)
        // stroke a border from top-left to
        // inner center of the larger rectangle
        ctx.strokeRect(20,20, 40, 40)
    }
}

注意

画笔的绘制区域由中间向两边延展。一个宽度为4像素的画笔将会在绘制路径的里面绘制2个像素,外面绘制2个像素。

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/zhongbin-QmlBook-In-Chinese.git
git@api.gitlife.ru:oschina-mirror/zhongbin-QmlBook-In-Chinese.git
oschina-mirror
zhongbin-QmlBook-In-Chinese
zhongbin-QmlBook-In-Chinese
master