Branch data Line data Source code
1 : : /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 : : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
3 : : // SPDX-FileCopyrightText: 2010 litl, LLC.
4 : :
5 : : #include <config.h>
6 : :
7 : : #include <cairo.h>
8 : :
9 : : #include <js/PropertyDescriptor.h> // for JSPROP_READONLY
10 : : #include <js/PropertySpec.h>
11 : : #include <js/RootingAPI.h>
12 : : #include <js/TypeDecls.h>
13 : : #include <jsapi.h> // for JS_NewObjectWithGivenProto
14 : : #include <jspubtd.h> // for JSProtoKey
15 : :
16 : : #include "gjs/jsapi-util-args.h"
17 : : #include "modules/cairo-private.h"
18 : :
19 : : namespace JS {
20 : : class CallArgs;
21 : : }
22 : :
23 : 2 : JSObject* CairoRadialGradient::new_proto(JSContext* cx, JSProtoKey) {
24 : 2 : JS::RootedObject parent_proto(cx, CairoGradient::prototype(cx));
25 : 2 : return JS_NewObjectWithGivenProto(cx, nullptr, parent_proto);
26 : 2 : }
27 : :
28 : 1 : cairo_pattern_t* CairoRadialGradient::constructor_impl(
29 : : JSContext* context, const JS::CallArgs& argv) {
30 : : double cx0, cy0, radius0, cx1, cy1, radius1;
31 : : cairo_pattern_t* pattern;
32 [ - + ]: 1 : if (!gjs_parse_call_args(context, "RadialGradient", argv, "ffffff",
33 : : "cx0", &cx0,
34 : : "cy0", &cy0,
35 : : "radius0", &radius0,
36 : : "cx1", &cx1,
37 : : "cy1", &cy1,
38 : : "radius1", &radius1))
39 : 0 : return nullptr;
40 : :
41 : 1 : pattern = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1);
42 : :
43 [ - + ]: 1 : if (!gjs_cairo_check_status(context, cairo_pattern_status(pattern), "pattern"))
44 : 0 : return nullptr;
45 : :
46 : 1 : return pattern;
47 : : }
48 : :
49 : : const JSPropertySpec CairoRadialGradient::proto_props[] = {
50 : : JS_STRING_SYM_PS(toStringTag, "RadialGradient", JSPROP_READONLY),
51 : : JS_PS_END};
52 : :
53 : : const JSFunctionSpec CairoRadialGradient::proto_funcs[] = {
54 : : // getRadialCircles
55 : : JS_FS_END};
|