forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanvas.lcb
More file actions
5118 lines (3762 loc) · 161 KB
/
canvas.lcb
File metadata and controls
5118 lines (3762 loc) · 161 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C) 2003-2015 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
/**
This module specifies the syntax definitions and bindings for canvas drawing operations in modular LiveCode.
*/
module com.livecode.canvas
use com.livecode.foreign
public type CanvasFloat is CFloat
// Point
public foreign type Point binds to "MCCanvasPointTypeInfo"
// Rectangle
public foreign type Rectangle binds to "MCCanvasRectangleTypeInfo"
// Transform
public foreign type Transform binds to "MCCanvasTransformTypeInfo"
// Color
public foreign type Color binds to "MCCanvasColorTypeInfo"
// Paint (supertype of pattern, gradient, solidpaint)
public foreign type Paint binds to "MCCanvasPaintTypeInfo"
// Solid Paint
public foreign type SolidPaint binds to "MCCanvasSolidPaintTypeInfo"
// Pattern
public foreign type Pattern binds to "MCCanvasPatternTypeInfo"
// Gradient
public foreign type Gradient binds to "MCCanvasGradientTypeInfo"
public foreign type GradientStop binds to "MCCanvasGradientStopTypeInfo"
// Image
public foreign type Image binds to "MCCanvasImageTypeInfo"
// Path
public foreign type Path binds to "MCCanvasPathTypeInfo"
// Effect
public foreign type Effect binds to "MCCanvasEffectTypeInfo"
// Font
public foreign type Font binds to "MCCanvasFontTypeInfo"
// Canvas
public foreign type Canvas binds to "MCCanvasTypeInfo"
////////////////////////////////////////////////////////////////////////////////
// Rectangle
// Constructors
public foreign handler MCCanvasRectangleMakeWithLTRB(in pLeft as CanvasFloat, in pTop as CanvasFloat, in pRight as CanvasFloat, in pBottom as CanvasFloat, out rRect as Rectangle) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleMakeWithList(in pRect as List, out rRect as Rectangle) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleGetLeft(in pRect as Rectangle, out rLeft as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleSetLeft(in pLeft as CanvasFloat, inout xRect as Rectangle) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleGetTop(in pRect as Rectangle, out rTop as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleSetTop(in pTop as CanvasFloat, inout xRect as Rectangle) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleGetRight(in pRect as Rectangle, out rRight as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleSetRight(in pRight as CanvasFloat, inout xRect as Rectangle) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleGetBottom(in pRect as Rectangle, out rBottom as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleSetBottom(in pBottom as CanvasFloat, inout xRect as Rectangle) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleGetWidth(in pRect as Rectangle, out rWidth as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleSetWidth(in pWidth as CanvasFloat, inout xRect as Rectangle) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleGetHeight(in pRect as Rectangle, out rHeight as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasRectangleSetHeight(in pHeight as CanvasFloat, inout xRect as Rectangle) returns nothing binds to "<builtin>"
/**
Summary: Creates a new rectangle value.
mRect: An expression which evaluates to a list of 4 numbers, the left, top, right and bottom edges of the rectangle.
Returns: A new rectange with the given edges.
Example:
// Initialize tRect to a rectangle value with origin at point 50,50 and size 100x50
variable tRect
put rectangle [50, 50, 150, 100] into tRect
Tags: Canvas
*/
syntax RectangleMake is prefix operator with constructor precedence
"rectangle" <mRect: Expression>
begin
MCCanvasRectangleMakeWithList(mRect, output)
end syntax
/**
Summary: The left edge of a rectangle value.
mRect: An expression which evaluates to a rectangle.
Description:
The location along the x-axis of the left edge of the rectangle.
>*Note:* Setting the left of a rectangle will reposition it without altering the width or height.
Example:
variable tRect
put rectangle [50,100,150,200] into tRect
// Store the left edge of the rectangle in a variable
variable tLeft
put the left of tRect into tLeft
// Move the rectangle horizontally to a new position.
set the left of tRect to 20
Tags: Canvas
*/
syntax RectanglePropertyLeft is prefix operator with property precedence
"the" "left" "of" <mRect:Expression>
begin
MCCanvasRectangleGetLeft(mRect, output)
MCCanvasRectangleSetLeft(input, mRect)
end syntax
syntax RectanglePropertyX is prefix operator with property precedence
"the" "x" "of" <mRect:Expression>
begin
MCCanvasRectangleGetLeft(mRect, output)
MCCanvasRectangleSetLeft(input, mRect)
end syntax
/**
Summary: The top edge of a rectangle value.
mRect: An expression which evaluates to a rectangle.
Description:
The location along the y-axis of the top edge of the rectangle.
>*Note:* Setting the top of a rectangle will reposition it without altering the width or height.
Example:
variable tRect
put rectangle [50,100,150,200] into tRect
// Store the top edge of the rectangle in a variable
variable tTop
put the top of tRect into tTop
// Move the rectangle vertically to a new position.
set the top of tRect to 120
Tags: Canvas
*/
syntax RectanglePropertyTop is prefix operator with property precedence
"the" "top" "of" <mRect:Expression>
begin
MCCanvasRectangleGetTop(mRect, output)
MCCanvasRectangleSetTop(input, mRect)
end syntax
syntax RectanglePropertyY is prefix operator with property precedence
"the" "y" "of" <mRect:Expression>
begin
MCCanvasRectangleGetTop(mRect, output)
MCCanvasRectangleSetTop(input, mRect)
end syntax
/**
Summary: The right edge of a rectangle value.
mRect: An expression which evaluates to a rectangle.
Description:
The location along the x-axis of the right edge of the rectangle.
>*Note:* Setting the right of a rectangle will reposition it without altering the width or height.
Example:
variable tRect
put rectangle [50,100,150,200] into tRect
// Store the right edge of the rectangle in a variable
variable tRight
put the right of tRect into tRight
// Move the rectangle horizontally to a new position.
set the right of tRect to (tRight + 10)
Tags: Canvas
*/
syntax RectanglePropertyRight is prefix operator with property precedence
"the" "right" "of" <mRect:Expression>
begin
MCCanvasRectangleGetRight(mRect, output)
MCCanvasRectangleSetRight(input, mRect)
end syntax
/**
Summary: The bottom edge of a rectangle value.
mRect: An expression which evaluates to a rectangle.
Description:
The location along the y-axis of the bottom edge of the rectangle.
>*Note:* Setting the bottom of a rectangle will reposition it without altering the width or height.
Example:
variable tRect
put rectangle [50,100,150,200] into tRect
// Store the bottom edge of the rectangle in a variable
variable tBottom
put the bottom of tRect into tBottom
// Move the rectangle vertically to a new position.
set the bottom of tRect to (tBottom + 10)
Tags: Canvas
*/
syntax RectanglePropertyBottom is prefix operator with property precedence
"the" "bottom" "of" <mRect:Expression>
begin
MCCanvasRectangleGetBottom(mRect, output)
MCCanvasRectangleSetBottom(input, mRect)
end syntax
/**
Summary: The width of a rectangle value.
mRect: An expression which evaluates to a rectangle.
Description:
The width of the rectangle.
>*Note:* Setting the width of a rectangle will resize it without moving the left edge, expanding or contracting from the right.
Example:
variable tRect
put rectangle [50,100,150,200] into tRect
// Store the width of the rectangle in a variable
variable tWidth
put the width of tRect into tWidth
// Increase the width of the rectangle
set the width of tRect to (tWidth + 10)
Tags: Canvas
*/
syntax RectanglePropertyWidth is prefix operator with property precedence
"the" "width" "of" <mRect:Expression>
begin
MCCanvasRectangleGetWidth(mRect, output)
MCCanvasRectangleSetWidth(input, mRect)
end syntax
/**
Summary: The height of a rectangle value.
mRect: An expression which evaluates to a rectangle.
Description:
The height of the rectangle.
>*Note:* Setting the height of a rectangle will resize it without moving the top edge, expanding or contracting from the bottom.
Example:
variable tRect
put rectangle [50,100,150,200] into tRect
// Store the height of the rectangle in a variable
variable tHeight
put the height of tRect into tHeight
// Increase the height of the rectangle
set the height of tRect to (tHeight + 10)
Tags: Canvas
*/
syntax RectanglePropertyHeight is prefix operator with property precedence
"the" "height" "of" <mRect:Expression>
begin
MCCanvasRectangleGetHeight(mRect, output)
MCCanvasRectangleSetHeight(input, mRect)
end syntax
////////////////////////////////////////////////////////////////////////////////
// Point
// Constructors
public foreign handler MCCanvasPointMake(in pX as CanvasFloat, in pY as CanvasFloat, out rPoint as Point) returns nothing binds to "<builtin>"
public foreign handler MCCanvasPointMakeWithList(in pPoint as List, out rPoint as Point) returns nothing binds to "<builtin>"
public foreign handler MCCanvasPointGetX(in pPoint as Point, out rX as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasPointSetX(in pX as CanvasFloat, inout xPoint as Point) returns nothing binds to "<builtin>"
public foreign handler MCCanvasPointGetY(in pPoint as Point, out rY as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasPointSetY(in pY as CanvasFloat, inout xPoint as Point) returns nothing binds to "<builtin>"
/**
Summary: Creates a new point value.
mPoint: An expression which evaluates to a list of 2 numbers, the x and y coordinates of the point.
Returns: A new point with the given coordinates
Example:
variable tPoint
put point [50, 100] into tPoint
Tags: Canvas
*/
syntax PointMake is prefix operator with property precedence
"point" <mPoint: Expression>
begin
MCCanvasPointMakeWithList(mPoint, output)
end syntax
/**
Summary: The x coordinate of a point value.
mPoint: An expression which evaluates to a point.
Description: The x coordinate of <mPoint>.
Example:
variable tPoint
put point [50, 100] into tPoint
// Store the x-coordinate of the point in a variable
variable tX
put the x of tPoint into tX
// Move the point 10 units to the right
set the x of tPoint to (tX + 10)
Tags: Canvas
*/
syntax PointPropertyX is prefix operator with property precedence
"the" "x" "of" <mPoint: Expression>
begin
MCCanvasPointGetX(mPoint, output)
MCCanvasPointSetX(input, mPoint)
end syntax
/**
Summary: The y coordinate of a point value.
mPoint: An expression which evaluates to a point.
Description: The y coordinate of <mPoint>.
Example:
variable tPoint
put point [50, 100] into tPoint
// Store the y-coordinate of the point in a variable
variable tY
put the y of tPoint into tY
// Move the point 10 units downward.
set the y of tPoint to (tY + 10)
Tags: Canvas
*/
syntax PointPropertyY is prefix operator with property precedence
"the" "y" "of" <mPoint: Expression>
begin
MCCanvasPointGetY(mPoint, output)
MCCanvasPointSetY(input, mPoint)
end syntax
////////////////////////////////////////////////////////////////////////////////
// Color
// Constructors
public foreign handler MCCanvasColorMakeRGBA(in pRed as CanvasFloat, in pGreen as CanvasFloat, in pBlue as CanvasFloat, in pAlpha as CanvasFloat, out rColor as Color) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorMakeWithList(in pColor as List, out rColor as Color) returns nothing binds to "<builtin>"
//public foreign handler MCCanvasColorMakeWithString(in pList as String, out rColor as Color)
/**
Summary: Creates a new color value.
mColor: An expression which evaluates to a list of 3 or 4 numbers, the red, green, blue, and (optional) alpha components of the color.
Returns: A new color with the given RGBA values.
Description:
>*Note:* The component value denotes the intensity of that component, expressed as a real number between 0 and 1. The alpha component represents the opacity of the color. If the alpha component is not specified then it is assumed to be 1 (fully opaque).
Example:
variable tColor
// Set tColor to opaque red
put color [1.0, 0.0, 0.0] into tColor
// Set tColor to partially transparent cyan
put color [0.0, 1.0, 1.0, 0.75] into tColor
Tags: Canvas
*/
syntax ColorMake is prefix operator with constructor precedence
"color" <mColor: Expression>
begin
MCCanvasColorMakeWithList(mColor, output)
end syntax
//////////
// Properties
public foreign handler MCCanvasColorGetRed(in pColor as Color, out rRed as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorSetRed(in pRed as CanvasFloat, inout xColor as Color) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorGetGreen(in pColor as Color, out rGreen as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorSetGreen(in pGreen as CanvasFloat, inout xColor as Color) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorGetBlue(in pColor as Color, out rBlue as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorSetBlue(in pBlue as CanvasFloat, inout xColor as Color) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorGetAlpha(in pColor as Color, out rAlpha as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasColorSetAlpha(in pAlpha as CanvasFloat, inout xColor as Color) returns nothing binds to "<builtin>"
/**
Summary: The red component of a color value.
mColor: An expression which evaluates to a color.
Description:
The red component of <mColor>
>*Note:* The component value denotes the intensity of that component, expressed as a real number between 0 and 1.
Example:
variable tColor
put color [0.75, 1.0, 0.5] into tColor
// Store the old red value
variable tRed
put the red of tColor into tRed
// Invert the intensity of the red color component
set the red of tColor to 1.0 - tRed
Tags: Canvas
*/
syntax ColorPropertyRed is prefix operator with property precedence
"the" "red" "of" <mColor: Expression>
begin
MCCanvasColorGetRed(mColor, output)
MCCanvasColorSetRed(input, mColor)
end syntax
/**
Summary: The green component of a color value.
mColor: An expression which evaluates to a color.
Description:
The green component of <mColor>
>*Note:* The component value denotes the intensity of that component, expressed as a real number between 0 and 1.
Example:
variable tColor
put color [0.75, 1.0, 0.5] into tColor
// Store the old green value
variable tGreen
put the green of tColor into tGreen
// Remove any green component from the color
set the green of tColor to 0
Tags: Canvas
*/
syntax ColorPropertyGreen is prefix operator with property precedence
"the" "green" "of" <mColor: Expression>
begin
MCCanvasColorGetGreen(mColor, output)
MCCanvasColorSetGreen(input, mColor)
end syntax
/**
Summary: The blue component of a color value.
mColor: An expression which evaluates to a color.
Description:
The blue component of <mColor>
>*Note:* The component value denotes the intensity of that component, expressed as a real number between 0 and 1.
Example:
variable tColor
put color [0.75, 1.0, 0.5] into tColor
// Store the old blue value
variable tBlue
put the blue of tColor into tBlue
// Set the blue component of the color to full intensity
set the blue of tColor to 1
Tags: Canvas
*/
syntax ColorPropertyBlue is prefix operator with property precedence
"the" "blue" "of" <mColor: Expression>
begin
MCCanvasColorGetBlue(mColor, output)
MCCanvasColorSetBlue(input, mColor)
end syntax
/**
Summary: The alpha component of a color value.
mColor: An expression which evaluates to a color.
Description:
The alpha component of <mColor>
>*Note:* The alpha value represents the opacity of the color, expressed as a real number between 0 (fully transparent) and 1 (fully opaque).
Example:
variable tColor
put color [0.75, 1.0, 0.5] into tColor
// Store the old alpha value
variable tAlpha
put the alpha of tColor into tAlpha
// Make the color semi-transparent
set the alpha of tColor to 0.5
Tags: Canvas
*/
syntax ColorPropertyAlpha is prefix operator with property precedence
"the" "alpha" "of" <mColor: Expression>
begin
MCCanvasColorGetAlpha(mColor, output)
MCCanvasColorSetAlpha(input, mColor)
end syntax
////////////////////////////////////////////////////////////////////////////////
// Transform
// Constructors
public foreign handler MCCanvasTransformMakeIdentity(out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeScale(in pScaleX as CanvasFloat, in pScaleY as CanvasFloat, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeScaleWithList(in pScale as List, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeSkew(in pSkewX as CanvasFloat, in pSkewY as CanvasFloat, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeSkewWithList(in pSkew as List, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeRotation(in pRotation as CanvasFloat, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeTranslation(in pX as CanvasFloat, in pY as CanvasFloat, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeTranslationWithList(in pTranslation as List, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeWithMatrixValues(in pA as CanvasFloat, in pB as CanvasFloat, in pC as CanvasFloat, in pD as CanvasFloat, in pTX as CanvasFloat, in pTY as CanvasFloat, out rTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMakeWithMatrixAsList(in pMatrix as List, out rTransform as Transform) returns nothing binds to "<builtin>"
/**
Summary: The identity transform.
Returns: A new identity transform.
Description:
The identity transform represents a coordinate transformation where the set of coordinates remain the same after it is applied. This can be useful when specifying that coordinates should not be altered, or as a starting point when combining transforms to produce a more complex one.
Example:
variable tTransform
put the identity transform into tTransform
Tags: Canvas
*/
syntax TransformMakeIdentity is expression
"the" "identity" "transform"
begin
MCCanvasTransformMakeIdentity(output)
end syntax
/**
Summary: Creates a new scaling transform value.
mScale: An expression which evaluates to a list of 1 or 2 numbers, the x-axis scale and y-axis scale, or the uniform scale when only a single value is given.
Returns: A new scale transform.
Example:
// Create x2 uniformly scaling transform
variable tTransform
put transform with scale [2] into tTransform
// Create transform which only scales in the direction of the x axis
put transform with scale [ 2, 1 ] into tTransform
Tags: Canvas
*/
syntax TransformMakeScale is prefix operator with constructor precedence
"transform" "with" "scale" <mScale: Expression>
begin
MCCanvasTransformMakeScaleWithList(mScale, output)
end syntax
/**
Summary: Creates a new skewing transform value.
mScale: An expression which evaluates to a list of 2 numbers, the x-axis skew and y-axis skew.
Returns: A new skew transform.
Example:
// Create skew transform
variable tTransform
put transform with skew [1,0] into tTransform
Tags: Canvas
*/
syntax TransformMakeSkew is prefix operator with constructor precedence
"transform" "with" "skew" <mSkew: Expression>
begin
MCCanvasTransformMakeSkewWithList(mSkew, output)
end syntax
/**
Summary: Creates a new rotation transform value.
mRotation: An expression which evaluates to a number, the number of degrees of the rotation.
Returns: A new rotation transform.
Example:
// Create 30 degree rotation transform
variable tTransform
put transform with rotation by 30 into tTransform
Tags: Canvas
*/
syntax TransformMakeRotation is prefix operator with constructor precedence
"transform" "with" "rotation" "by" <mRotation: Expression>
begin
MCCanvasTransformMakeRotation(mRotation, output)
end syntax
/**
Summary: Creates a new translation transform.
mTranslation: An expression which evaluates to a list of 2 numbers, the x and y offsets of the translation.
Returns: A new translation transform.
Example:
// Create translation transform to offset coordinates by 50,100
variable tTransform
put transform with translation [50,100] into tTransform
Tags: Canvas
*/
syntax TransformMakeTranslation is prefix operator with constructor precedence
"transform" "with" "translation" <mTranslation: Expression>
begin
MCCanvasTransformMakeTranslationWithList(mTranslation, output)
end syntax
/**
Summary: Creates a new transform.
mTranslation: An expression which evaluates to a list of 6 numbers, the a, b, c, d, tx and ty values of the transform matrix.
Returns: A new translation transform.
Example:
// Create combined rotate, scale, and translate transform
variable tTransform
put transform with matrix [0, 2, -2, 0, 50, 100] into tTransform
Tags: Canvas
*/
syntax TransformMakeWithMatrixAsList is prefix operator with constructor precedence
"transform" "with" "matrix" <mMatrix: Expression>
begin
MCCanvasTransformMakeWithMatrixAsList(mMatrix, output)
end syntax
//////////
// Properties
public foreign handler MCCanvasTransformGetScaleAsList(in pTransform as Transform, out rScale as List) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformSetScaleAsList(in pScaleX as List, inout xTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformGetRotation(in pTransform as Transform, out rRotation as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformSetRotation(in pRotation as CanvasFloat, inout xTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformGetSkewAsList(in pTransform as Transform, out rSkew as List) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformSetSkewAsList(in pSkew as List, inout xTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformGetTranslationAsList(in pTransform as Transform, out rTranslation as List) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformSetTranslationAsList(in pTranslation as List, inout xTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformGetMatrixAsList(in pTransform as Transform, out rMatrix as List) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformSetMatrixAsList(in pMatrix as List, inout xTransform as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformGetInverse(in pTransform as Transform, out rInverse as Transform) returns nothing binds to "<builtin>"
/**
Summary: The scale component of a transform.
mTransform: An expression which evaluates to a transform.
Description: The scale of <mTransform> as a list of 2 numbers (the x and y scales)
Example:
variable tTransform
put transform with matrix [0, 2, -2, 0, 50, 100] into tTransform
// Store the old scale component
variable tScale
put the scale of tTransform into tScale
// Modify the scale by adding 1 to the x scale value
set the scale of tTransform to [element 1 of tScale + 1, element 2 of tScale]
Tags: Canvas
*/
syntax TransformPropertyScale is prefix operator with property precedence
"the" "scale" "of" <mTransform: Expression>
begin
MCCanvasTransformGetScaleAsList(mTransform, output)
MCCanvasTransformSetScaleAsList(input, mTransform)
end syntax
/**
Summary: The rotation component of a transform.
mTransform: An expression which evaluates to a transform.
Description: The rotation of <mTransform> as a number of degrees.
Example:
variable tTransform
put transform with matrix [0, 2, -2, 0, 50, 100] into tTransform
// Store the old rotation component
variable tRotation
put the rotation of tTransform into tRotation
// Double the rotation
set the rotation of tTransform to tRotation * 2
Tags: Canvas
*/
syntax TransformPropertyRotation is prefix operator with property precedence
"the" "rotation" "of" <mTransform: Expression>
begin
MCCanvasTransformGetRotation(mTransform, output)
MCCanvasTransformSetRotation(input, mTransform)
end syntax
/**
Summary: The skew component of a transform.
mTransform: An expression which evaluates to a transform.
Description: The skew of <mTransform> as a list of 2 numbers (the x and y skew values).
Example:
variable tTransform
put transform with matrix [0, 2, -2, 0, 50, 100] into tTransform
// Store the old skew component
variable tSkew
put the skew of tTransform into tSkew
// Remove the skew
set the skew of tTransform to [0,0]
Tags: Canvas
*/
syntax TransformPropertySkew is prefix operator with property precedence
"the" "skew" "of" <mTransform: Expression>
begin
MCCanvasTransformGetSkewAsList(mTransform, output)
MCCanvasTransformSetSkewAsList(input, mTransform)
end syntax
/**
Summary: The translation component of a transform.
mTransform: An expression which evaluates to a transform.
Description: The translation of <mTransform> as a list of 2 numbers (the x and y offset values).
Example:
variable tTransform
put transform with matrix [0, 2, -2, 0, 50, 100] into tTransform
// Store the old translation component
variable tTranslation
put the translation of tTransform into tTranslation
// Adjust the offset of the transformation
set the translation of tTransform to [element 1 of tTranslation + 5, element 2 of tTranslation + 5]
Tags: Canvas
*/
syntax TransformPropertyTranslation is prefix operator with property precedence
"the" "translation" "of" <mTransform: Expression>
begin
MCCanvasTransformGetTranslationAsList(mTransform, output)
MCCanvasTransformSetTranslationAsList(input, mTransform)
end syntax
/**
Summary: The matrix values of a transform.
mTransform: An expression which evaluates to a transform.
Description: The matrix values of <mTransform> as a list of 6 numbers.
Example:
variable tTransform
put transform with translation [20,50] into tTransform
// Get the current transform matrix
variable tMatrix
put the matrix of tTransform into tMatrix
// Directly set the components
put 2.5 into element 1 of tMatrix
put 0 into element 2 of tMatrix
put 0 into element 3 of tMatrix
put 2.5 into element 4 of tMatrix
// Update the transform with the new values
set the matrix of tTransform to tMatrix
Tags: Canvas
*/
syntax TransformPropertyMatrixAsList is prefix operator with property precedence
"the" "matrix" "of" <mTransform: Expression>
begin
MCCanvasTransformGetMatrixAsList(mTransform, output)
MCCanvasTransformSetMatrixAsList(input, mTransform)
end syntax
/**
Summary: The inverse of a transform.
mTransform: An expression which evaluates to a transform.
Description:
The inverse of <mTransform>
>*Note:* The inverse of a transform matrix is the transform that reverses the effect of the original. Combining a transform with its inverse will produce the identity transform.
Example:
variable tTransform
put transform with matrix [0,2,-2,0,50,100] into tTransform
// Get the inverse of the current transform
variable tInverse
put the inverse of tTransform into tInverse
// Combine the transform with its inverse to produce the identity transform
concat tTransform with tInverse
Tags: Canvas
*/
syntax TransformPropertyInverse is prefix operator with property precedence
"the" "inverse" "of" <mTransform: Expression>
begin
MCCanvasTransformGetInverse(mTransform, output)
end syntax
//////////
// Operations
public foreign handler MCCanvasTransformConcat(inout xTransformA as Transform, in pTransformB as Transform) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformScale(inout xTransform as Transform, in pScaleX as CanvasFloat, in pScaleY as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformScaleWithList(inout xTransform as Transform, in pScale as List) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformSkew(inout xTransform as Transform, in pSkewX as CanvasFloat, in pSkewY as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformSkewWithList(inout xTransform as Transform, in pSkew as List) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformRotate(inout xTransform as Transform, in pRotation as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformTranslate(inout xTransform as Transform, in pX as CanvasFloat, in pY as CanvasFloat) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformTranslateWithList(inout xTransform as Transform, in pTranslation as List) returns nothing binds to "<builtin>"
public foreign handler MCCanvasTransformMultiply(in pTransformA as Transform, in pTransformB as Transform, out rTransform as Transform) returns nothing binds to "<builtin>"
/**
Summary: Concatenate transform a with transform b.
mTransformA: An expression which evaluates to a transform.
mTransformB: An expression which evaluates to a transform.
Description:
Concatenating transforms modifies the original transform to produce a single transform that is the equivalent of applying the new transform followed by the original. Changing the order of concatenation will result in a transform with different effects.
Example:
// Create a new scaling transform
variable tScale
put transform with scale [5,10] into tScale
// Create a new rotation transform
variable tRotation
put transform with rotation by 30 into tRotation
variable tTransform
// Create a transform representing a rotation followed by a scale
put tScale into tTransform
concat tTransform with tRotation
// Create a transform representing a scale followed by a rotation
put tRotation into tTransform
concat tTransform with tScale
Tags: Canvas
*/
syntax TransformOperationConcat is statement
"concat" <mTransformA: Expression> "with" <mTransformB: Expression>
begin
MCCanvasTransformConcat(mTransformA, mTransformB)
end syntax
/**
Summary: Apply a scale to a transform.
mTransform: An expression which evaluates to a transform.
mScale: An expression which evaluates to a list of 1 or 2 numbers, the x-axis scale and y-axis scale, or the uniform scale when only a single value is given.
Description:
Apply the given scale to <mTransform>. This is equivalent to concatenating <mTransform> with a new scale transform.
Example:
// Create a new transform
variable tTransform
put the identity transform into tTransform
// Apply a uniform scale to the transform
scale tTransform by [0.5]
// Apply a non-uniform scale to the transform
scale tTransform by [2.2, 3]
Tags: Canvas
*/
syntax TransformOperationScale is statement
"scale" <mTransform: Expression> "by" <mScale: Expression>
begin
MCCanvasTransformScaleWithList(mTransform, mScale)
end syntax
/**
Summary: Apply a skew to a transform.
mTransform: An expression which evaluates to a transform.
mSkew: An expression which evaluates to a list of 2 numbers, the x-axis skew and y-axis skew.
Description:
Apply the given skew to <mTransform>
Example:
variable tTransform
// Create a new transform
put the identity transform into tTransform
// Apply a skew to the transform