1from plotly.basedatatypes import BaseLayoutHierarchyType as _BaseLayoutHierarchyType
2import copy as _copy
3
4
5class Newshape(_BaseLayoutHierarchyType):
6
7    # class properties
8    # --------------------
9    _parent_path_str = "layout"
10    _path_str = "layout.newshape"
11    _valid_props = {
12        "drawdirection",
13        "fillcolor",
14        "fillrule",
15        "layer",
16        "line",
17        "opacity",
18    }
19
20    # drawdirection
21    # -------------
22    @property
23    def drawdirection(self):
24        """
25        When `dragmode` is set to "drawrect", "drawline" or
26        "drawcircle" this limits the drag to be horizontal, vertical or
27        diagonal. Using "diagonal" there is no limit e.g. in drawing
28        lines in any direction. "ortho" limits the draw to be either
29        horizontal or vertical. "horizontal" allows horizontal extend.
30        "vertical" allows vertical extend.
31
32        The 'drawdirection' property is an enumeration that may be specified as:
33          - One of the following enumeration values:
34                ['ortho', 'horizontal', 'vertical', 'diagonal']
35
36        Returns
37        -------
38        Any
39        """
40        return self["drawdirection"]
41
42    @drawdirection.setter
43    def drawdirection(self, val):
44        self["drawdirection"] = val
45
46    # fillcolor
47    # ---------
48    @property
49    def fillcolor(self):
50        """
51        Sets the color filling new shapes' interior. Please note that
52        if using a fillcolor with alpha greater than half, drag inside
53        the active shape starts moving the shape underneath, otherwise
54        a new shape could be started over.
55
56        The 'fillcolor' property is a color and may be specified as:
57          - A hex string (e.g. '#ff0000')
58          - An rgb/rgba string (e.g. 'rgb(255,0,0)')
59          - An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
60          - An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
61          - A named CSS color:
62                aliceblue, antiquewhite, aqua, aquamarine, azure,
63                beige, bisque, black, blanchedalmond, blue,
64                blueviolet, brown, burlywood, cadetblue,
65                chartreuse, chocolate, coral, cornflowerblue,
66                cornsilk, crimson, cyan, darkblue, darkcyan,
67                darkgoldenrod, darkgray, darkgrey, darkgreen,
68                darkkhaki, darkmagenta, darkolivegreen, darkorange,
69                darkorchid, darkred, darksalmon, darkseagreen,
70                darkslateblue, darkslategray, darkslategrey,
71                darkturquoise, darkviolet, deeppink, deepskyblue,
72                dimgray, dimgrey, dodgerblue, firebrick,
73                floralwhite, forestgreen, fuchsia, gainsboro,
74                ghostwhite, gold, goldenrod, gray, grey, green,
75                greenyellow, honeydew, hotpink, indianred, indigo,
76                ivory, khaki, lavender, lavenderblush, lawngreen,
77                lemonchiffon, lightblue, lightcoral, lightcyan,
78                lightgoldenrodyellow, lightgray, lightgrey,
79                lightgreen, lightpink, lightsalmon, lightseagreen,
80                lightskyblue, lightslategray, lightslategrey,
81                lightsteelblue, lightyellow, lime, limegreen,
82                linen, magenta, maroon, mediumaquamarine,
83                mediumblue, mediumorchid, mediumpurple,
84                mediumseagreen, mediumslateblue, mediumspringgreen,
85                mediumturquoise, mediumvioletred, midnightblue,
86                mintcream, mistyrose, moccasin, navajowhite, navy,
87                oldlace, olive, olivedrab, orange, orangered,
88                orchid, palegoldenrod, palegreen, paleturquoise,
89                palevioletred, papayawhip, peachpuff, peru, pink,
90                plum, powderblue, purple, red, rosybrown,
91                royalblue, rebeccapurple, saddlebrown, salmon,
92                sandybrown, seagreen, seashell, sienna, silver,
93                skyblue, slateblue, slategray, slategrey, snow,
94                springgreen, steelblue, tan, teal, thistle, tomato,
95                turquoise, violet, wheat, white, whitesmoke,
96                yellow, yellowgreen
97
98        Returns
99        -------
100        str
101        """
102        return self["fillcolor"]
103
104    @fillcolor.setter
105    def fillcolor(self, val):
106        self["fillcolor"] = val
107
108    # fillrule
109    # --------
110    @property
111    def fillrule(self):
112        """
113        Determines the path's interior. For more info please visit
114        https://developer.mozilla.org/en-
115        US/docs/Web/SVG/Attribute/fill-rule
116
117        The 'fillrule' property is an enumeration that may be specified as:
118          - One of the following enumeration values:
119                ['evenodd', 'nonzero']
120
121        Returns
122        -------
123        Any
124        """
125        return self["fillrule"]
126
127    @fillrule.setter
128    def fillrule(self, val):
129        self["fillrule"] = val
130
131    # layer
132    # -----
133    @property
134    def layer(self):
135        """
136        Specifies whether new shapes are drawn below or above traces.
137
138        The 'layer' property is an enumeration that may be specified as:
139          - One of the following enumeration values:
140                ['below', 'above']
141
142        Returns
143        -------
144        Any
145        """
146        return self["layer"]
147
148    @layer.setter
149    def layer(self, val):
150        self["layer"] = val
151
152    # line
153    # ----
154    @property
155    def line(self):
156        """
157        The 'line' property is an instance of Line
158        that may be specified as:
159          - An instance of :class:`plotly.graph_objs.layout.newshape.Line`
160          - A dict of string/value properties that will be passed
161            to the Line constructor
162
163            Supported dict properties:
164
165                color
166                    Sets the line color. By default uses either
167                    dark grey or white to increase contrast with
168                    background color.
169                dash
170                    Sets the dash style of lines. Set to a dash
171                    type string ("solid", "dot", "dash",
172                    "longdash", "dashdot", or "longdashdot") or a
173                    dash length list in px (eg "5px,10px,2px,2px").
174                width
175                    Sets the line width (in px).
176
177        Returns
178        -------
179        plotly.graph_objs.layout.newshape.Line
180        """
181        return self["line"]
182
183    @line.setter
184    def line(self, val):
185        self["line"] = val
186
187    # opacity
188    # -------
189    @property
190    def opacity(self):
191        """
192        Sets the opacity of new shapes.
193
194        The 'opacity' property is a number and may be specified as:
195          - An int or float in the interval [0, 1]
196
197        Returns
198        -------
199        int|float
200        """
201        return self["opacity"]
202
203    @opacity.setter
204    def opacity(self, val):
205        self["opacity"] = val
206
207    # Self properties description
208    # ---------------------------
209    @property
210    def _prop_descriptions(self):
211        return """\
212        drawdirection
213            When `dragmode` is set to "drawrect", "drawline" or
214            "drawcircle" this limits the drag to be horizontal,
215            vertical or diagonal. Using "diagonal" there is no
216            limit e.g. in drawing lines in any direction. "ortho"
217            limits the draw to be either horizontal or vertical.
218            "horizontal" allows horizontal extend. "vertical"
219            allows vertical extend.
220        fillcolor
221            Sets the color filling new shapes' interior. Please
222            note that if using a fillcolor with alpha greater than
223            half, drag inside the active shape starts moving the
224            shape underneath, otherwise a new shape could be
225            started over.
226        fillrule
227            Determines the path's interior. For more info please
228            visit https://developer.mozilla.org/en-
229            US/docs/Web/SVG/Attribute/fill-rule
230        layer
231            Specifies whether new shapes are drawn below or above
232            traces.
233        line
234            :class:`plotly.graph_objects.layout.newshape.Line`
235            instance or dict with compatible properties
236        opacity
237            Sets the opacity of new shapes.
238        """
239
240    def __init__(
241        self,
242        arg=None,
243        drawdirection=None,
244        fillcolor=None,
245        fillrule=None,
246        layer=None,
247        line=None,
248        opacity=None,
249        **kwargs
250    ):
251        """
252        Construct a new Newshape object
253
254        Parameters
255        ----------
256        arg
257            dict of properties compatible with this constructor or
258            an instance of
259            :class:`plotly.graph_objs.layout.Newshape`
260        drawdirection
261            When `dragmode` is set to "drawrect", "drawline" or
262            "drawcircle" this limits the drag to be horizontal,
263            vertical or diagonal. Using "diagonal" there is no
264            limit e.g. in drawing lines in any direction. "ortho"
265            limits the draw to be either horizontal or vertical.
266            "horizontal" allows horizontal extend. "vertical"
267            allows vertical extend.
268        fillcolor
269            Sets the color filling new shapes' interior. Please
270            note that if using a fillcolor with alpha greater than
271            half, drag inside the active shape starts moving the
272            shape underneath, otherwise a new shape could be
273            started over.
274        fillrule
275            Determines the path's interior. For more info please
276            visit https://developer.mozilla.org/en-
277            US/docs/Web/SVG/Attribute/fill-rule
278        layer
279            Specifies whether new shapes are drawn below or above
280            traces.
281        line
282            :class:`plotly.graph_objects.layout.newshape.Line`
283            instance or dict with compatible properties
284        opacity
285            Sets the opacity of new shapes.
286
287        Returns
288        -------
289        Newshape
290        """
291        super(Newshape, self).__init__("newshape")
292
293        if "_parent" in kwargs:
294            self._parent = kwargs["_parent"]
295            return
296
297        # Validate arg
298        # ------------
299        if arg is None:
300            arg = {}
301        elif isinstance(arg, self.__class__):
302            arg = arg.to_plotly_json()
303        elif isinstance(arg, dict):
304            arg = _copy.copy(arg)
305        else:
306            raise ValueError(
307                """\
308The first argument to the plotly.graph_objs.layout.Newshape
309constructor must be a dict or
310an instance of :class:`plotly.graph_objs.layout.Newshape`"""
311            )
312
313        # Handle skip_invalid
314        # -------------------
315        self._skip_invalid = kwargs.pop("skip_invalid", False)
316        self._validate = kwargs.pop("_validate", True)
317
318        # Populate data dict with properties
319        # ----------------------------------
320        _v = arg.pop("drawdirection", None)
321        _v = drawdirection if drawdirection is not None else _v
322        if _v is not None:
323            self["drawdirection"] = _v
324        _v = arg.pop("fillcolor", None)
325        _v = fillcolor if fillcolor is not None else _v
326        if _v is not None:
327            self["fillcolor"] = _v
328        _v = arg.pop("fillrule", None)
329        _v = fillrule if fillrule is not None else _v
330        if _v is not None:
331            self["fillrule"] = _v
332        _v = arg.pop("layer", None)
333        _v = layer if layer is not None else _v
334        if _v is not None:
335            self["layer"] = _v
336        _v = arg.pop("line", None)
337        _v = line if line is not None else _v
338        if _v is not None:
339            self["line"] = _v
340        _v = arg.pop("opacity", None)
341        _v = opacity if opacity is not None else _v
342        if _v is not None:
343            self["opacity"] = _v
344
345        # Process unknown kwargs
346        # ----------------------
347        self._process_kwargs(**dict(arg, **kwargs))
348
349        # Reset skip_invalid
350        # ------------------
351        self._skip_invalid = False
352