123456789_123456789_123456789_123456789_123456789_

Class: Layout::Rectangle

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Entity
Instance Chain:
self, Entity
Inherits: Layout::Entity

Overview

A simple rectangular shape entity.

Version:

  • LayOut 2018

Constant Summary

Class Method Summary

Instance Attribute Summary

Entity - Inherited

#locked=

The #locked= method sets the Entity as locked or unlocked.

#locked?

The #locked? method returns whether the Entity is locked or unlocked.

#on_shared_layer?

The #on_shared_layer? method returns whether or not the Entity is on a shared Layer.

#style

The #style method returns the Style of the Entity.

#style=

The #style= method sets the Style of the Entity.

#untransformed_bounds

The #untransformed_bounds method returns the untransformed bounds of the Entity.

#untransformed_bounds=

The #untransformed_bounds= method sets the untransformed bounds of the Entity.

Instance Method Summary

Entity - Inherited

#==

The #== method checks to see if the two Entitys are equal.

#bounds

The #bounds method returns the 2D rectangular bounds of the Entity.

#document

The #document method returns the Document that the Entity belongs to, or nil if it is not in a Document.

#drawing_bounds

The #drawing_bounds method returns the 2D rectangular drawing bounds of the Entity.

#group

The #group method returns the Group the Entity belongs to, or nil if it is not in a Group.

#layer_instance

The #layer_instance method returns the LayerInstance that the Entity is on, or nil if it is not associated with a LayerInstance.

#move_to_group

The #move_to_group method moves the Entity into a Group.

#move_to_layer

The #move_to_layer method moves the Entity to the given Layer.

#page

The #page method returns the Page that the Entity belongs to, or nil if it is on a shared Layer or not in a Document.

#transform!

The #transform! method transforms the Entity with a given ::Geom::Transformation2d.

#transformation

The #transformation method returns the explicit ::Geom::Transformation2d.

Constructor Details

.new(bounds) ⇒ Rectangle .new(bounds, type) ⇒ Rectangle .new(bounds, type, radius) ⇒ Rectangle

The #initialize method creates a new normal, lozenge, bulged or rounded Rectangle, depending on the type passed in.

The rectangle type can be one of the following values:

Layout::Rectangle::TYPE_NORMAL
Layout::Rectangle::TYPE_ROUNDED
Layout::Rectangle::TYPE_LOZENGE
Layout::Rectangle::TYPE_BULGED

Examples:

upper_left = Geom::Point2d.new(1, 1)
lower_right = Geom::Point2d.new(2, 2)
bounds = Geom::Bounds2d.new(upper_left, lower_right)
# Creates a normal rectangle
rect = Layout::Rectangle.new(bounds)
rounded_rect = Layout::Rectangle.new_rounded(
    Layout::Rectangle::TYPE_ROUNDED, bounds, radius)
lozenge_rect = Layout::Rectangle.new_lozenge(
    Layout::Rectangle::TYPE_LOZENGE, bounds)
bulged_rect = Layout::Rectangle.new_bulged(Layout::Rectangle::TYPE_BULGED,
    bounds, bulge_distance)

Overloads:

  • .new(bounds) ⇒ Rectangle

    Parameters:

  • .new(bounds, type) ⇒ Rectangle

    Parameters:

    • bounds (Geom::Bounds2d)
    • type (Integer)

      The type of Rectangle to create. Must be Layout::Rectangle::TYPE_NORMAL or Layout::Rectangle::TYPE_LOZENGE

  • .new(bounds, type, radius) ⇒ Rectangle

    Parameters:

    • bounds (Geom::Bounds2d)
    • type (Integer)

      The type of Rectangle to create. Must be Layout::Rectangle::TYPE_BULGED or Layout::Rectangle::TYPE_ROUNDED

    • radius (Float)

Raises:

  • (ArgumentError)

    if type passed in does not match the number of arguments

  • (ArgumentError)

    if bounds is zero size

  • (ArgumentError)

    if type is not a valid type

  • (ArgumentError)

    if radius is a negative value

Version:

  • LayOut 2018

Instance Attribute Details

#radiusFloat? (rw)

The #radius method returns the radius of the Rectangle, or nil if the Rectangle is not of type Layout::Rectangle::TYPE_BULGED or Layout::Rectangle::TYPE_ROUNDED

Examples:

upper_left = Geom::Point2d.new(1, 1)
lower_right = Geom::Point2d.new(2, 2)
bounds = Geom::Bounds2d.new(upper_left, lower_right)
radius = 0.8
rect = Layout::Rectangle.new_rounded(bounds, radius)
# Should equal 0.8
r = rect.radius

Version:

  • LayOut 2018

#radius=(radius) (rw)

The #radius= method sets the radius of the Rectangle.

Examples:

upper_left = Geom::Point2d.new(1, 1)
lower_right = Geom::Point2d.new(2, 2)
bounds = Geom::Bounds2d.new(upper_left, lower_right)
radius = 0.8
rect = Layout::Rectangle.new_rounded(bounds, radius)
rect.radius = 0.5

Parameters:

  • radius (Float)

    The new radius value to set

Raises:

  • (ArgumentError)

    if the Rectangle is not of type Layout::Rectangle::TYPE_BULGED or Layout::Rectangle::TYPE_ROUNDED

  • (ArgumentError)

    if radius is negative

  • (LockedLayerError)

    if the Rectangle is on a locked Layer

  • (LockedEntityError)

    if the Rectangle is locked

Version:

  • LayOut 2018

#typeInteger (rw)

The #type method returns the type of the Rectangle.

The type of a rectangle can be one of the following:

Layout::Rectangle::TYPE_NORMAL
Layout::Rectangle::TYPE_ROUNDED
Layout::Rectangle::TYPE_LOZENGE
Layout::Rectangle::TYPE_BULGED

Examples:

upper_left = Geom::Point2d.new(1, 1)
lower_right = Geom::Point2d.new(2, 2)
bounds = Geom::Bounds2d.new(upper_left, lower_right)
rect = Layout::Rectangle.new(bounds)
rect_type =rect.type

Returns:

  • (Integer)

    integer that corresponds with a rectangle type

Version:

  • LayOut 2018

#type=(type) (rw)

The #type= method sets the type of the Rectangle. If the type is set to Layout::Rectangle::TYPE_ROUNDED or Layout::Rectangle::TYPE_BULGED, the [Layout::Rectangle]‘s radius will be set to the default value of 0.25, if the value had not previously been set.

The type of a Rectangle can be one of the following:

Layout::Rectangle::TYPE_NORMAL
Layout::Rectangle::TYPE_ROUNDED
Layout::Rectangle::TYPE_LOZENGE
Layout::Rectangle::TYPE_BULGED

Examples:

upper_left = Geom::Point2d.new(1, 1)
lower_right = Geom::Point2d.new(2, 2)
bounds = Geom::Bounds2d.new(upper_left, lower_right)
rect = Layout::Rectangle.new(bounds)
rect.type = Layout::Rectangle::TYPE_LOZENGE

Parameters:

  • type (Integer)

    An integer that corresponds with a rectangle type

Raises:

Version:

  • LayOut 2018