PINE LIBRARY
Canvas

Library "Canvas"
A library implementing a kind of "canvas" using a table where each pixel is represented by a table cell and the pixel color by the background color of each cell.
To use the library, you need to create a color matrix (represented as an array) and a canvas table.
The canvas table is the container of the canvas, and the color matrix determines what color each pixel in the canvas should have.
max_canvas_size() Function that returns the maximum size of the canvas (100). The canvas is always square, so the size is equal to rows (as opposed to not rows multiplied by columns).
Returns: The maximum size of the canvas (100).
get_bg_color(color_matrix) Get the current background color of the color matrix. This is the default color used when erasing pixels or clearing a canvas.
Parameters:
color_matrix: The color matrix.
Returns: The current background color.
get_fg_color(color_matrix) Get the current foreground color of the color matrix. This is the default color used when drawing pixels.
Parameters:
color_matrix: The color matrix.
Returns: The current foreground color.
set_bg_color(color_matrix, bg_color) Set the background color of the color matrix. This is the default color used when erasing pixels or clearing a canvas.
Parameters:
color_matrix: The color matrix.
bg_color: The new background color.
set_fg_color(color_matrix, fg_color) Set the foreground color of the color matrix. This is the default color used when drawing pixels.
Parameters:
color_matrix: The color matrix.
fg_color: The new foreground color.
color_matrix_rows(color_matrix, rows) Function that returns how many rows a color matrix consists of.
Parameters:
color_matrix: The color matrix.
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
Returns: The number of rows a color matrix consists of.
pixel_color(color_matrix, x, y, rows) Get the color of the pixel at the specified coordinates.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
Returns: The color of the pixel at the specified coordinates.
draw_pixel(color_matrix, x, y, pixel_color, rows) Draw a pixel at the specified X and Y coordinates. Uses the specified color.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
pixel_color: The color of the pixel.
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
draw_pixel(color_matrix, x, y, rows) Draw a pixel at the specified X and Y coordinates. Uses the current foreground color.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
erase_pixel(color_matrix, x, y, rows) Erase a pixel at the specified X and Y coordinates, replacing it with the background color.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
init_color_matrix(rows, bg_color, fg_color) Create and initialize a color matrix with the specified number of rows. The number of columns will be equal to the number of rows.
Parameters:
rows: The number of rows the color matrix should consist of. This can be omitted, but if used, can speed up execution. It can never be greater than "max_canvas_size()".
bg_color: (Optional) The initial background color. The default is black.
fg_color: (Optional) The initial foreground color. The default is white.
Returns: The array representing the color matrix.
init_canvas(color_matrix, pixel_width, pixel_height, position) Create and initialize a canvas table.
Parameters:
color_matrix: The color matrix.
pixel_width: (Optional) The pixel width (in % of the pane width). The default width is 0.35%.
pixel_height: (Optional) The pixel width (in % of the pane height). The default width is 0.60%.
position: (Optional) The position for the table representing the canvas. The default is "position.middle_center".
Returns: The canvas table.
clear(color_matrix, rows) Clear a color matrix, replacing all pixels with the current background color.
Parameters:
color_matrix: The color matrix.
rows: The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
update(canvas, color_matrix, rows) This updates the canvas with the colors from the color matrix. No changes to the canvas gets plotted until this function is called.
Parameters:
canvas: The canvas table.
color_matrix: The color matrix.
rows: The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
A library implementing a kind of "canvas" using a table where each pixel is represented by a table cell and the pixel color by the background color of each cell.
To use the library, you need to create a color matrix (represented as an array) and a canvas table.
The canvas table is the container of the canvas, and the color matrix determines what color each pixel in the canvas should have.
max_canvas_size() Function that returns the maximum size of the canvas (100). The canvas is always square, so the size is equal to rows (as opposed to not rows multiplied by columns).
Returns: The maximum size of the canvas (100).
get_bg_color(color_matrix) Get the current background color of the color matrix. This is the default color used when erasing pixels or clearing a canvas.
Parameters:
color_matrix: The color matrix.
Returns: The current background color.
get_fg_color(color_matrix) Get the current foreground color of the color matrix. This is the default color used when drawing pixels.
Parameters:
color_matrix: The color matrix.
Returns: The current foreground color.
set_bg_color(color_matrix, bg_color) Set the background color of the color matrix. This is the default color used when erasing pixels or clearing a canvas.
Parameters:
color_matrix: The color matrix.
bg_color: The new background color.
set_fg_color(color_matrix, fg_color) Set the foreground color of the color matrix. This is the default color used when drawing pixels.
Parameters:
color_matrix: The color matrix.
fg_color: The new foreground color.
color_matrix_rows(color_matrix, rows) Function that returns how many rows a color matrix consists of.
Parameters:
color_matrix: The color matrix.
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
Returns: The number of rows a color matrix consists of.
pixel_color(color_matrix, x, y, rows) Get the color of the pixel at the specified coordinates.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
Returns: The color of the pixel at the specified coordinates.
draw_pixel(color_matrix, x, y, pixel_color, rows) Draw a pixel at the specified X and Y coordinates. Uses the specified color.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
pixel_color: The color of the pixel.
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
draw_pixel(color_matrix, x, y, rows) Draw a pixel at the specified X and Y coordinates. Uses the current foreground color.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
erase_pixel(color_matrix, x, y, rows) Erase a pixel at the specified X and Y coordinates, replacing it with the background color.
Parameters:
color_matrix: The color matrix.
x: The X coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
y: The Y coordinate for the pixel. Must be between 0 and "color_matrix_rows() - 1".
rows: (Optional) The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
init_color_matrix(rows, bg_color, fg_color) Create and initialize a color matrix with the specified number of rows. The number of columns will be equal to the number of rows.
Parameters:
rows: The number of rows the color matrix should consist of. This can be omitted, but if used, can speed up execution. It can never be greater than "max_canvas_size()".
bg_color: (Optional) The initial background color. The default is black.
fg_color: (Optional) The initial foreground color. The default is white.
Returns: The array representing the color matrix.
init_canvas(color_matrix, pixel_width, pixel_height, position) Create and initialize a canvas table.
Parameters:
color_matrix: The color matrix.
pixel_width: (Optional) The pixel width (in % of the pane width). The default width is 0.35%.
pixel_height: (Optional) The pixel width (in % of the pane height). The default width is 0.60%.
position: (Optional) The position for the table representing the canvas. The default is "position.middle_center".
Returns: The canvas table.
clear(color_matrix, rows) Clear a color matrix, replacing all pixels with the current background color.
Parameters:
color_matrix: The color matrix.
rows: The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
update(canvas, color_matrix, rows) This updates the canvas with the colors from the color matrix. No changes to the canvas gets plotted until this function is called.
Parameters:
canvas: The canvas table.
color_matrix: The color matrix.
rows: The number of rows of the color matrix. This can be omitted, but if used, can speed up execution.
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.