Size

Size — Size representation

Functions

Types and Values

Includes

#include <graphene.h>

Description

graphene_size_t represents a size composed of a graphene_size_t.width by a graphene_size_t.height .

Functions

GRAPHENE_SIZE_INIT()

#define GRAPHENE_SIZE_INIT(_w,_h)       (graphene_size_t) { .width = (_w), .height = (_h) }

Initializes a graphene_size_t with the given sizes when declaring it, e.g.:

1
graphene_size_t size = GRAPHENE_SIZE_INIT (100.f, 100.f);

Parameters

_w

the width

 

_h

the height

 

Since: 1.0


graphene_size_alloc ()

graphene_size_t *
graphene_size_alloc (void);

Allocates a new graphene_size_t.

The contents of the returned value are undefined.

[constructor]

Returns

the newly allocated graphene_size_t.

[transfer full]

Since: 1.0


graphene_size_free ()

void
graphene_size_free (graphene_size_t *s);

Frees the resources allocated by graphene_size_alloc().

Parameters

Since: 1.0


graphene_size_init ()

graphene_size_t *
graphene_size_init (graphene_size_t *s,
                    float width,
                    float height);

Initializes a graphene_size_t using the given width and height .

Parameters

s

a graphene_size_t

 

width

the width

 

height

the height

 

Returns

the initialized graphene_size_t.

[transfer none]

Since: 1.0


graphene_size_init_from_size ()

graphene_size_t *
graphene_size_init_from_size (graphene_size_t *s,
                              const graphene_size_t *src);

Initializes a graphene_size_t using the width and height of the given src .

Parameters

Returns

the initialized graphene_size_t.

[transfer none]

Since: 1.0


graphene_size_equal ()

bool
graphene_size_equal (const graphene_size_t *a,
                     const graphene_size_t *b);

Checks whether the two give graphene_size_t are equal.

Parameters

Returns

true if the sizes are equal

Since: 1.0


graphene_size_scale ()

void
graphene_size_scale (const graphene_size_t *s,
                     float factor,
                     graphene_size_t *res);

Scales the components of a graphene_size_t using the given factor .

Parameters

s

a graphene_size_t

 

factor

the scaling factor

 

res

return location for the scaled size.

[out caller-allocates]

Since: 1.0


graphene_size_interpolate ()

void
graphene_size_interpolate (const graphene_size_t *a,
                           const graphene_size_t *b,
                           double factor,
                           graphene_size_t *res);

Linearly interpolates the two given graphene_size_t using the given interpolation factor .

Parameters

a

a graphene_size_t

 

b

a graphene_size_t

 

factor

the linear interpolation factor

 

res

return location for the interpolated size.

[out caller-allocates]

Since: 1.0


graphene_size_zero ()

const graphene_size_t *
graphene_size_zero (void);

A constant pointer to a zero graphene_size_t, useful for equality checks and interpolations.

Returns

a constant size.

[transfer none]

Since: 1.0

Types and Values

GRAPHENE_SIZE_INIT_ZERO

#define GRAPHENE_SIZE_INIT_ZERO         GRAPHENE_SIZE_INIT (0.f, 0.f)

Initializes a graphene_size_t to (0, 0) when declaring it.

Since: 1.0


graphene_size_t

typedef struct {
  float width;
  float height;
} graphene_size_t;

A size.

Members

float width;

the width

 

float height;

the height

 

Since: 1.0