Package: graphene

Macro graphene:with-size

Lambda List

graphene:with-size ((var &rest args) &body body)

Syntax

(graphene:with-size (s) body) => result
(graphene:with-size (s s1) body) => result
(graphene:with-size (s width height) body) => result

Arguments

s -- a graphene:size-t instance to create and initialize
s1 -- a graphene:size-t instance to use for initialization
width -- a number coerced to a float for the width component
height -- a number coerced to a float for the height component

Details

The graphene:with-size macro allocates a new graphene:size-t instance, initializes the graphene:size-t instance with the given values and executes the body that uses the size. After execution of the body the allocated memory for the size is released.

When no argument is given the components of the graphene:size-t instance are initialized to zero. The initialization with two single floats uses the graphene:size-init function. The initialization from another size is done with the graphene:size-init-from-size function.

Note

The memory is allocated with the graphene:size-alloc function and released with the graphene:size-free function.

Examples

Initialize a graphene:size-t instance with no value and two float values.
(graphene:with-size (s)
  (list (graphene:size-width s) (graphene:size-height s)))
=> (0.0 0.0)
(graphene:with-size (s 1.5 1.7)
  (list (graphene:size-width s) (graphene:size-height s)))
=> (1.5 1.7)    
This examples uses the graphene:with-sizes macro to initialize two graphene:size-t instances. The second instance is intialized with the values from the first instance.
(graphene:with-sizes ((s1 0.3 0.5) (s2 s1))
  (list (graphene:size-width s2) (graphene:size-height s2)))
=> (0.3 0.5)    
 

See also

2024-1-20