@@ -179,9 +179,9 @@ defmodule Scenic.Primitive do
179
179
[Scenic.Primitives](Scenic.Primitives.html) instead.
180
180
181
181
Parameters:
182
- `module` - The module of the primitive you are building
183
- `data` - the primitive-specific data being set into the primitive
184
- `opts` - a list of style and transform options to apply to the primitive
182
+ * `module` - The module of the primitive you are building
183
+ * `data` - the primitive-specific data being set into the primitive
184
+ * `opts` - a list of style and transform options to apply to the primitive
185
185
186
186
Returns the built primitive.
187
187
"""
@@ -298,7 +298,7 @@ defmodule Scenic.Primitive do
298
298
Get the styles map from a primitive.
299
299
300
300
Parameters:
301
- `primitive` - The primitive
301
+ * `primitive` - The primitive
302
302
303
303
Returns the a map of styles set directly onto this primitive. This does
304
304
not include any inherited styles.
@@ -314,8 +314,8 @@ defmodule Scenic.Primitive do
314
314
Update the styles map in a primitive.
315
315
316
316
Parameters:
317
- `primitive` - The primitive
318
- `styles` - The new styles map
317
+ * `primitive` - The primitive
318
+ * `styles` - The new styles map
319
319
320
320
Returns the primitive with the updated styles.
321
321
"""
@@ -337,9 +337,9 @@ defmodule Scenic.Primitive do
337
337
If the style is not set, it returns default
338
338
339
339
Parameters:
340
- `primitive` - The primitive
341
- `type` - atom representing the style to get.
342
- `default` - default value to return if the style is not set.
340
+ * `primitive` - The primitive
341
+ * `type` - atom representing the style to get.
342
+ * `default` - default value to return if the style is not set.
343
343
344
344
Returns the value of the style.
345
345
"""
@@ -352,9 +352,9 @@ defmodule Scenic.Primitive do
352
352
Update the value of a specific style set on the primitive.
353
353
354
354
Parameters:
355
- `primitive` - The primitive
356
- `type` - atom representing the style to get.
357
- `data` - the value to set on the style.
355
+ * `primitive` - The primitive
356
+ * `type` - atom representing the style to get.
357
+ * `data` - the value to set on the style.
358
358
359
359
Returns the updated primitive.
360
360
"""
@@ -371,6 +371,7 @@ defmodule Scenic.Primitive do
371
371
|> ( & put_styles ( p , & 1 ) ) . ( )
372
372
end
373
373
374
+ @ deprecated "Use Primitive.merge_opts instead"
374
375
def put_style ( % Primitive { } = p , list ) when is_list ( list ) do
375
376
Enum . reduce ( list , p , fn { type , data } , acc ->
376
377
put_style ( acc , type , data )
@@ -383,8 +384,8 @@ defmodule Scenic.Primitive do
383
384
Does nothing if the style is not set.
384
385
385
386
Parameters:
386
- `primitive` - The primitive
387
- `type` - atom representing the style to delete.
387
+ * `primitive` - The primitive
388
+ * `type` - atom representing the style to delete.
388
389
389
390
Returns the updated primitive.
390
391
"""
@@ -404,7 +405,7 @@ defmodule Scenic.Primitive do
404
405
Get the transforms map from a primitive.
405
406
406
407
Parameters:
407
- `primitive` - The primitive
408
+ * `primitive` - The primitive
408
409
409
410
Returns the a map of transforms set directly onto this primitive. This does
410
411
not include any inherited transforms.
@@ -420,8 +421,8 @@ defmodule Scenic.Primitive do
420
421
Update the transforms map in a primitive.
421
422
422
423
Parameters:
423
- `primitive` - The primitive
424
- `transforms` - The new transforms map
424
+ * `primitive` - The primitive
425
+ * `transforms` - The new transforms map
425
426
426
427
Returns the primitive with the updated transforms.
427
428
"""
@@ -444,9 +445,9 @@ defmodule Scenic.Primitive do
444
445
If the transform is not set, it returns default
445
446
446
447
Parameters:
447
- `primitive` - The primitive
448
- `type` - atom representing the transform to get.
449
- `default` - default value to return if the transform is not set.
448
+ * `primitive` - The primitive
449
+ * `type` - atom representing the transform to get.
450
+ * `default` - default value to return if the transform is not set.
450
451
451
452
Returns the value of the transform.
452
453
"""
@@ -459,9 +460,9 @@ defmodule Scenic.Primitive do
459
460
Update the value of a specific transform set on the primitive.
460
461
461
462
Parameters:
462
- `primitive` - The primitive
463
- `type` - atom representing the transform to get.
464
- `data` - the value to set on the transform.
463
+ * `primitive` - The primitive
464
+ * `type` - atom representing the transform to get.
465
+ * `data` - the value to set on the transform.
465
466
466
467
Returns the updated primitive.
467
468
"""
@@ -478,6 +479,7 @@ defmodule Scenic.Primitive do
478
479
|> ( & put_transforms ( p , & 1 ) ) . ( )
479
480
end
480
481
482
+ @ deprecated "Use Primitive.merge_opts instead"
481
483
def put_transform ( % Primitive { } = p , tx_list ) when is_list ( tx_list ) do
482
484
Enum . reduce ( tx_list , p , fn { k , v } , acc ->
483
485
put_transform ( acc , k , v )
@@ -491,8 +493,8 @@ defmodule Scenic.Primitive do
491
493
Does nothing if the transform is not set.
492
494
493
495
Parameters:
494
- `primitive` - The primitive
495
- `type` - atom representing the transform to delete.
496
+ * `primitive` - The primitive
497
+ * `type` - atom representing the transform to delete.
496
498
497
499
Returns the updated primitive.
498
500
"""
@@ -512,7 +514,7 @@ defmodule Scenic.Primitive do
512
514
Get the value of the primitive-specific data.
513
515
514
516
Parameters:
515
- `primitive` - The primitive
517
+ * `primitive` - The primitive
516
518
517
519
Returns the value of the primitive-specific data.
518
520
"""
@@ -528,7 +530,7 @@ defmodule Scenic.Primitive do
528
530
@ spec put_opts ( primitive :: Primitive . t ( ) , opts :: keyword ) :: Primitive . t ( )
529
531
def put_opts ( primitive , opts )
530
532
531
- def put_opts ( % Primitive { } = p , opts ) when is_list ( opts ) do
533
+ def put_opts ( % Primitive { } , opts ) when is_list ( opts ) do
532
534
raise "Primitive.put_opts has been deprecated. Use Primitive.merge_opts instead."
533
535
end
534
536
@@ -540,7 +542,7 @@ defmodule Scenic.Primitive do
540
542
more of a merge. The supplied list of styles and transforms
541
543
542
544
Parameters:
543
- `primitive` - The primitive
545
+ * `primitive` - The primitive
544
546
545
547
Returns the value of the primitive-specific data.
546
548
"""
@@ -558,9 +560,9 @@ defmodule Scenic.Primitive do
558
560
off using the helper functions in [`Scenic.Primitives`](Scenic.Primitives.html) instead.
559
561
560
562
Parameters:
561
- `primitive` - The primitive
562
- `data` - The data to set
563
- `opts` - A list of style/transform options to merge
563
+ * `primitive` - The primitive
564
+ * `data` - The data to set
565
+ * `opts` - A list of style/transform options to merge
564
566
565
567
Returns the updated primitive.
566
568
"""
@@ -645,6 +647,26 @@ defmodule Scenic.Primitive do
645
647
defp mprim_add_transforms ( min_p , _ ) , do: min_p
646
648
647
649
# --------------------------------------------------------
650
+ @ doc """
651
+ Determines if a point is contained within a primitive.
652
+
653
+ The supplied point must already be projected into the local coordinate space
654
+ of the primitive. In other words, this test does NOT take into account any
655
+ transforms that have been applied to the primitive.
656
+
657
+ The input mechanism takes care of this for you by projecting incoming points
658
+ by the inverse-matrix of a primitive before calling this function...
659
+
660
+ Note that some primitives, such as Group, do not inherently have a notion of
661
+ containing a point. In those cases, this function will always return false.
662
+
663
+ Parameters:
664
+ * `primitive` - The primitive
665
+ * `point` - The point to test
666
+
667
+ Returns `true` or `false`.
668
+ """
669
+
648
670
@ spec contains_point? ( primitive :: Primitive . t ( ) , point :: Scenic.Math . point ( ) ) :: map
649
671
def contains_point? ( % Primitive { module: mod , data: data } , point ) do
650
672
mod . contains_point? ( data , point )
0 commit comments