Skip to content

Commit d4aa3ee

Browse files
fixes #124
1 parent 9e42515 commit d4aa3ee

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

ti_python_module/ti_draw.py

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ def set_colour(red:int, green:int, blue:int):
379379
380380
Args:
381381
red (int): The amount of red. Ranges from 0 to 255.
382-
green (int): [description]
383-
blue (int): [description]
382+
green (int): The amount of green. Ranges from 0 to 255.
383+
blue (int): The amount of blue. Ranges from 0 to 255.
384384
385385
Returns:
386386
list: a list containing the following data: [red, green, blue]
@@ -409,47 +409,70 @@ def set_colour(red:int, green:int, blue:int):
409409

410410
###########################################################################################
411411

412-
def set_pen(thickness:str, stil:str):
412+
def set_pen(thickness:str, stile:str):
413413
"""
414414
Sets the specified thickness and style of the border when drawing shapes (not applicable when using fill commands).
415415
416-
417-
Category: TI Draw / Control
418-
419-
420-
Returns an array / list: [thickness, stil]
416+
Args:
417+
thickness (str): The thickness of the pen. Possible Options: 'thin', 'medium', 'thick'.
418+
stile (str): The stile of the pen. Possible Options: 'solid', 'dotted', 'dashed'.
419+
420+
Returns:
421+
list: a list containing the following data: [thickness, stile]
421422
"""
423+
if cerr.type_error(str, thickness) == False: log("Argument 'thickness' has to be type string!", "ERROR", "TI Draw", "Set Pen")
424+
if cerr.type_error(str, stile) == False: log("Argument 'stile' has to be type string!", "ERROR", "TI Draw", "Set Pen")
425+
426+
if cerr.argument_error(thickness, "thin", "medium", "thick") == False: log("Argument 'thickness' can only be one of these: 'thin', 'medium', 'thick'!", "ERROR", "TI Draw", "Set Pen")
427+
if cerr.argument_error(stile, "solid", "dotted", "dashed") == False: log("Argument 'stile' can only be one of these: 'solid', 'dotted', 'dashed'!", "ERROR", "TI Draw", "Set Pen")
428+
422429
err.type_error(str, "str", thickness)
423-
err.type_error(str, "str", stil)
430+
err.type_error(str, "str", stile)
424431

425432
err.argument_error(thickness, "thin", "medium", "thick")
426-
err.argument_error(stil, "solid", "dotted", "dashed")
433+
err.argument_error(stile, "solid", "dotted", "dashed")
427434

428-
print("Setting Drawing Pen thickness to '" + thickness + "' and pen stil to '" + stil + "'")
429-
return [thickness, stil]
435+
log("Setting Drawing Pen thickness to '" + thickness + "' and pen stile to '" + stile + "'", "INFO", "TI Draw", "Set Pen")
436+
print("Setting Drawing Pen thickness to '" + thickness + "' and pen stile to '" + stile + "'")
437+
return [thickness, stile]
430438

431439
###########################################################################################
432440

433441
def set_window(x_min:int, x_max:int, y_min:int, y_max:int):
434442
"""
435443
Sets the size of the window in which any shapes will be drawn. This function is useful to resize the window to match the data or to change the origin (0,0) of the drawing canvas.
436-
437-
438-
Category: TI Draw / Control
439-
440-
441-
Returns an array / list: [x_min, x_max, y_min, y_max]
444+
445+
Args:
446+
x_min (int): The minimum x coordinate.
447+
x_max (int): The minimum y coordinate.
448+
y_min (int): The maximum x coordinate.
449+
y_max (int): The maximum y corrdinate.
450+
451+
Raises:
452+
ValueError: If x_min is greater or equal to x_max.
453+
ValueError: If y_min is greater or equal to y_max.
454+
455+
Returns:
456+
list: a list containing the following data: [x_min, x_max, y_min, y_max]
442457
"""
458+
if cerr.type_error(int, x_min) == False: log("Argument 'x_min' has to be type integer!", "ERROR", "TI Draw", "Set Window")
459+
if cerr.type_error(int, x_max) == False: log("Argument 'x_max' has to be type integer!", "ERROR", "TI Draw", "Set Window")
460+
if cerr.type_error(int, y_min) == False: log("Argument 'y_min' has to be type integer!", "ERROR", "TI Draw", "Set Window")
461+
if cerr.type_error(int, y_max) == False: log("Argument 'y_max' has to be type integer!", "ERROR", "TI Draw", "Set Window")
462+
463+
if cerr.relation.larger_equal_error(x_min, x_max) == False: log("Argument 'x_min' has to be smaller then argument 'x_max'!", "ERROR", "TI Draw", "Set Window")
464+
if cerr.relation.larger_equal_error(y_min, y_max) == False: log("Argument 'y_min' has to be smaller then argument 'y_max'!", "ERROR", "TI Draw", "Set Window")
465+
466+
443467
err.type_error(int, "int", x_min)
444468
err.type_error(int, "int", x_max)
445469
err.type_error(int, "int", y_min)
446470
err.type_error(int, "int", y_max)
447471

448-
if(x_min >= x_max):
449-
raise ValueError("ERROR: minimum value has to be smaller then maximum value")
450-
if(x_min >= x_max):
451-
raise ValueError("ERROR: minimum value has to be smaller then maximum value")
472+
err.relation.larger_equal_error(x_min, x_max)
473+
err.relation.larger_equal_error(y_min, y_max)
452474

475+
log("Setting Drawing window from (" + str(x_min) + " | " + str(y_min) + " ) to (" + str(x_max) + " | " + str(y_max) + " )", "INFO", "TI Draw", "Set Window")
453476
print("Setting Drawing window from (" + str(x_min) + " | " + str(y_min) + " ) to (" + str(x_max) + " | " + str(y_max) + " )")
454477
return [x_min, x_max, y_min, y_max]
455478

0 commit comments

Comments
 (0)