Class: Layout::Rectangle

Inherits:
Entity
  • Object
show all
Defined in:
lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb

Overview

A simple rectangular shape entity.

Version:

  • LayOut 2018

Constant Summary collapse

TYPE_BULGED =

Constants

nil
TYPE_LOZENGE =

Stub value.

nil
TYPE_NORMAL =

Stub value.

nil
TYPE_ROUNDED =

Stub value.

nil

Instance Method Summary collapse

Methods inherited from Entity

#==, #bounds, #document, #drawing_bounds, #group, #layer_instance, #locked=, #locked?, #move_to_group, #move_to_layer, #on_shared_layer?, #page, #style, #style=, #transform!, #transformation, #untransformed_bounds, #untransformed_bounds=

Constructor Details

#initialize(bounds) ⇒ Layout::Rectangle #initialize(bounds, type) ⇒ Layout::Rectangle #initialize(bounds, type, radius) ⇒ Layout::Rectangle

The #initialize method creates a new normal, lozenge, bulged or rounded Layout::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:

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



72
73
# File 'lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb', line 72

def initialize(*args)
end

Instance Method Details

#radiusFloat?

The #radius method returns the radius of the Layout::Rectangle, or nil if the Layout::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

Returns:

  • (Float, nil)

Version:

  • LayOut 2018



91
92
# File 'lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb', line 91

def radius
end

#radius=(radius) ⇒ Object

The #radius= method sets the radius of the Layout::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:

Version:

  • LayOut 2018



118
119
# File 'lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb', line 118

def radius=(radius)
end

#typeInteger

The #type method returns the type of the Layout::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



139
140
# File 'lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb', line 139

def type
end

#type=(type) ⇒ Object

The #type= method sets the type of the Layout::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 Layout::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



171
172
# File 'lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb', line 171

def type=(type)
end