libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
Loading...
Searching...
No Matches
cairo_utils.c
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license in the file COPYING
10 * or http://www.opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file COPYING.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2022 Saso Kiselkov. All rights reserved.
24 */
25
26#include "acfutils/assert.h"
27#include "acfutils/geom.h"
29
30void
31cairo_utils_rounded_rect(cairo_t *cr, double x, double y,
32 double w, double h, double radius)
33{
34 ASSERT(cr != NULL);
35 cairo_move_to(cr, x + radius, y);
36 cairo_line_to(cr, x + w - radius, y);
37 cairo_arc(cr, x + w - radius, y + radius, radius,
38 DEG2RAD(270), DEG2RAD(360));
39 cairo_line_to(cr, x + w, y + h - radius);
40 cairo_arc(cr, x + w - radius, y + h - radius, radius,
41 DEG2RAD(0), DEG2RAD(90));
42 cairo_line_to(cr, x + radius, y + h);
43 cairo_arc(cr, x + radius, y + h - radius, radius,
44 DEG2RAD(90), DEG2RAD(180));
45 cairo_line_to(cr, x, y + radius);
46 cairo_arc(cr, x + radius, y + radius, radius,
47 DEG2RAD(180), DEG2RAD(270));
48}
#define ASSERT(x)
Definition assert.h:208
void cairo_utils_rounded_rect(cairo_t *cr, double x, double y, double w, double h, double radius)
Definition cairo_utils.c:31
#define DEG2RAD(d)
Definition geom.h:156