UITable color for value

1 回表示 (過去 30 日間)
Jan Moor
Jan Moor 2021 年 9 月 19 日
コメント済み: Image Analyst 2021 年 9 月 23 日
I've made a easy connectfour in matlab. Is there a possibility, that when the value in a cell from the UITable is 1, to make it red ans when it's -1 to make it yellow?
the background and the foreground color need to change.

回答 (2 件)

Image Analyst
Image Analyst 2021 年 9 月 20 日
Yes. Not sure how you're doing the display but you could make an array of circles and a colormap. Then use
imshow(yourImage, 'ColorMap', cmap);

Jan Moor
Jan Moor 2021 年 9 月 23 日
Thank you for your answer.
Here is the part of the code where it should adapt the color. for example 1 = red cell, -1 = yellow cell:
function row_inserted = button_pushed(app, col)
for row = 6:-1:1
if app.UITable.Data(row, col) == 0
app.UITable.Data(row, col) = app.active_player;
row_inserted = row;
return
end
end
row_inserted = -1;
end
function play_round(app, col, button)
row_inserted = button_pushed(app, col);
if row_inserted == 1
button.Enable = 0;
Thanks for the help.
If needed I can upload the whole game.
  2 件のコメント
Jan Moor
Jan Moor 2021 年 9 月 23 日
the table get displayed as followed with the startupFcn:
app.UITable.Data = zeros(6,7);
app.UITable.BackgroundColor = [1,1,1];
app.UITable.ForegroundColor = [1,1,1];
Image Analyst
Image Analyst 2021 年 9 月 23 日
I don't understand it. You'd need to upload the whole app.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by