mirror of
https://github.com/Relintai/pandemonium_engine_easy_charts.git
synced 2024-12-19 13:37:03 +01:00
56 lines
1.3 KiB
GDScript3
56 lines
1.3 KiB
GDScript3
|
tool
|
||
|
extends Reference
|
||
|
class_name Matrix
|
||
|
|
||
|
var _matrix : Array = []
|
||
|
|
||
|
func _init(matrix : Array = []) -> void:
|
||
|
_matrix = matrix
|
||
|
|
||
|
func _to_string() -> String:
|
||
|
var last_string_len : int
|
||
|
for row in _matrix:
|
||
|
for column in row:
|
||
|
var string_len : int = str(column).length()
|
||
|
last_string_len = string_len if string_len > last_string_len else last_string_len
|
||
|
var string : String = "\n"
|
||
|
for row_i in _matrix.size():
|
||
|
for column_i in _matrix[row_i].size():
|
||
|
string+="%*s" % [last_string_len+1 if column_i!=0 else last_string_len, _matrix[row_i][column_i]]
|
||
|
string+="\n"
|
||
|
return string
|
||
|
|
||
|
func insert_row(row : Array, index : int = _matrix.size()) -> void:
|
||
|
_matrix.insert(index, row)
|
||
|
|
||
|
func to_array() -> Array:
|
||
|
return _matrix.duplicate()
|
||
|
|
||
|
func get_size() -> Vector2:
|
||
|
return Vector2(_matrix.size(), _matrix[0].size())
|
||
|
|
||
|
func get_column(column : int) -> Array:
|
||
|
if column >= get_size()[1]: printerr("error")
|
||
|
var column_array : Array = []
|
||
|
for row in _matrix: column_array.append(row[column])
|
||
|
return column_array
|
||
|
|
||
|
func get_row(row : int) -> Array:
|
||
|
if row >= get_size()[0]: printerr("error")
|
||
|
return _matrix[row]
|
||
|
#
|
||
|
#func multiply_int(_int : int) -> void:
|
||
|
# _matrix = MatrixGenerator.multiply_int(self, _int).to_array()
|
||
|
#
|
||
|
#func multiply_float(_float : int) -> void:
|
||
|
# _matrix = MatrixGenerator.multiply_float(self, _float).to_array()
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|