Skip to main content

Using Canvas to paint a word array...

1 reply [Last post]
bedwards
Offline
Joined: 2006-03-06
Points: 0

I am trying to display an array of words as Text objects in a Canvas.
The array is five words of five characters each. The idea is to use
guess words to match a secret word, and display the matching letters
in red; unmatched letters in yellow. The problem is that the Canvas
only shows four rows of words, omitting row "zero". Any ideas?
I'm using the NB 6.0 interpreter for this prototype. Code snippet:

Frame {
title: "LINGO"
height: 400
width: 300
visible: true
onClose: operation() { System.exit(0); }
content: GroupPanel {
border: EmptyBorder {
top: 10
left: 10
bottom: 10
right: 10
}
var tableRow = Row { alignment: BASELINE }
var guessRow = Row { alignment: BASELINE }
var messageRow = Row { alignment: BASELINE }
var buttonRow = Row { alignment: BASELINE }
var singleCol = Column { alignment: LEADING }
rows: [
tableRow,
guessRow,
messageRow,
buttonRow
]
columns: [singleCol]
content: [
Canvas {
border: LineBorder {
lineColor: black
thickness: 2
}
row: tableRow
column: singleCol
//height: 400
//width: 400
content: bind foreach (i in [0..4], j in [0..4])
Text {
x: (j * 50)
y: (i * 50)
content: bind wordsTest.words[i].substring(j,j+1)
font: wordFont
stroke: black
fill: bind if (wordsTest.hits[i].substring(j,j+1) == "1") then red else yellow
strokeWidth: 1
valign: BOTTOM
}
}, FlowPanel {

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bedwards
Offline
Joined: 2006-03-06
Points: 0

Never mind. Sometimes you miss the obvious.

y: (i+1)*50)