Polygon
Polygon object.
Source code in gdsr/_gdsr.pyi
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
|
__init__
__init__(points: InputPointsLike, layer: Layer = 0, data_type: DataType = 0) -> None
Initialize the Polygon.
If the first and last points are not the same, the first point is appended to the end, to ensure that the polygon is closed.
Parameters:
-
points
(InputPointsLike
) –Polygon vertices. Sequence of objects that are indexable at 0 and 1. Must not be empty
-
layer
(Layer
, default:0
) –Polygon layer, defaults to 0
-
data_type
(DataType
, default:0
) –Polygon data_type, defaults to 0
Source code in gdsr/_gdsr.pyi
set_points
set_points(points: InputPointsLike) -> Self
Set the points of the polygon.
If the first and last points are not the same, the first point is appended to the end, to ensure that the polygon is closed.
Parameters:
-
points
(InputPointsLike
) –Polygon vertices. Sequence of objects that are indexable at 0 and 1. Must not be empty
Source code in gdsr/_gdsr.pyi
set_layer
set_data_type
contains
contains(point: PointLike) -> bool
contains_all
contains_all(*points: PointLike) -> bool
contains_any
contains_any(*points: PointLike) -> bool
on_edge
on_edge(point: PointLike) -> bool
on_edge_all
on_edge_all(*points: PointLike) -> bool
on_edge_any
on_edge_any(*points: PointLike) -> bool
intersects
intersects(other: Polygon) -> bool
visualize
copy
move_to
move_to(point: PointLike) -> Self
Move the polygon to a point.
This method modifies the polygon in place and returns itself.
Parameters:
-
point
(PointLike
) –Point to move the polygon to.
move_by
move_by(vector: PointLike) -> Self
Move the polygon by a vector.
This method modifies the polygon in place and returns itself.
Parameters:
-
vector
(PointLike
) –Vector to move the polygon by.
rotate
rotate(angle: float, centre: PointLike = Point(0, 0)) -> Self
Rotate the polygon by an angle around a centre point.
This method modifies the polygon in place and returns itself.
Parameters:
-
angle
(float
) –Counter-clockwise rotation angle in degrees.
-
centre
(PointLike
, default:Point(0, 0)
) –Centre point of rotation, defaults to (0, 0).
Source code in gdsr/_gdsr.pyi
scale
scale(factor: float, centre: PointLike = Point(0, 0)) -> Self
Scale the polygon by a factor around a centre point.
This method modifies the polygon in place and returns itself.
Parameters:
-
factor
(float
) –Scaling factor.
-
centre
(PointLike
, default:Point(0, 0)
) –Centre point of scaling, defaults to (0, 0).
Source code in gdsr/_gdsr.pyi
is_on
is_on(*layer_data_types: LayerDataType) -> bool
regular
staticmethod
regular(centre: PointLike, radius: float, n_sides: int, rotation: float = 0, layer: int = 0, data_type: int = 0) -> Polygon
Return a regular polygon.
Parameters:
-
centre
(PointLike
) –Centre of the polygon.
-
radius
(float
) –Radius of the polygon.
-
n_sides
(int
) –Number of sides of the polygon.
-
rotation
(float
, default:0
) –Rotation of the polygon in degrees.
-
layer
(int
, default:0
) –Layer of the polygon, defaults to 0.
-
data_type
(int
, default:0
) –Data type of the polygon, defaults to 0.
Source code in gdsr/_gdsr.pyi
ellipse
staticmethod
ellipse(centre: PointLike, horizontal_radius: float, vertical_radius: float | None = None, initial_angle: float = 0.0, final_angle: float = 360.0, n_sides: int = 400, layer: int = 0, data_type: int = 0) -> Polygon
Return an ellipse.
Parameters:
-
centre
(PointLike
) –Centre of the ellipse.
-
radius
(float
) –Radius of the ellipse.
-
initial_angle
(float
, default:0.0
) –Initial angle in degrees, defaults to 0.
-
final_angle
(float
, default:360.0
) –Final angle in degrees, defaults to 0.
-
n_sides
(int
, default:400
) –Number of sides of the ellipse, defaults to 400.
-
layer
(int
, default:0
) –Layer of the ellipse, defaults to 0.
-
data_type
(int
, default:0
) –Data type of the ellipse, defaults to 0.