level 12
xsjqqq123
楼主
这一句中的var ctx = canvas.getContext('2d')原话是object Canvas::getContext(string
contextId, any),它有什么用?2d是画布的环境?但有些比如ctx.rect。ctx.fill(),在参考中找不到这个方法啊,是不是html5能用的,qtquick教能直接用?
import QtQuick 2.0
Rectangle {
id: root
width: 360; height: 360
color: "#3C3C3C"
Canvas {
id: canvas
width: 300; height: 300
anchors.centerIn: parent
onPaint: {
// get the drawing context
var ctx = canvas.getContext('2d')
// create a rectangle path
ctx.rect(50, 50, 200, 200)
// setup fill color
ctx.fillStyle = "#FFF0A5"
// fill path
ctx.fill()
// setup line width and stroke color
ctx.lineWidth = 4
ctx.strokeStyle = "#468966"
// stroke path
ctx.stroke()
}
}
}
2013年04月13日 15点04分
1
contextId, any),它有什么用?2d是画布的环境?但有些比如ctx.rect。ctx.fill(),在参考中找不到这个方法啊,是不是html5能用的,qtquick教能直接用?
import QtQuick 2.0
Rectangle {
id: root
width: 360; height: 360
color: "#3C3C3C"
Canvas {
id: canvas
width: 300; height: 300
anchors.centerIn: parent
onPaint: {
// get the drawing context
var ctx = canvas.getContext('2d')
// create a rectangle path
ctx.rect(50, 50, 200, 200)
// setup fill color
ctx.fillStyle = "#FFF0A5"
// fill path
ctx.fill()
// setup line width and stroke color
ctx.lineWidth = 4
ctx.strokeStyle = "#468966"
// stroke path
ctx.stroke()
}
}
}

