本文整理匯總了TypeScript中pixi.js.Graphics.lineTo方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript js.Graphics.lineTo方法的具體用法?TypeScript js.Graphics.lineTo怎麽用?TypeScript js.Graphics.lineTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pixi.js.Graphics
的用法示例。
在下文中一共展示了js.Graphics.lineTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor (label: (string | (string | Item)[]), width: number, hint?: string, disabled: boolean = false) {
super()
const contentWidth = width // TODO MUST ACCOUNT FOR PADDING AND BORDER
if (typeof label === 'string') {
label = [label]
}
const textContainer = this.makeTextContainer(label, contentWidth)
textContainer.x = (contentWidth / 2) - (textContainer.width / 2)
textContainer.y = BORDER_WIDTH + PADDING
const graphics: Graphics = new Graphics()
if (disabled) {
graphics.beginFill(DB16.LIGHT_GRAY)
} else {
graphics.beginFill(DB16.WHITE)
}
graphics.drawRect(
BORDER_WIDTH,
BORDER_WIDTH,
width - 2 * BORDER_WIDTH,
textContainer.height + 2 * PADDING,
)
const innerHeight = textContainer.height + 2 * PADDING
graphics.lineStyle(BORDER_WIDTH, DB16.DARK_GRAY)
// Top
graphics.moveTo(BORDER_WIDTH, BORDER_WIDTH / 2)
graphics.lineTo(width - BORDER_WIDTH, BORDER_WIDTH / 2)
// Bottom
graphics.moveTo(BORDER_WIDTH, innerHeight + BORDER_WIDTH + BORDER_WIDTH / 2)
graphics.lineTo(width - BORDER_WIDTH, innerHeight + BORDER_WIDTH + BORDER_WIDTH / 2)
// Left
graphics.moveTo(BORDER_WIDTH / 2, BORDER_WIDTH)
graphics.lineTo(BORDER_WIDTH / 2, innerHeight + BORDER_WIDTH)
// Right
graphics.moveTo(width - BORDER_WIDTH / 2, BORDER_WIDTH)
graphics.lineTo(width - BORDER_WIDTH / 2, innerHeight + BORDER_WIDTH)
this.addChild(graphics)
this.addChild(textContainer)
if (hint) {
const hintText = new Text(hint, HINT_STYLE)
hintText.x = textContainer.x - hintText.width - PADDING
hintText.y = BORDER_WIDTH + (innerHeight / 2) - (hintText.height / 2)
this.addChild(hintText)
}
}