2.9 <GskRoundedRect>

Structure: <GskRoundedRect>

A rectangular region with rounded corners.

Application code should normalize rectangles using rounded-rect:normalize; this function will ensure that the bounds of the rectangle are normalized and ensure that the corner values are positive and the corners do not overlap.

All functions taking a <GskRoundedRect> as an argument will internally operate on a normalized copy; all functions returning a <GskRoundedRect> will always return a normalized one.

The algorithm used for normalizing corner sizes is described in the CSS specification.

Fields

bounds

the bounds of the rectangle

corner

the size of the 4 rounded corners

Procedures

Procedure: make-rounded-rect [bounds] [corner] ⇒ struct
Procedure: rounded-rect:bounds self ⇒ bounds
Method: rounded-rect:contains-point? self point ⇒ %return
Method: contains-point? self point ⇒ %return

Checks if the given point is inside the rounded rectangle.

self

Passed: a <GskRoundedRect>.

a rounded rectangle

point

Passed: a <GraphenePoint>.

the point to check

%return

Returned: a boolean.

true if the point is inside the rounded rectangle

Method: rounded-rect:contains-rect? self rect ⇒ %return
Method: contains-rect? self rect ⇒ %return

Checks if the given rectangle is contained inside the rounded rectangle.

self

Passed: a <GskRoundedRect>.

a rounded rectangle

rect

Passed: a <GrapheneRect>.

the rectangle to check

%return

Returned: a boolean.

true if the rect is fully contained inside the rounded rectangle

Procedure: rounded-rect:corner self ⇒ corner
Method: rounded-rect:init self bounds top-left top-right bottom-right bottom-left ⇒ %return
Method: init self bounds top-left top-right bottom-right bottom-left ⇒ %return

Initializes a rounded rectangle with the given values.

This function will implicitly normalize the rounded rectangle before returning.

self

Passed: a <GskRoundedRect>.

the rounded rectangle to initialize

bounds

Passed: a <GrapheneRect>.

a <GrapheneRect> describing the bounds

top-left

Passed: a <GrapheneSize>.

the rounding radius of the top left corner

top-right

Passed: a <GrapheneSize>.

the rounding radius of the top right corner

bottom-right

Passed: a <GrapheneSize>.

the rounding radius of the bottom right corner

bottom-left

Passed: a <GrapheneSize>.

the rounding radius of the bottom left corner

%return

Returned: a <GskRoundedRect>.

the initialized rounded rectangle

Method: rounded-rect:init-copy self src ⇒ %return
Method: init-copy self src ⇒ %return

Initializes a rounded rectangle with a copy.

This function will not normalize the rounded rectangle, so make sure the source is normalized.

self

Passed: a <GskRoundedRect>.

the rounded rectangle to initialize

src

Passed: a <GskRoundedRect>.

another rounded rectangle

%return

Returned: a <GskRoundedRect>.

the initialized rounded rectangle

Method: rounded-rect:init-from-rect self bounds radius ⇒ %return
Method: init-from-rect self bounds radius ⇒ %return

Initializes a rounded rectangle to the given bounds and sets the radius of all four corners equally.

self

Passed: a <GskRoundedRect>.

the rounded rectangle to initialize

bounds

Passed: a <GrapheneRect>.

a <GrapheneRect>

radius

Passed: a real number.

the border radius

%return

Returned: a <GskRoundedRect>.

the initialized rounded rectangle

Method: rounded-rect:intersects-rect? self rect ⇒ %return
Method: intersects-rect? self rect ⇒ %return

Checks if part a rectangle is contained inside the rounded rectangle.

self

Passed: a <GskRoundedRect>.

a rounded rectangle

rect

Passed: a <GrapheneRect>.

the rectangle to check

%return

Returned: a boolean.

true if the rect intersects with the rounded rectangle

Method: rounded-rect:is-rectilinear? self ⇒ %return
Method: is-rectilinear? self ⇒ %return

Checks if all corners of a rounded rectangle are right angles and the rectangle covers all of its bounds.

This information can be used to decide if clip-node:new or rounded-clip-node:new should be called.

self

Passed: a <GskRoundedRect>.

the rounded rectangle to check

%return

Returned: a boolean.

true if the rounded rectangle is rectilinear

Method: rounded-rect:normalize self ⇒ %return
Method: normalize self ⇒ %return

Normalizes a rounded rectangle.

This function will ensure that the bounds of the rounded rectangle are normalized and ensure that the corner values are positive and the corners do not overlap.

self

Passed: a <GskRoundedRect>.

a rounded rectangle

%return

Returned: a <GskRoundedRect>.

the normalized rounded rectangle

Method: rounded-rect:offset self dx dy ⇒ %return
Method: offset self dx dy ⇒ %return

Offsets the rounded rectangle’s origin by dx and dy.

The size and corners of the rounded rectangle are unchanged.

self

Passed: a <GskRoundedRect>.

a rounded rectangle

dx

Passed: a real number.

the horizontal offset

dy

Passed: a real number.

the vertical offset

%return

Returned: a <GskRoundedRect>.

the offset rounded rectangle

Procedure: rounded-rect:set-bounds! self bounds
Procedure: rounded-rect:set-corner! self corner
Method: rounded-rect:shrink self top right bottom left ⇒ %return
Method: shrink self top right bottom left ⇒ %return

Shrinks (or grows) a rounded rectangle by moving the 4 sides according to the offsets given.

The corner radii will be changed in a way that tries to keep the center of the corner circle intact. This emulates CSS behavior.

This function also works for growing rounded rectangles if you pass negative values for the top, right, bottom or left.

self

Passed: a <GskRoundedRect>.

the rounded rectangle to shrink or grow

top

Passed: a real number.

how far to move the top side downwards

right

Passed: a real number.

how far to move the right side to the left

bottom

Passed: a real number.

how far to move the bottom side upwards

left

Passed: a real number.

how far to move the left side to the right

%return

Returned: a <GskRoundedRect>.

the resized rounded rectangle