Компьютерное моделирование 2017-2018 учебный год Лабораторная работа 3 Клеточный автомат Пример 3. Закрасить ячейки так, чтобы образовался градиент, а в соответствующих ячейках программа записывает значение красной составляющей цвета от 0 до 255. Задание. Создайте отдельные кнопки для трех составляющих цвета: красный, синий, зеленый. Добавьте кнопку, которая очищает все в задействованной области ячейки и задает белый цвет фона ' Глобальные константы Const COL_X = 1 Const COL_Y = 2 Const COL_RED = 3 Const COL_GREEN = 4 Const COL_BLUE = 5 Const ROW_START = 2 Const ROW_END = 3 Const ROW_COLOR1 = 4 Const ROW_COLOR2 = 5 Const ROW_X = 2 Const ROW_Y = 2 Const ROW_RED = 2 Const ROW_GREEN = 3 Dim x As Integer Dim stepColor As Integer Dim cellColor As Integer Dim redColor As Integer Dim greenColor As Integer Sub Main Doc = StarDesktop.CurrentComponent Sheet = Doc.Sheets(0) CellRedStart = Sheet.getCellByPosition(COL_RED, ROW_START) redStart = CellRedStart.Value CellRedEnd = Sheet.getCellByPosition(COL_RED, ROW_END) redEnd = CellRedEnd.Value CellRedColor1 = Sheet.getCellByPosition(COL_RED, ROW_COLOR1) CellRedColor2 = Sheet.getCellByPosition(COL_RED, ROW_COLOR2) stepColor = (CellRedColor2.Value - CellRedColor1.Value)/(redEnd - redStart) cellColor = CellRedColor1.Value for xRedRow = redStart to redEnd CellRedRow = Sheet.getCellByPosition(xRedRow, ROW_RED) CellRedRow.CellBackColor = RGB(cellColor, 0, 0) cellColor = cellColor + stepColor if cellColor > CellRedColor2.Value then cellColor = CellRedColor2.Value end if CellRedRow.Value = cellColor next xRedRow x = x + 1 Cell_X = Sheet.getCellByPosition(COL_X, ROW_X) Cell_X.Value = x End Sub Пример 4. [4] Sub Main ThisComponent.currentSelection.IsCellBackgroundTransparent = True End Sub Пример 4. [5] oCellToCheck.Formula = ""
Основные источники
inf.1september.ru: Алгоритмы перебора. И.И.Данилина
Дополнительные источники
forum.openoffice.org: Basic macro to color cell background.
stackoverflow.com How to change the background color of a cell on mouse click in Libre Office Calc?
ooo-forums.apache.org: Change cell color macro.
forum.openoffice.org: Quickly remove background color from selected cells.
ooo-forums.apache.org: Test for blank cell and put word into cell if blank.