1from lazpaint import command, colors 2 3HAND = 'Hand' 4HOT_SPOT = 'HotSpot' 5MOVE_LAYER = 'MoveLayer' 6ROTATE_LAYER = 'RotateLayer' 7ZOOM_LAYER = 'ZoomLayer' 8PEN = 'Pen' 9BRUSH = 'Brush' 10CLONE = 'Clone' 11COLOR_PICKER = 'ColorPicker' 12ERASER = 'Eraser' 13EDIT_SHAPE = 'EditShape' 14RECTANGLE = 'Rect' 15ELLIPSE = 'Ellipse' 16POLYGON = 'Polygon' 17SPLINE = 'Spline' 18FLOOD_FILL = 'FloodFill' 19GRADIENT = 'Gradient' 20PHONG_SHAPE = 'Phong' 21SELECT_PEN = 'SelectPen' 22SELECT_RECT = 'SelectRect' 23SELECT_ELLIPSE = 'SelectEllipse' 24SELECT_POLY = 'SelectPoly' 25SELECT_SPLINE = 'SelectSpline' 26MOVE_SELECTION = 'MoveSelection' 27ROTATE_SELECTION = 'RotateSelection' 28MAGIC_WAND = 'MagicWand' 29DEFORMATION_GRID = 'Deformation' 30TEXTURE_MAPPING = 'TextureMapping' 31LAYER_MAPPING = 'LayerMapping' 32TEXT = 'Text' 33 34#click state 35STATE_LEFT = 'Left' 36STATE_RIGHT = 'Right' 37STATE_SHIFT = 'Shift' 38STATE_ALT = 'Alt' 39STATE_CTRL = 'Ctrl' 40 41ERASER_MODE_ALPHA = 'EraseAlpha' 42ERASER_MODE_SHARPEN = 'Sharpen' 43ERASER_MODE_SOFTEN = 'Soften' 44ERASER_MODE_LIGHTEN = 'Lighten' 45ERASER_MODE_DARKEN = 'Darken' 46 47PEN_STYLE_SOLD = 'Solid' 48PEN_STYLE_DASH = 'Dash' 49PEN_STYLE_DOT = 'Dot' 50PEN_STYLE_DASH_DOT = 'DashDot' 51PEN_STYLE_DASH_DOT_DOT = 'DashDotDot' 52 53JOIN_STYLE_BEVEL = 'Bevel' 54JOIN_STYLE_MITER = 'Miter' 55JOIN_STYLE_ROUND = 'Round' 56 57LINE_CAP_ROUND = 'Round' 58LINE_CAP_SQUARE = 'Square' 59LINE_CAP_FLAT = 'Flat' 60 61FONT_STYLE_BOLD = 'Bold' 62FONT_STYLE_ITALIC = 'Italic' 63FONT_STYLE_UNDERLINE = 'Underline' 64FONT_STYLE_STRIKE_OUT = 'StrikeOut' 65 66ALIGN_LEFT = 'Left' 67ALIGN_CENTER = 'Center' 68ALIGN_RIGHT = 'Right' 69 70SHAPE_OPTION_DRAW_SHAPE = 'DrawShape' 71SHAPE_OPTION_FILL_SHAPE = 'FillShape' 72SHAPE_OPTION_CLOSE_SHAPE = 'CloseShape' 73 74ARROW_NONE = 'None' 75ARROW_TAIL = 'Tail' 76ARROW_TIP = 'Tip' 77ARROW_NORMAL = 'Normal' 78ARROW_CUT = 'Cut' 79ARROW_FLIPPED = 'Flipped' 80ARROW_FLIPPED_CUT = 'FlippedCut' 81ARROW_TRIANGLE = 'Triangle' 82ARROW_TRIANGLE_BACK1 = 'TriangleBack1' 83ARROW_TRIANGLE_BACK2 = 'TriangleBack2' 84ARROW_HOLLOW_TRIANGLE = 'HollowTriangle' 85ARROW_HOLLOW_TRIANGLE_BACK1 = 'HollowTriangleBack1' 86ARROW_HOLLOW_TRIANGLE_BACK2 = 'HollowTriangleBack2' 87 88SPLINE_STYLE_INSIDE = 'Inside' 89SPLINE_STYLE_INSIDE_WITH_ENDS = 'InsideWithEnds' 90SPLINE_STYLE_CROSSING = 'Crossing' 91SPLINE_STYLE_CROSSING_WITH_ENDS = 'CrossingWithEnds' 92SPLINE_STYLE_OUTSIDE = 'Outside' 93SPLINE_STYLE_ROUND_OUTSIDE = 'RoundOutside' 94SPLINE_STYLE_VERTEX_TO_SIDE = 'VertexToSide' 95SPLINE_STYLE_EASY_BEZIER = 'EasyBezier' 96 97GRADIENT_TYPE_LINEAR = 'Linear' 98GRADIENT_TYPE_REFLECTED = 'Reflected' 99GRADIENT_TYPE_DIAMOND = 'Diamond' 100GRADIENT_TYPE_RADIAL = 'Radial' 101GRADIENT_TYPE_ANGULAR = 'Angular' 102 103GRADIENT_INTERPOLATION_STD_RGB = 'StdRGB' 104GRADIENT_INTERPOLATION_LINEAR_RGB = 'LinearRGB' 105GRADIENT_INTERPOLATION_LINEAR_HSL_POSITIVE = 'LinearHSLPositive' 106GRADIENT_INTERPOLATION_LINEAR_HSL_NEGATIVE = 'LinearHSLNegative' 107GRADIENT_INTERPOLATION_CORR_HSL_POSITIVE = 'GSBPositive' 108GRADIENT_INTERPOLATION_CORR_HSL_NEGATIVE = 'GSBNegative' 109 110GRADIENT_REPETITION_PAD = 'Pad' 111GRADIENT_REPETITION_REPEAT = 'Repeat' 112GRADIENT_REPETITION_REFLECT = 'Reflect' 113GRADIENT_REPETITION_SINE = 'Sine' 114 115TEXTURE_REPETITION_NONE = 'None'; 116TEXTURE_REPETITION_X = 'RepeatX'; 117TEXTURE_REPETITION_Y = 'RepeatY'; 118TEXTURE_REPETITION_BOTH = 'RepeatBoth'; 119 120SHAPE_KIND_RECTANGLE = 'Rectangle' 121SHAPE_KIND_ROUND_RECTANGLE = 'RoundRectangle' 122SHAPE_KIND_HALF_SPHERE = 'HalfSphere' 123SHAPE_KIND_CONE_TOP = 'ConeTop' 124SHAPE_KIND_CONE_SIDE = 'ConeSide' 125SHAPE_KIND_HORIZ_CYLINDER = 'HorizCylinder' 126SHAPE_KIND_VERT_CYLINDER = 'VertCylinder' 127 128DEFORMATION_MODE_DEFORM = 'Deform' 129DEFORMATION_MODE_MOVE_POINT_WITHOUT_DEFORMATION = 'MovePointWithoutDeformation' 130 131FLOOD_FILL_PROGRESSIVE = 'Progressive' 132FLOOD_FILL_FILL_ALL = 'FillAll' #not implemented 133 134PERSPECTIVE_REPEAT = 'Repeat' 135PERSPECTIVE_TWO_PLANES = 'TwoPlanes' 136 137KEY_UNKNOWN = 'Unknown' 138KEY_BACKSPACE = 'Backspace' 139KEY_TAB = 'Tab' 140KEY_RETURN = 'Return' 141KEY_ESCAPE = 'Escape' 142KEY_PAGE_UP = 'PageUp' 143KEY_PAGE_DOWN = 'PageDown' 144KEY_HOME = 'Home' 145KEY_END = 'End' 146KEY_LEFT = 'Left' 147KEY_UP = 'Up' 148KEY_RIGHT = 'Right' 149KEY_DOWN = 'Down' 150KEY_INSERT = 'Insert' 151KEY_DELETE = 'Delete' 152KEY_NUM0 = 'Num0' 153KEY_NUM1 = 'Num1' 154KEY_NUM2 = 'Num2' 155KEY_NUM3 = 'Num3' 156KEY_NUM4 = 'Num4' 157KEY_NUM5 = 'Num5' 158KEY_NUM6 = 'Num6' 159KEY_NUM7 = 'Num7' 160KEY_NUM8 = 'Num8' 161KEY_NUM9 = 'Num9' 162KEY_F1 = 'F1' 163KEY_F2 = 'F2' 164KEY_F3 = 'F3' 165KEY_F4 = 'F4' 166KEY_F5 = 'F5' 167KEY_F6 = 'F6' 168KEY_F7 = 'F7' 169KEY_F8 = 'F8' 170KEY_F9 = 'F9' 171KEY_F10 = 'F10' 172KEY_F11 = 'F11' 173KEY_F12 = 'F12' 174KEY_A = 'A' 175KEY_B = 'B' 176KEY_C = 'C' 177KEY_D = 'D' 178KEY_E = 'E' 179KEY_F = 'F' 180KEY_G = 'G' 181KEY_H = 'H' 182KEY_I = 'I' 183KEY_J = 'J' 184KEY_K = 'K' 185KEY_L = 'L' 186KEY_M = 'M' 187KEY_M = 'N' 188KEY_O = 'O' 189KEY_P = 'P' 190KEY_Q = 'Q' 191KEY_R = 'R' 192KEY_S = 'S' 193KEY_T = 'T' 194KEY_U = 'U' 195KEY_V = 'V' 196KEY_W = 'W' 197KEY_X = 'X' 198KEY_Y = 'Y' 199KEY_W = 'Z' 200KEY_0 = '0' 201KEY_1 = '1' 202KEY_2 = '2' 203KEY_3 = '3' 204KEY_4 = '4' 205KEY_5 = '5' 206KEY_6 = '6' 207KEY_7 = '7' 208KEY_8 = '8' 209KEY_9 = '9' 210KEY_SHIFT = 'Shift' 211KEY_CTRL = 'Ctrl' 212KEY_ALT = 'Alt' 213 214def choose(name): 215 command.send("ChooseTool", Name=name) 216 217def mouse(coords, state=[STATE_LEFT], default_pressure=1.0): 218 if not isinstance(coords, list): 219 xy = [(float(coords[0]), float(coords[1]))] 220 if len(coords)>2: 221 pressure = [float(coords[2])] 222 else: 223 pressure = [default_pressure] 224 else: 225 xy = [(float(c[0]), float(c[1])) for c in coords] 226 pressure = [float(c[2]) if len(c)>2 else default_pressure for c in coords] 227 command.send("ToolMouse", Coords=xy, State=state, Pressure=pressure) 228 229def keys(keys, state=[]): 230 if isinstance(keys, str): 231 keys = [keys] 232 command.send("ToolKeys", Keys=keys, State=state) 233 234def write(text): 235 command.send("ToolWrite", Text=text) 236 237def set_fore_color(color): 238 command.send("ToolSetForeColor", Color=color) 239 240def set_back_color(color): 241 command.send("ToolSetBackColor", Color=color) 242 243def set_outline_color(color): 244 command.send("ToolSetOutlineColor", Color=color) 245 246def get_fore_color(): 247 return colors.str_to_RGBA(command.send("ToolGetForeColor?")) 248 249def get_back_color(): 250 return colors.str_to_RGBA(command.send("ToolGetBackColor?")) 251 252def get_outline_color(): 253 return colors.str_to_RGBA(command.send("ToolGetOutlineColor?")) 254 255def set_eraser_mode(mode): 256 command.send('ToolSetEraserMode', Mode=mode) 257 258def get_eraser_mode(): 259 return command.send('ToolGetEraserMode?') 260 261def set_eraser_alpha(alpha: int): #0..255 262 command.send('ToolSetEraserAlpha', Alpha=alpha) 263 264def get_eraser_alpha() -> int: 265 return command.send('ToolGetEraserAlpha?') 266 267def set_pen_width(width: float): 268 command.send('ToolSetPenWidth', Width=width) 269 270def get_pen_width(): 271 return command.send('ToolGetPenWidth?') 272 273def set_pen_style(style): 274 command.send('ToolSetPenStyle', Style=style) 275 276def get_pen_style(): 277 return command.send('ToolGetPenStyle?') 278 279def set_join_style(style): 280 command.send('ToolSetJoinStyle', Style=style) 281 282def get_join_style(): 283 return command.send('ToolGetJoinStyle?') 284 285def set_line_cap(cap): 286 command.send('ToolSetLineCap', Cap=cap) 287 288def get_line_cap(): 289 return command.send('ToolGetLineCap?') 290 291def set_shape_options(options: list): 292 command.send('ToolSetShapeOptions', Options=options) 293 294def get_shape_options() -> list: 295 return command.send('ToolGetShapeOptions?') 296 297def set_aliasing(enabled: bool): 298 command.send('ToolSetAliasing', Enabled=enabled) 299 300def get_aliasing() -> bool: 301 return command.send('ToolGetAliasing?') 302 303def set_shape_ratio(ratio: float): 304 command.send('ToolSetShapeRatio', Ratio=ratio) 305 306def get_shape_ratio() -> float: 307 return command.send('ToolGetShapeRatio?') 308 309def set_brush_index(index: int): 310 command.send('ToolSetBrushIndex', Index=index) 311 312def get_brush_index() -> int: 313 return command.send('ToolGetBrushIndex?') 314 315def get_brush_count() -> int: 316 return command.send('ToolGetBrushCount?') 317 318def set_brush_spacing(spacing: int): 319 command.send('ToolSetBrushSpacing', Spacing=spacing) 320 321def get_brush_spacing() -> int: 322 return command.send('ToolGetBrushSpacing?') 323 324def set_font_name(name: str): 325 command.send('ToolSetFontName', Name=name) 326 327def get_font_name() -> str: 328 return command.send('ToolGetFontName?') 329 330def set_font_size(size: float): 331 command.send('ToolSetFontSize', Size=size) 332 333def get_font_size() -> float: 334 return command.send('ToolGetFontSize?') 335 336def set_font_style(style: list): 337 command.send('ToolSetFontStyle', Style=style) 338 339def get_font_style() -> list: 340 return command.send('ToolGetFontStyle?') 341 342def set_text_align(align): 343 command.send('ToolSetTextAlign', Align=align) 344 345def get_text_align(): 346 return command.send('ToolGetTextAlign?') 347 348def set_text_outline(width: float): 349 command.send('ToolSetTextOutline', Width=width) 350 351def get_text_outline() -> float: 352 return command.send('ToolGetTextOutline?') 353 354def set_text_phong(enabled: bool): 355 command.send('ToolSetTextPhong', Enabled=enabled) 356 357def get_text_phong() -> bool: 358 return command.send('ToolGetTextPhong?') 359 360def set_light_position(x: float, y: float): 361 command.send('ToolSetLightPosition', Position=(x, y)) 362 363def get_light_position() -> tuple: 364 return command.send('ToolGetLightPosition?') 365 366def set_arrow_start(arrow): 367 command.send('ToolSetArrowStart', Arrow=arrow) 368 369def get_arrow_start(): 370 return command.send('ToolGetArrowStart?') 371 372def set_arrow_end(arrow): 373 command.send('ToolSetArrowEnd', Arrow=arrow) 374 375def get_arrow_end(): 376 return command.send('ToolGetArrowEnd?') 377 378def set_arrow_size(x, y): 379 command.send('ToolSetArrowSize', Size=(x, y)) 380 381def get_arrow_size() -> tuple: 382 return command.send('ToolGetArrowSize?') 383 384def set_spline_style(style): 385 command.send('ToolSetSplineStyle', Style=style) 386 387def get_spline_style(): 388 return command.send('ToolGetSplineStyle?') 389 390def set_fore_gradient_type(gradient_type): 391 command.send('ToolSetForeGradientType', GradientType=gradient_type) 392 393def get_fore_gradient_type(): 394 return command.send('ToolGetForeGradientType?') 395 396def set_fore_gradient_colors(colors: list): 397 command.send('ToolSetForeGradientColors', Colors=colors) 398 399def get_fore_gradient_colors() -> list: 400 return colors.str_to_RGBA(command.send('ToolGetForeGradientColors?')) 401 402def set_fore_gradient_interpolation(interpolation): 403 command.send('ToolSetForeGradientInterpolation', Interpolation=interpolation) 404 405def get_fore_gradient_interpolation(): 406 return command.send('ToolGetForeGradientInterpolation?') 407 408def set_fore_gradient_repetition(repetition): 409 command.send('ToolSetForeGradientRepetition', Repetition=repetition) 410 411def get_fore_gradient_repetition(): 412 return command.send('ToolGetForeGradientRepetition?') 413 414def set_back_gradient_type(gradient_type): 415 command.send('ToolSetBackGradientType', GradientType=gradient_type) 416 417def get_back_gradient_type(): 418 return command.send('ToolGetGradientType?') 419 420def set_back_gradient_interpolation(interpolation): 421 command.send('ToolSetBackGradientInterpolation', Interpolation=interpolation) 422 423def get_back_gradient_interpolation(): 424 return command.send('ToolGetBackGradientInterpolation?') 425 426def set_back_gradient_colors(colors: list): 427 command.send('ToolSetBackGradientColors', Colors=colors) 428 429def get_back_gradient_colors() -> list: 430 return colors.str_to_RGBA(command.send('ToolGetBackGradientColors?')) 431 432def set_back_gradient_repetition(repetition): 433 command.send('ToolSetBackGradientRepetition', Repetition=repetition) 434 435def get_back_gradient_repetition(): 436 return command.send('ToolGetBackGradientRepetition?') 437 438def set_outline_gradient_type(gradient_type): 439 command.send('ToolSetOutlineGradientType', GradientType=gradient_type) 440 441def get_outline_gradient_type(): 442 return command.send('ToolGetOutlineGradientType?') 443 444def set_outline_gradient_colors(colors: list): 445 command.send('ToolSetOutlineGradientColors', Colors=colors) 446 447def get_outline_gradient_colors() -> list: 448 return colors.str_to_RGBA(command.send('ToolGetOutlineGradientColors?')) 449 450def set_outline_gradient_interpolation(interpolation): 451 command.send('ToolSetOutlineGradientInterpolation', Interpolation=interpolation) 452 453def get_outline_gradient_interpolation(): 454 return command.send('ToolGetOutlineGradientInterpolation?') 455 456def set_outline_gradient_repetition(repetition): 457 command.send('ToolSetOutlineGradientRepetition', Repetition=repetition) 458 459def get_outline_gradient_repetition(): 460 return command.send('ToolGetOutlineGradientRepetition?') 461 462def set_fore_texture(file_name): 463 command.send('ToolSetForeTexture', FileName=file_name) 464 465def set_fore_texture_repetition(repetition): 466 command.send('ToolSetForeTextureRepetition', Repetition=repetition) 467 468def get_fore_texture_repetition(): 469 return command.send('ToolGetForeTextureRepetition?') 470 471def set_fore_texture_opacity(opacity: int): 472 command.send('ToolSetForeTextureOpacity', Opacity=opacity) 473 474def get_fore_texture_opacity(): #-> int 0..255 475 return command.send('ToolGetForeTextureOpacity?') 476 477def set_back_texture(file_name): 478 command.send('ToolSetBackTexture', FileName=file_name) 479 480def set_back_texture_repetition(repetition): 481 command.send('ToolSetBackTextureRepetition', Repetition=repetition) 482 483def get_back_texture_repetition(): 484 return command.send('ToolGetBackTextureRepetition?') 485 486def set_back_texture_opacity(opacity: int): 487 command.send('ToolSetBackTextureOpacity', Opacity=opacity) 488 489def get_back_texture_opacity(): #-> int 0..255 490 return command.send('ToolGetBackTextureOpacity?') 491 492def set_outline_texture(file_name): 493 command.send('ToolSetOutlineTexture', FileName=file_name) 494 495def set_outline_texture_repetition(repetition): 496 command.send('ToolSetOutlineTextureRepetition', Repetition=repetition) 497 498def get_outline_texture_repetition(): 499 return command.send('ToolGetOutlineTextureRepetition?') 500 501def set_outline_texture_opacity(opacity: int): 502 command.send('ToolSetOutlineTextureOpacity', Opacity=opacity) 503 504def get_outline_texture_opacity(): #-> int 0..255 505 return command.send('ToolGetOutlineTextureOpacity?') 506 507def set_phong_shape_kind(kind): 508 command.send('ToolSetPhongShapeKind', Kind=kind) 509 510def get_phong_shape_kind(): 511 return command.send('ToolGetPhongShapeKind?') 512 513def set_grid_deformation_mode(mode): 514 command.send('ToolSetDeformationGridMode', Mode=mode) 515 516def get_grid_deformation_mode(): 517 return command.send('ToolGetDeformationGridMode?') 518 519def set_flood_fill_options(options: list): 520 command.send('ToolSetFloodFillOptions', Options=options) 521 522def get_flood_fill_options() -> list: 523 return command.send('ToolGetFloodFillOptions?') 524 525def set_perspective_options(options: list): 526 command.send('ToolSetPerspectiveOptions', Options=options) 527 528def get_perspective_options() -> list: 529 return command.send('ToolGetPerspectiveOptions?') 530 531