├── .gitignore
├── Aelib.json
├── LICENSE
├── README.md
├── VEXpressions.txt
├── examples
├── BASE.hip
├── ae__AccumulationSolver.hip
├── ae__ActivationSolver.hip
├── ae__ArcCreator.hip
├── ae__Assignment.hip
├── ae__AttribChop.hip
├── ae__AttribContour.hip
├── ae__AttribFit.hip
├── ae__AttribPoint.hip
├── ae__AttribTransferByUV.hip
├── ae__AttributeClip.hip
├── ae__AxisTransform.hip
├── ae__BboxUtils.hip
├── ae__CameraCull.hip
├── ae__CameraHUD.hip
├── ae__Capsule.hip
├── ae__ChaoticAttractor.hip
├── ae__Clip.hip
├── ae__ColourCorrect.hip
├── ae__Connector.hip
├── ae__Containment.hip
├── ae__Contour.hip
├── ae__CubeSphere.hip
├── ae__CurveBlender.hip
├── ae__CurveCutter.hip
├── ae__CurveDuplicator.hip
├── ae__CurveOffset.hip
├── ae__CurveOrient.hip
├── ae__Curve_Boolean.hip
├── ae__Curve_Decimator.hip
├── ae__DartThrowerSolver.hip
├── ae__DeleteSmallPieces.hip
├── ae__Divide2D.hip
├── ae__EdgeDistance.hip
├── ae__ExtractEdgeByAttrib.hip
├── ae__FiveColourTheorem.hip
├── ae__HeightFieldInvertMask.hip
├── ae__HeightFieldSharpen.hip
├── ae__Helix.hip
├── ae__ID.hip
├── ae__Instance_To_Points.hip
├── ae__JohnsonSolid.hip
├── ae__Mandala.hip
├── ae__MatchSize.hip
├── ae__Merge_Assemble.hip
├── ae__MinimalSpanningTree.hip
├── ae__Neighbours.hip
├── ae__Orient.hip
├── ae__Palette_Manager_Base.hip
├── ae__ParametricCurve.hip
├── ae__PathRandomise.hip
├── ae__PatternMaster.hip
├── ae__PerPrimCarve.hip
├── ae__PhyllotacticSpiral.hip
├── ae__Plexus.hip
├── ae__Point_Deform.hip
├── ae__PointsAlongCurves.hip
├── ae__PointsFromVolume.hip
├── ae__Polarise.hip
├── ae__Polyhedron.hip
├── ae__PropagationSolver.hip
├── ae__QuadExtract.hip
├── ae__Quantize.hip
├── ae__Queue.hip
├── ae__QuickCurveUV.hip
├── ae__QuickDelete.hip
├── ae__QuickPointPreview.hip
├── ae__QuickSoftbox.hip
├── ae__QuickVisualiseFrame.hip
├── ae__RandomSpaceFiller.hip
├── ae__Ray.hip
├── ae__Reflector.hip
├── ae__Rotate4D.hip
├── ae__RoundCorners.hip
├── ae__SphereInversion.hip
├── ae__SphericalSpiral.hip
├── ae__SpringSolver.hip
├── ae__StereographicProjection.hip
├── ae__Subdividor.hip
├── ae__TemporalSmooth.hip
├── ae__Thicken.hip
├── ae__TravellingSalesman.hip
├── ae__UVCarve.hip
├── ae__UV_Jitter.hip
├── ae__Uniform_Streamlines.hip
├── ae__VDB_Rebuild_SDF.hip
├── ae__VectorVolumeVisualisation.hip
├── ae__VolumeRemap.hip
├── ae__VolumeScatter.hip
├── archive
│ ├── Creators.hip
│ ├── CurveTools.hip
│ ├── Deformers.hip
│ └── Utility.hip
└── create_examples.py
├── gallery
└── Aelib_SOP.gal
├── icons
├── ae_active.svg
├── ae_unstaged.svg
├── ae_wip.svg
├── aelib_logo.psd
└── patreon.svg
├── otls
├── ae__AccumulationSolver.hda
├── ae__ActivationSolver.hda
├── ae__Align_And_Center_Pieces.hda
├── ae__ArcCreator.hda
├── ae__Assignment.hda
├── ae__AttribChop.hda
├── ae__AttribContour.hda
├── ae__AttribFit.hda
├── ae__AttribPoint.hda
├── ae__AttribTransferByUV.hda
├── ae__Attrib_Adjust_Orient.hda
├── ae__AttributeClip.hda
├── ae__Automata_1D.hda
├── ae__AxisTransform.hda
├── ae__BboxUtils.hda
├── ae__CameraCull.hda
├── ae__CameraHUD.hda
├── ae__Capsule.hda
├── ae__ChaoticAttractor.hda
├── ae__Clip.hda
├── ae__ColourCorrect.hda
├── ae__Connector.hda
├── ae__Containment.hda
├── ae__CubeSphere.hda
├── ae__CurveBiasedResample.hda
├── ae__CurveBlender.hda
├── ae__CurveCutter.hda
├── ae__CurveDuplicator.hda
├── ae__CurveOffset.hda
├── ae__CurveOrient.hda
├── ae__Curve_Boolean.hda
├── ae__Curve_Decimator.hda
├── ae__DartThrowerSolver.hda
├── ae__DeleteSmallPieces.hda
├── ae__Divide2D.hda
├── ae__EdgeDistance.hda
├── ae__ExtractEdgeByAttrib.hda
├── ae__Fast_Clean_Up.hda
├── ae__FiveColourTheorem.hda
├── ae__HeightFieldFromVolume.hda
├── ae__HeightFieldInvertMask.hda
├── ae__HeightFieldSharpen.hda
├── ae__Helix.hda
├── ae__ImagePlane.hda
├── ae__Inflate.hda
├── ae__Instance_To_Points.hda
├── ae__JohnsonSolid.hda
├── ae__Mandala.hda
├── ae__MatchSize.hda
├── ae__MinimalSpanningTree.hda
├── ae__Neighbours.hda
├── ae__Orient.hda
├── ae__POP_Restoring_Force.hda
├── ae__Palette_Manager_Base.hda
├── ae__ParametricCurve.hda
├── ae__PathRandomise.hda
├── ae__PatternMaster.hda
├── ae__PerPrimCarve.hda
├── ae__PhyllotacticSpiral.hda
├── ae__Plexus.hda
├── ae__Point_Deform.hda
├── ae__Point_Overlap_Scale_Adjuster.hda
├── ae__PointsAlongCurves.hda
├── ae__PointsFromVolume.hda
├── ae__Polarise.hda
├── ae__Polyhedron.hda
├── ae__PropagationSolver.hda
├── ae__QuadExtract.hda
├── ae__Quantize.hda
├── ae__Queue.hda
├── ae__QuickCurveUV.hda
├── ae__QuickDelete.hda
├── ae__QuickPointPreview.hda
├── ae__QuickSoftbox.hda
├── ae__QuickVisualiseFrame.hda
├── ae__RandomSpaceFiller.hda
├── ae__Ray.hda
├── ae__Reflector.hda
├── ae__Rotate4D.hda
├── ae__RoundCorners.hda
├── ae__RoundToFloat.hda
├── ae__SVG_Export.hda
├── ae__SVG_Import.hda
├── ae__SphereInversion.hda
├── ae__Spheres_To_Points.hda
├── ae__SphericalSpiral.hda
├── ae__Split_Multi.hda
├── ae__SpringSolver.hda
├── ae__StereographicProjection.hda
├── ae__Subdividor.hda
├── ae__TemporalSmooth.hda
├── ae__Thicken.hda
├── ae__TravellingSalesman.hda
├── ae__UVCarve.hda
├── ae__UV_Jitter.hda
├── ae__Uniform_Streamlines.hda
├── ae__VDB_Rebuild_SDF.hda
├── ae__VectorVolumeVisualisation.hda
├── ae__VolumeRemap.hda
├── ae__VolumeScatter.hda
├── ae__Volume_Fade.hda
├── ae__id.hda
└── archive
│ ├── ae__AlembicPostImport.hda
│ ├── ae__AlembicPreExport.hda
│ ├── ae__CameraQuery.hda
│ ├── ae__Contour.hda
│ ├── ae__CurveMorph.hda
│ ├── ae__CurveOrient.hda
│ ├── ae__Curve_Frame.hda
│ ├── ae__FastSweep.hda
│ ├── ae__PairConnect.hda
│ ├── ae__RampManager.hda
│ └── ae__SDF_Fill_Interior.hda
├── python3.10libs
├── svg
│ ├── __init__.py
│ └── path
│ │ ├── __init__.py
│ │ ├── parser.py
│ │ └── path.py
└── tinycss
│ ├── __init__.py
│ ├── color3.py
│ ├── css21.py
│ ├── decoding.py
│ ├── fonts3.py
│ ├── page3.py
│ ├── parsing.py
│ ├── tests
│ ├── __init__.py
│ ├── speed.py
│ ├── test_api.py
│ ├── test_color3.py
│ ├── test_css21.py
│ ├── test_decoding.py
│ ├── test_fonts3.py
│ ├── test_page3.py
│ └── test_tokenizer.py
│ ├── token_data.py
│ ├── tokenizer.py
│ └── version.py
├── python3.11libs
├── svg
│ ├── __init__.py
│ └── path
│ │ ├── __init__.py
│ │ ├── parser.py
│ │ └── path.py
└── tinycss
│ ├── __init__.py
│ ├── color3.py
│ ├── css21.py
│ ├── decoding.py
│ ├── fonts3.py
│ ├── page3.py
│ ├── parsing.py
│ ├── tests
│ ├── __init__.py
│ ├── speed.py
│ ├── test_api.py
│ ├── test_color3.py
│ ├── test_css21.py
│ ├── test_decoding.py
│ ├── test_fonts3.py
│ ├── test_page3.py
│ └── test_tokenizer.py
│ ├── token_data.py
│ ├── tokenizer.py
│ └── version.py
├── python3.9libs
├── svg
│ ├── __init__.py
│ └── path
│ │ ├── __init__.py
│ │ ├── parser.py
│ │ └── path.py
└── tinycss
│ ├── __init__.py
│ ├── color3.py
│ ├── css21.py
│ ├── decoding.py
│ ├── fonts3.py
│ ├── page3.py
│ ├── parsing.py
│ ├── token_data.py
│ ├── tokenizer.py
│ └── version.py
├── scripts
└── python
│ ├── __init__.py
│ ├── ae_tools.py
│ └── atcq
│ ├── ATCQ_Widget.py
│ ├── __init__.py
│ ├── atcq_image.png
│ └── web
│ ├── css
│ ├── bootstrap.min.css
│ └── main.css
│ ├── dist
│ └── index.js
│ └── index.html
├── toolbar
└── aelib.shelf
└── vex
└── include
├── aevex.vfl
├── array2d.h
├── array3d.h
├── ease.vfl
└── subdiv.vfl
/.gitignore:
--------------------------------------------------------------------------------
1 | # backup dirs
2 | otls/backup
3 | gallery/backup
4 | examples/backup
5 | .vs
6 |
7 | # backup files
8 | *_bak*.hip
9 |
10 | .DS_Store
11 | .vs
12 | Thumbs.db
13 |
14 | # compiled python files
15 | *.pyc
--------------------------------------------------------------------------------
/Aelib.json:
--------------------------------------------------------------------------------
1 | {
2 | "env": [
3 | {
4 | "AELIB": "PATH/TO/aelib"
5 | }
6 | ],
7 | "path": [
8 | "$AELIB"
9 | ]
10 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Aelib
2 |
3 | 
4 |
5 | A library of Digital Assets, Tools and Scripts for SideFX Houdini.
6 |
7 | The /otls folder contains approximately 100 SOP level HDAs which are available from the 'aelib' Tab submenu. These are categorised into the following sections:
8 |
9 | - Creators: Geometry creation SOPs, usually not requiring input geometry
10 | - Deformer: Modify geometry positions
11 | - Modify: Involve creating or destroying points/primitives and require input geometry
12 | - Curves: A variety of tools acting on polyline curves
13 | - IO: Operations for reading or writing files to disk
14 | - Solvers: Simulations and feedback loops
15 | - Utility: General purpose tools and miscellaneous items
16 | - Extensions: Similar to existing Houdini or 3rd-Party SOPs but with extra functionality
17 |
18 | As well as the HDA collection, Aelib includes:
19 |
20 | - A shelf containing macros and useful python scripts
21 | - Several VEX include files adding a range of new functions
22 | - A VEXpressions.txt file which adds presets to wrangles
23 | - Bundled python libraries required for a small number of SOP nodes
24 |
25 | ## Usage
26 |
27 | The /examples directory contains hip files demonstrating usage of many of the Aelib SOPs. Each node also includes a help card detailing its inputs, parameters and behaviour. Many parameters include a rollover tooltip.
28 |
29 | ## Installation (Houdini Package)
30 |
31 | - Download and extract the repository and move it to any location
32 | - Create a folder called 'packages' in your Houdini home directory (e.g C:/Users/MY_USER/Documents/houdini18.0) if it does not exist already
33 | - Copy the Aelib.json file into the packages folder
34 | - Edit the json file to point to the Aelib parent directory (edit the "AELIB" line)
35 | - For more information on how package files work, see [HERE](https://www.sidefx.com/docs/houdini/ref/plugins.html)
36 |
37 | ## Other
38 |
39 | HDAs are periodically archived from the main library as they are superceded by new Aelib nodes or built-in Houdini nodes. These are kept in /otls/archive
40 |
41 | If you would like to support the development of Aelib you can subscribe on [Patreon](https://www.patreon.com/aeoll).
42 |
43 | Feedback and bug reports are always welcome!
44 |
45 | This library is been heavily inspired by [qLib](https://github.com/qLab/qLib).
46 |
47 | qLib is an incredible resource and I would highly recommended installing and exploring it.
48 |
--------------------------------------------------------------------------------
/VEXpressions.txt:
--------------------------------------------------------------------------------
1 | attribwrangle/snippet
2 | [ae] ae_include
3 | include
4 | //include
5 | // we should include a bunch of function examples here
6 | // or at least a list of all definitions
7 |
8 | attribwrangle/snippet
9 | [ae] Extract packed intrinsic transform and reapply
10 | // extract
11 | int id = point(0,"ptid", @primnum);
12 | matrix3 transform = primintrinsic(1, "transform", id);
13 | vector pivot = primintrinsic(1, "pivot", id);
14 | vector pos = point(1, "P", id);
15 |
16 | // reapply
17 | setprimintrinsic(0, "transform", id, transform, "set");
18 | setprimintrinsic(0, "pivot", id, pivot, "set");
19 | setpointattrib(0, "P", id, pos, "set");
20 | // can use packedfulltransform too?
21 |
22 | attribwrangle/snippet
23 | [ae] Extract packed intrinsic transform (cracktransform) and reapply
24 | // reconstruct transform
25 | matrix3 mytransform = primintrinsic(0, "transform", @primnum);
26 | vector t = cracktransform(XFORM_TRS, XFORM_XYZ, 0, set(0,0,0), mytransform);
27 | vector r = cracktransform(XFORM_TRS, XFORM_XYZ, 1, set(0,0,0), mytransform);
28 | vector s = cracktransform(XFORM_TRS, XFORM_XYZ, 2, set(0,0,0), mytransform);
29 |
30 | float ss = xnoise(0.5*@P);
31 | matrix newxf = maketransform(XFORM_TRS, XFORM_XYZ, t, r, set(ss,ss,ss));
32 | setprimintrinsic(0, "transform", @primnum, matrix3(newxf), "set");
33 |
34 | attribwrangle/snippet
35 | [ae] Scale Bullet objects
36 | // set this for geometry wrangle/pop wrangle and not attrib wrangle?
37 | // set the scale amount
38 | float scale_value = 1.0f;
39 | if(@Frame%40<20) {
40 | scale_value = fit(f@dist_from_center, 0, 1, 1.1, 1);
41 | }
42 | else {
43 | scale_value = fit(f@dist_from_center, 0, 1, 0.9, 1);
44 | }
45 | vector scale_amount = set(scale_value, scale_value, scale_value);
46 |
47 | // get the current transform from the intrinsics and apply the scale
48 | matrix3 m = primintrinsic(0, "transform", @primnum);
49 | matrix scalem = maketransform(0, 0, {0,0,0}, {0,0,0}, scale_amount, @P);
50 | m *= matrix3(scalem);
51 | setprimintrinsic(0, "transform", @primnum, m);
52 |
53 | // delete the id from the points to force the collision hull to regenerate
54 | int pts[] = primpoints(0,i@primnum);
55 | setpointattrib(0,"id",pts[0],-1);
56 |
57 | attribwrangle/snippet
58 | [ae] Edged Window Threshold
59 | // takes an attrib a in 0-1 range, an animation range and edge window size and transitions
60 | float a = 0.5*(1+sin(@P));
61 | int s = 0;
62 | int e = 100;
63 | float edge = 0.5;
64 | float t = fit(@Frame, s, e, 0 ,1);
65 | float t_max = fit(@Frame, s, e, 0, 1+edge);
66 | float t_min = fit(@Frame, s, e, -edge, 1);
67 | @Cd = fit(a, t_min, t_max, 0, 1);
68 |
69 | attribwrangle/snippet
70 | [ae] xyzdist-primuv or uvdist-primuv
71 | int prim;
72 | vector primuv;
73 | //float dist = xyzdist(1, @P, prim, primuv);
74 | float dist = uvdist(1, "uv", v@uv, prim, primuv);
75 | vector p = primuv(1, "P", prim, primuv);
76 |
77 | attribwrangle/snippet
78 | [ae] Rotate points about axis
79 | float a = @Time * @primnum * 20;
80 | vector4 q = quaternion(radians(a), set(0,1,0));
81 | vector cen = set(0);
82 | @P -= cen;
83 | @P = qrotate(q, @P);
84 | @P += cen;
85 |
86 | attribwrangle/snippet
87 | [ae] Nicks distribution
88 | float r = rand(@ptnum*555+888 + chi("sd"));
89 | float a = chf("scale")/ (chf("max_limit") + pow( fit01(r, 0, 1) , chf("pow") ));
90 |
91 | attribwrangle/snippet
92 | [ae] Modify Multiple Attributes
93 | string str = chs("attribs");
94 | string attrs[] = split(str);
95 | foreach(string s; attrs){
96 | if(haspointattrib(0, s) >= 0){
97 | vector v = point(0, s, @ptnum);
98 | // do something
99 | v = normalize(v)*0.5;
100 | setpointattrib(0, s, @ptnum, v);
101 | }
102 | }
103 |
104 | attribwrangle/snippet
105 | [ae][kinefx] Procedural Rotation
106 | vector axis = set(1,0,0);
107 | float angle = chf("amp")*pow(sin(@Time*chf("freq")), 3);
108 | // rotate!
109 | prerotate(4@localtransform, angle, axis);
110 |
111 | rigattribwrangle/snippet
112 | [ae][kinefx] Procedural Rotation 2
113 | vector axis = set(1,0,0);
114 | float angle = chf("amp")*pow(sin(@Time*chf("freq")), 3);
115 | // rotate!
116 | prerotate(4@localtransform, angle, axis);
--------------------------------------------------------------------------------
/examples/ae__AccumulationSolver.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AccumulationSolver.hip
--------------------------------------------------------------------------------
/examples/ae__ActivationSolver.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__ActivationSolver.hip
--------------------------------------------------------------------------------
/examples/ae__ArcCreator.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__ArcCreator.hip
--------------------------------------------------------------------------------
/examples/ae__Assignment.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Assignment.hip
--------------------------------------------------------------------------------
/examples/ae__AttribChop.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AttribChop.hip
--------------------------------------------------------------------------------
/examples/ae__AttribContour.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AttribContour.hip
--------------------------------------------------------------------------------
/examples/ae__AttribFit.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AttribFit.hip
--------------------------------------------------------------------------------
/examples/ae__AttribPoint.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AttribPoint.hip
--------------------------------------------------------------------------------
/examples/ae__AttribTransferByUV.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AttribTransferByUV.hip
--------------------------------------------------------------------------------
/examples/ae__AttributeClip.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AttributeClip.hip
--------------------------------------------------------------------------------
/examples/ae__AxisTransform.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__AxisTransform.hip
--------------------------------------------------------------------------------
/examples/ae__BboxUtils.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__BboxUtils.hip
--------------------------------------------------------------------------------
/examples/ae__CameraCull.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CameraCull.hip
--------------------------------------------------------------------------------
/examples/ae__CameraHUD.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CameraHUD.hip
--------------------------------------------------------------------------------
/examples/ae__Capsule.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Capsule.hip
--------------------------------------------------------------------------------
/examples/ae__ChaoticAttractor.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__ChaoticAttractor.hip
--------------------------------------------------------------------------------
/examples/ae__Clip.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Clip.hip
--------------------------------------------------------------------------------
/examples/ae__ColourCorrect.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__ColourCorrect.hip
--------------------------------------------------------------------------------
/examples/ae__Connector.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Connector.hip
--------------------------------------------------------------------------------
/examples/ae__Containment.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Containment.hip
--------------------------------------------------------------------------------
/examples/ae__Contour.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Contour.hip
--------------------------------------------------------------------------------
/examples/ae__CubeSphere.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CubeSphere.hip
--------------------------------------------------------------------------------
/examples/ae__CurveBlender.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CurveBlender.hip
--------------------------------------------------------------------------------
/examples/ae__CurveCutter.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CurveCutter.hip
--------------------------------------------------------------------------------
/examples/ae__CurveDuplicator.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CurveDuplicator.hip
--------------------------------------------------------------------------------
/examples/ae__CurveOffset.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CurveOffset.hip
--------------------------------------------------------------------------------
/examples/ae__CurveOrient.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__CurveOrient.hip
--------------------------------------------------------------------------------
/examples/ae__Curve_Boolean.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Curve_Boolean.hip
--------------------------------------------------------------------------------
/examples/ae__Curve_Decimator.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Curve_Decimator.hip
--------------------------------------------------------------------------------
/examples/ae__DartThrowerSolver.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__DartThrowerSolver.hip
--------------------------------------------------------------------------------
/examples/ae__DeleteSmallPieces.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__DeleteSmallPieces.hip
--------------------------------------------------------------------------------
/examples/ae__Divide2D.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Divide2D.hip
--------------------------------------------------------------------------------
/examples/ae__EdgeDistance.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__EdgeDistance.hip
--------------------------------------------------------------------------------
/examples/ae__ExtractEdgeByAttrib.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__ExtractEdgeByAttrib.hip
--------------------------------------------------------------------------------
/examples/ae__FiveColourTheorem.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__FiveColourTheorem.hip
--------------------------------------------------------------------------------
/examples/ae__HeightFieldInvertMask.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__HeightFieldInvertMask.hip
--------------------------------------------------------------------------------
/examples/ae__HeightFieldSharpen.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__HeightFieldSharpen.hip
--------------------------------------------------------------------------------
/examples/ae__Helix.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Helix.hip
--------------------------------------------------------------------------------
/examples/ae__ID.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__ID.hip
--------------------------------------------------------------------------------
/examples/ae__Instance_To_Points.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Instance_To_Points.hip
--------------------------------------------------------------------------------
/examples/ae__JohnsonSolid.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__JohnsonSolid.hip
--------------------------------------------------------------------------------
/examples/ae__Mandala.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Mandala.hip
--------------------------------------------------------------------------------
/examples/ae__MatchSize.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__MatchSize.hip
--------------------------------------------------------------------------------
/examples/ae__Merge_Assemble.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Merge_Assemble.hip
--------------------------------------------------------------------------------
/examples/ae__MinimalSpanningTree.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__MinimalSpanningTree.hip
--------------------------------------------------------------------------------
/examples/ae__Neighbours.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Neighbours.hip
--------------------------------------------------------------------------------
/examples/ae__Orient.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Orient.hip
--------------------------------------------------------------------------------
/examples/ae__Palette_Manager_Base.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Palette_Manager_Base.hip
--------------------------------------------------------------------------------
/examples/ae__ParametricCurve.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__ParametricCurve.hip
--------------------------------------------------------------------------------
/examples/ae__PathRandomise.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__PathRandomise.hip
--------------------------------------------------------------------------------
/examples/ae__PatternMaster.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__PatternMaster.hip
--------------------------------------------------------------------------------
/examples/ae__PerPrimCarve.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__PerPrimCarve.hip
--------------------------------------------------------------------------------
/examples/ae__PhyllotacticSpiral.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__PhyllotacticSpiral.hip
--------------------------------------------------------------------------------
/examples/ae__Plexus.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Plexus.hip
--------------------------------------------------------------------------------
/examples/ae__Point_Deform.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Point_Deform.hip
--------------------------------------------------------------------------------
/examples/ae__PointsAlongCurves.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__PointsAlongCurves.hip
--------------------------------------------------------------------------------
/examples/ae__PointsFromVolume.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__PointsFromVolume.hip
--------------------------------------------------------------------------------
/examples/ae__Polarise.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Polarise.hip
--------------------------------------------------------------------------------
/examples/ae__Polyhedron.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Polyhedron.hip
--------------------------------------------------------------------------------
/examples/ae__PropagationSolver.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__PropagationSolver.hip
--------------------------------------------------------------------------------
/examples/ae__QuadExtract.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__QuadExtract.hip
--------------------------------------------------------------------------------
/examples/ae__Quantize.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Quantize.hip
--------------------------------------------------------------------------------
/examples/ae__Queue.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Queue.hip
--------------------------------------------------------------------------------
/examples/ae__QuickCurveUV.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__QuickCurveUV.hip
--------------------------------------------------------------------------------
/examples/ae__QuickDelete.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__QuickDelete.hip
--------------------------------------------------------------------------------
/examples/ae__QuickPointPreview.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__QuickPointPreview.hip
--------------------------------------------------------------------------------
/examples/ae__QuickSoftbox.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__QuickSoftbox.hip
--------------------------------------------------------------------------------
/examples/ae__QuickVisualiseFrame.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__QuickVisualiseFrame.hip
--------------------------------------------------------------------------------
/examples/ae__RandomSpaceFiller.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__RandomSpaceFiller.hip
--------------------------------------------------------------------------------
/examples/ae__Ray.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Ray.hip
--------------------------------------------------------------------------------
/examples/ae__Reflector.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Reflector.hip
--------------------------------------------------------------------------------
/examples/ae__Rotate4D.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Rotate4D.hip
--------------------------------------------------------------------------------
/examples/ae__RoundCorners.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__RoundCorners.hip
--------------------------------------------------------------------------------
/examples/ae__SphereInversion.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__SphereInversion.hip
--------------------------------------------------------------------------------
/examples/ae__SphericalSpiral.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__SphericalSpiral.hip
--------------------------------------------------------------------------------
/examples/ae__SpringSolver.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__SpringSolver.hip
--------------------------------------------------------------------------------
/examples/ae__StereographicProjection.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__StereographicProjection.hip
--------------------------------------------------------------------------------
/examples/ae__Subdividor.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Subdividor.hip
--------------------------------------------------------------------------------
/examples/ae__TemporalSmooth.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__TemporalSmooth.hip
--------------------------------------------------------------------------------
/examples/ae__Thicken.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Thicken.hip
--------------------------------------------------------------------------------
/examples/ae__TravellingSalesman.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__TravellingSalesman.hip
--------------------------------------------------------------------------------
/examples/ae__UVCarve.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__UVCarve.hip
--------------------------------------------------------------------------------
/examples/ae__UV_Jitter.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__UV_Jitter.hip
--------------------------------------------------------------------------------
/examples/ae__Uniform_Streamlines.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__Uniform_Streamlines.hip
--------------------------------------------------------------------------------
/examples/ae__VDB_Rebuild_SDF.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__VDB_Rebuild_SDF.hip
--------------------------------------------------------------------------------
/examples/ae__VectorVolumeVisualisation.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__VectorVolumeVisualisation.hip
--------------------------------------------------------------------------------
/examples/ae__VolumeRemap.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__VolumeRemap.hip
--------------------------------------------------------------------------------
/examples/ae__VolumeScatter.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/ae__VolumeScatter.hip
--------------------------------------------------------------------------------
/examples/archive/Creators.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/archive/Creators.hip
--------------------------------------------------------------------------------
/examples/archive/CurveTools.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/archive/CurveTools.hip
--------------------------------------------------------------------------------
/examples/archive/Deformers.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/archive/Deformers.hip
--------------------------------------------------------------------------------
/examples/archive/Utility.hip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/examples/archive/Utility.hip
--------------------------------------------------------------------------------
/examples/create_examples.py:
--------------------------------------------------------------------------------
1 | from pathlib import Path
2 | import sys, os, shutil
3 |
4 | def create_hips():
5 | ROOT = Path(os.path.dirname(os.path.realpath(__file__))).parent
6 |
7 | hda_dir = ROOT.joinpath("otls")
8 | hdas = list(hda_dir.glob("*.hda"))
9 | template = ROOT.joinpath("examples/BASE.hip")
10 |
11 | for h in hdas:
12 | dst = ROOT.joinpath("examples")
13 | dst = dst.joinpath(h.stem + ".hip")
14 | if not os.path.exists(dst):
15 | shutil.copy(template, dst)
16 |
17 | create_hips()
18 |
--------------------------------------------------------------------------------
/gallery/Aelib_SOP.gal:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/gallery/Aelib_SOP.gal
--------------------------------------------------------------------------------
/icons/ae_active.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
32 |
--------------------------------------------------------------------------------
/icons/ae_unstaged.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
32 |
--------------------------------------------------------------------------------
/icons/ae_wip.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
32 |
--------------------------------------------------------------------------------
/icons/aelib_logo.psd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/icons/aelib_logo.psd
--------------------------------------------------------------------------------
/icons/patreon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/otls/ae__AccumulationSolver.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AccumulationSolver.hda
--------------------------------------------------------------------------------
/otls/ae__ActivationSolver.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__ActivationSolver.hda
--------------------------------------------------------------------------------
/otls/ae__Align_And_Center_Pieces.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Align_And_Center_Pieces.hda
--------------------------------------------------------------------------------
/otls/ae__ArcCreator.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__ArcCreator.hda
--------------------------------------------------------------------------------
/otls/ae__Assignment.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Assignment.hda
--------------------------------------------------------------------------------
/otls/ae__AttribChop.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AttribChop.hda
--------------------------------------------------------------------------------
/otls/ae__AttribContour.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AttribContour.hda
--------------------------------------------------------------------------------
/otls/ae__AttribFit.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AttribFit.hda
--------------------------------------------------------------------------------
/otls/ae__AttribPoint.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AttribPoint.hda
--------------------------------------------------------------------------------
/otls/ae__AttribTransferByUV.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AttribTransferByUV.hda
--------------------------------------------------------------------------------
/otls/ae__Attrib_Adjust_Orient.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Attrib_Adjust_Orient.hda
--------------------------------------------------------------------------------
/otls/ae__AttributeClip.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AttributeClip.hda
--------------------------------------------------------------------------------
/otls/ae__Automata_1D.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Automata_1D.hda
--------------------------------------------------------------------------------
/otls/ae__AxisTransform.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__AxisTransform.hda
--------------------------------------------------------------------------------
/otls/ae__BboxUtils.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__BboxUtils.hda
--------------------------------------------------------------------------------
/otls/ae__CameraCull.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CameraCull.hda
--------------------------------------------------------------------------------
/otls/ae__CameraHUD.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CameraHUD.hda
--------------------------------------------------------------------------------
/otls/ae__Capsule.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Capsule.hda
--------------------------------------------------------------------------------
/otls/ae__ChaoticAttractor.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__ChaoticAttractor.hda
--------------------------------------------------------------------------------
/otls/ae__Clip.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Clip.hda
--------------------------------------------------------------------------------
/otls/ae__ColourCorrect.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__ColourCorrect.hda
--------------------------------------------------------------------------------
/otls/ae__Connector.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Connector.hda
--------------------------------------------------------------------------------
/otls/ae__Containment.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Containment.hda
--------------------------------------------------------------------------------
/otls/ae__CubeSphere.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CubeSphere.hda
--------------------------------------------------------------------------------
/otls/ae__CurveBiasedResample.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CurveBiasedResample.hda
--------------------------------------------------------------------------------
/otls/ae__CurveBlender.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CurveBlender.hda
--------------------------------------------------------------------------------
/otls/ae__CurveCutter.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CurveCutter.hda
--------------------------------------------------------------------------------
/otls/ae__CurveDuplicator.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CurveDuplicator.hda
--------------------------------------------------------------------------------
/otls/ae__CurveOffset.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CurveOffset.hda
--------------------------------------------------------------------------------
/otls/ae__CurveOrient.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__CurveOrient.hda
--------------------------------------------------------------------------------
/otls/ae__Curve_Boolean.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Curve_Boolean.hda
--------------------------------------------------------------------------------
/otls/ae__Curve_Decimator.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Curve_Decimator.hda
--------------------------------------------------------------------------------
/otls/ae__DartThrowerSolver.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__DartThrowerSolver.hda
--------------------------------------------------------------------------------
/otls/ae__DeleteSmallPieces.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__DeleteSmallPieces.hda
--------------------------------------------------------------------------------
/otls/ae__Divide2D.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Divide2D.hda
--------------------------------------------------------------------------------
/otls/ae__EdgeDistance.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__EdgeDistance.hda
--------------------------------------------------------------------------------
/otls/ae__ExtractEdgeByAttrib.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__ExtractEdgeByAttrib.hda
--------------------------------------------------------------------------------
/otls/ae__Fast_Clean_Up.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Fast_Clean_Up.hda
--------------------------------------------------------------------------------
/otls/ae__FiveColourTheorem.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__FiveColourTheorem.hda
--------------------------------------------------------------------------------
/otls/ae__HeightFieldFromVolume.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__HeightFieldFromVolume.hda
--------------------------------------------------------------------------------
/otls/ae__HeightFieldInvertMask.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__HeightFieldInvertMask.hda
--------------------------------------------------------------------------------
/otls/ae__HeightFieldSharpen.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__HeightFieldSharpen.hda
--------------------------------------------------------------------------------
/otls/ae__Helix.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Helix.hda
--------------------------------------------------------------------------------
/otls/ae__ImagePlane.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__ImagePlane.hda
--------------------------------------------------------------------------------
/otls/ae__Inflate.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Inflate.hda
--------------------------------------------------------------------------------
/otls/ae__Instance_To_Points.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Instance_To_Points.hda
--------------------------------------------------------------------------------
/otls/ae__JohnsonSolid.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__JohnsonSolid.hda
--------------------------------------------------------------------------------
/otls/ae__Mandala.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Mandala.hda
--------------------------------------------------------------------------------
/otls/ae__MatchSize.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__MatchSize.hda
--------------------------------------------------------------------------------
/otls/ae__MinimalSpanningTree.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__MinimalSpanningTree.hda
--------------------------------------------------------------------------------
/otls/ae__Neighbours.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Neighbours.hda
--------------------------------------------------------------------------------
/otls/ae__Orient.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Orient.hda
--------------------------------------------------------------------------------
/otls/ae__POP_Restoring_Force.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__POP_Restoring_Force.hda
--------------------------------------------------------------------------------
/otls/ae__Palette_Manager_Base.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Palette_Manager_Base.hda
--------------------------------------------------------------------------------
/otls/ae__ParametricCurve.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__ParametricCurve.hda
--------------------------------------------------------------------------------
/otls/ae__PathRandomise.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__PathRandomise.hda
--------------------------------------------------------------------------------
/otls/ae__PatternMaster.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__PatternMaster.hda
--------------------------------------------------------------------------------
/otls/ae__PerPrimCarve.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__PerPrimCarve.hda
--------------------------------------------------------------------------------
/otls/ae__PhyllotacticSpiral.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__PhyllotacticSpiral.hda
--------------------------------------------------------------------------------
/otls/ae__Plexus.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Plexus.hda
--------------------------------------------------------------------------------
/otls/ae__Point_Deform.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Point_Deform.hda
--------------------------------------------------------------------------------
/otls/ae__Point_Overlap_Scale_Adjuster.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Point_Overlap_Scale_Adjuster.hda
--------------------------------------------------------------------------------
/otls/ae__PointsAlongCurves.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__PointsAlongCurves.hda
--------------------------------------------------------------------------------
/otls/ae__PointsFromVolume.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__PointsFromVolume.hda
--------------------------------------------------------------------------------
/otls/ae__Polarise.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Polarise.hda
--------------------------------------------------------------------------------
/otls/ae__Polyhedron.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Polyhedron.hda
--------------------------------------------------------------------------------
/otls/ae__PropagationSolver.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__PropagationSolver.hda
--------------------------------------------------------------------------------
/otls/ae__QuadExtract.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__QuadExtract.hda
--------------------------------------------------------------------------------
/otls/ae__Quantize.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Quantize.hda
--------------------------------------------------------------------------------
/otls/ae__Queue.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Queue.hda
--------------------------------------------------------------------------------
/otls/ae__QuickCurveUV.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__QuickCurveUV.hda
--------------------------------------------------------------------------------
/otls/ae__QuickDelete.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__QuickDelete.hda
--------------------------------------------------------------------------------
/otls/ae__QuickPointPreview.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__QuickPointPreview.hda
--------------------------------------------------------------------------------
/otls/ae__QuickSoftbox.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__QuickSoftbox.hda
--------------------------------------------------------------------------------
/otls/ae__QuickVisualiseFrame.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__QuickVisualiseFrame.hda
--------------------------------------------------------------------------------
/otls/ae__RandomSpaceFiller.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__RandomSpaceFiller.hda
--------------------------------------------------------------------------------
/otls/ae__Ray.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Ray.hda
--------------------------------------------------------------------------------
/otls/ae__Reflector.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Reflector.hda
--------------------------------------------------------------------------------
/otls/ae__Rotate4D.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Rotate4D.hda
--------------------------------------------------------------------------------
/otls/ae__RoundCorners.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__RoundCorners.hda
--------------------------------------------------------------------------------
/otls/ae__RoundToFloat.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__RoundToFloat.hda
--------------------------------------------------------------------------------
/otls/ae__SVG_Export.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__SVG_Export.hda
--------------------------------------------------------------------------------
/otls/ae__SVG_Import.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__SVG_Import.hda
--------------------------------------------------------------------------------
/otls/ae__SphereInversion.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__SphereInversion.hda
--------------------------------------------------------------------------------
/otls/ae__Spheres_To_Points.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Spheres_To_Points.hda
--------------------------------------------------------------------------------
/otls/ae__SphericalSpiral.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__SphericalSpiral.hda
--------------------------------------------------------------------------------
/otls/ae__Split_Multi.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Split_Multi.hda
--------------------------------------------------------------------------------
/otls/ae__SpringSolver.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__SpringSolver.hda
--------------------------------------------------------------------------------
/otls/ae__StereographicProjection.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__StereographicProjection.hda
--------------------------------------------------------------------------------
/otls/ae__Subdividor.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Subdividor.hda
--------------------------------------------------------------------------------
/otls/ae__TemporalSmooth.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__TemporalSmooth.hda
--------------------------------------------------------------------------------
/otls/ae__Thicken.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Thicken.hda
--------------------------------------------------------------------------------
/otls/ae__TravellingSalesman.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__TravellingSalesman.hda
--------------------------------------------------------------------------------
/otls/ae__UVCarve.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__UVCarve.hda
--------------------------------------------------------------------------------
/otls/ae__UV_Jitter.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__UV_Jitter.hda
--------------------------------------------------------------------------------
/otls/ae__Uniform_Streamlines.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Uniform_Streamlines.hda
--------------------------------------------------------------------------------
/otls/ae__VDB_Rebuild_SDF.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__VDB_Rebuild_SDF.hda
--------------------------------------------------------------------------------
/otls/ae__VectorVolumeVisualisation.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__VectorVolumeVisualisation.hda
--------------------------------------------------------------------------------
/otls/ae__VolumeRemap.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__VolumeRemap.hda
--------------------------------------------------------------------------------
/otls/ae__VolumeScatter.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__VolumeScatter.hda
--------------------------------------------------------------------------------
/otls/ae__Volume_Fade.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__Volume_Fade.hda
--------------------------------------------------------------------------------
/otls/ae__id.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/ae__id.hda
--------------------------------------------------------------------------------
/otls/archive/ae__AlembicPostImport.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__AlembicPostImport.hda
--------------------------------------------------------------------------------
/otls/archive/ae__AlembicPreExport.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__AlembicPreExport.hda
--------------------------------------------------------------------------------
/otls/archive/ae__CameraQuery.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__CameraQuery.hda
--------------------------------------------------------------------------------
/otls/archive/ae__Contour.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__Contour.hda
--------------------------------------------------------------------------------
/otls/archive/ae__CurveMorph.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__CurveMorph.hda
--------------------------------------------------------------------------------
/otls/archive/ae__CurveOrient.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__CurveOrient.hda
--------------------------------------------------------------------------------
/otls/archive/ae__Curve_Frame.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__Curve_Frame.hda
--------------------------------------------------------------------------------
/otls/archive/ae__FastSweep.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__FastSweep.hda
--------------------------------------------------------------------------------
/otls/archive/ae__PairConnect.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__PairConnect.hda
--------------------------------------------------------------------------------
/otls/archive/ae__RampManager.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__RampManager.hda
--------------------------------------------------------------------------------
/otls/archive/ae__SDF_Fill_Interior.hda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/otls/archive/ae__SDF_Fill_Interior.hda
--------------------------------------------------------------------------------
/python3.10libs/svg/__init__.py:
--------------------------------------------------------------------------------
1 | __path__ = __import__("pkgutil").extend_path(__path__, __name__)
2 |
--------------------------------------------------------------------------------
/python3.10libs/svg/path/__init__.py:
--------------------------------------------------------------------------------
1 | from .path import Path, Move, Line, Arc, Close # noqa: 401
2 | from .path import CubicBezier, QuadraticBezier # noqa: 401
3 | from .path import PathSegment, Linear, NonLinear # noqa: 401
4 | from .parser import parse_path # noqa: 401
5 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/__init__.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss
4 | -------
5 |
6 | A CSS parser, and nothing else.
7 |
8 | :copyright: (c) 2012 by Simon Sapin.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 |
12 | from .version import VERSION
13 |
14 | from .css21 import CSS21Parser
15 | from .page3 import CSSPage3Parser
16 | from .fonts3 import CSSFonts3Parser
17 |
18 |
19 | __version__ = VERSION
20 |
21 | PARSER_MODULES = {
22 | 'page3': CSSPage3Parser,
23 | 'fonts3': CSSFonts3Parser,
24 | }
25 |
26 |
27 | def make_parser(*features, **kwargs):
28 | """Make a parser object with the chosen features.
29 |
30 | :param features:
31 | Positional arguments are base classes the new parser class will extend.
32 | The string ``'page3'`` is accepted as short for
33 | :class:`~page3.CSSPage3Parser`.
34 | The string ``'fonts3'`` is accepted as short for
35 | :class:`~fonts3.CSSFonts3Parser`.
36 | :param kwargs:
37 | Keyword arguments are passed to the parser’s constructor.
38 | :returns:
39 | An instance of a new subclass of :class:`CSS21Parser`
40 |
41 | """
42 | if features:
43 | bases = tuple(PARSER_MODULES.get(f, f) for f in features)
44 | parser_class = type('CustomCSSParser', bases + (CSS21Parser,), {})
45 | else:
46 | parser_class = CSS21Parser
47 | return parser_class(**kwargs)
48 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/fonts3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.colors3
4 | ---------------
5 |
6 | Parser for CSS 3 Fonts syntax:
7 | https://www.w3.org/TR/css-fonts-3/
8 |
9 | Adds support for font-face and font-feature-values rules.
10 |
11 | :copyright: (c) 2016 by Kozea.
12 | :license: BSD, see LICENSE for more details.
13 | """
14 |
15 | from __future__ import division, unicode_literals
16 |
17 | from .css21 import CSS21Parser, ParseError
18 |
19 |
20 | class FontFaceRule(object):
21 | """A parsed at-rule for font faces.
22 |
23 | .. attribute:: at_keyword
24 |
25 | Always ``'@font-face'``.
26 |
27 | .. attribute:: declarations
28 |
29 | A list of :class:`~.css21.Declaration` objects.
30 |
31 | .. attribute:: line
32 |
33 | Source line where this was read.
34 |
35 | .. attribute:: column
36 |
37 | Source column where this was read.
38 |
39 | """
40 |
41 | def __init__(self, at_keyword, declarations, line, column):
42 | assert at_keyword == '@font-face'
43 | self.at_keyword = at_keyword
44 | self.declarations = declarations
45 | self.line = line
46 | self.column = column
47 |
48 |
49 | class FontFeatureValuesRule(object):
50 | """A parsed at-rule for font feature values.
51 |
52 | .. attribute:: at_keyword
53 |
54 | Always ``'@font-feature-values'``.
55 |
56 | .. attribute:: line
57 |
58 | Source line where this was read.
59 |
60 | .. attribute:: column
61 |
62 | Source column where this was read.
63 |
64 | .. attribute:: at_rules
65 |
66 | The list of parsed at-rules inside the @font-feature-values block, in
67 | source order.
68 |
69 | .. attribute:: family_names
70 |
71 | A list of strings representing font families.
72 |
73 | """
74 |
75 | def __init__(self, at_keyword, at_rules, family_names, line, column):
76 | assert at_keyword == '@font-feature-values'
77 | self.at_keyword = at_keyword
78 | self.family_names = family_names
79 | self.at_rules = at_rules
80 | self.line = line
81 | self.column = column
82 |
83 |
84 | class FontFeatureRule(object):
85 | """A parsed at-rule for font features.
86 |
87 | .. attribute:: at_keyword
88 |
89 | One of the 16 following strings:
90 |
91 | * ``@stylistic``
92 | * ``@styleset``
93 | * ``@character-variant``
94 | * ``@swash``
95 | * ``@ornaments``
96 | * ``@annotation``
97 |
98 | .. attribute:: declarations
99 |
100 | A list of :class:`~.css21.Declaration` objects.
101 |
102 | .. attribute:: line
103 |
104 | Source line where this was read.
105 |
106 | .. attribute:: column
107 |
108 | Source column where this was read.
109 |
110 | """
111 |
112 | def __init__(self, at_keyword, declarations, line, column):
113 | self.at_keyword = at_keyword
114 | self.declarations = declarations
115 | self.line = line
116 | self.column = column
117 |
118 |
119 | class CSSFonts3Parser(CSS21Parser):
120 | """Extend :class:`~.css21.CSS21Parser` for `CSS 3 Fonts`_ syntax.
121 |
122 | .. _CSS 3 Fonts: https://www.w3.org/TR/css-fonts-3/
123 |
124 | """
125 |
126 | FONT_FEATURE_VALUES_AT_KEYWORDS = [
127 | '@stylistic',
128 | '@styleset',
129 | '@character-variant',
130 | '@swash',
131 | '@ornaments',
132 | '@annotation',
133 | ]
134 |
135 | def parse_at_rule(self, rule, previous_rules, errors, context):
136 | if rule.at_keyword == '@font-face':
137 | if rule.head:
138 | raise ParseError(
139 | rule.head[0],
140 | 'unexpected {0} token in {1} rule header'.format(
141 | rule.head[0].type, rule.at_keyword))
142 | declarations, body_errors = self.parse_declaration_list(rule.body)
143 | errors.extend(body_errors)
144 | return FontFaceRule(
145 | rule.at_keyword, declarations, rule.line, rule.column)
146 | elif rule.at_keyword == '@font-feature-values':
147 | family_names = tuple(
148 | self.parse_font_feature_values_family_names(rule.head))
149 | at_rules, body_errors = (
150 | self.parse_rules(rule.body or [], '@font-feature-values'))
151 | errors.extend(body_errors)
152 | return FontFeatureValuesRule(
153 | rule.at_keyword, at_rules, family_names,
154 | rule.line, rule.column)
155 | elif rule.at_keyword in self.FONT_FEATURE_VALUES_AT_KEYWORDS:
156 | if context != '@font-feature-values':
157 | raise ParseError(
158 | rule, '{0} rule not allowed in {1}'.format(
159 | rule.at_keyword, context))
160 | declarations, body_errors = self.parse_declaration_list(rule.body)
161 | errors.extend(body_errors)
162 | return FontFeatureRule(
163 | rule.at_keyword, declarations, rule.line, rule.column)
164 | return super(CSSFonts3Parser, self).parse_at_rule(
165 | rule, previous_rules, errors, context)
166 |
167 | def parse_font_feature_values_family_names(self, tokens):
168 | """Parse an @font-feature-values selector.
169 |
170 | :param tokens:
171 | An iterable of token, typically from the ``head`` attribute of
172 | an unparsed :class:`AtRule`.
173 | :returns:
174 | A generator of strings representing font families.
175 | :raises:
176 | :class:`~.parsing.ParseError` on invalid selectors
177 |
178 | """
179 | family = ''
180 | current_string = False
181 | for token in tokens:
182 | if token.type == 'DELIM' and token.value == ',' and family:
183 | yield family
184 | family = ''
185 | current_string = False
186 | elif token.type == 'STRING' and not family and (
187 | current_string is False):
188 | family = token.value
189 | current_string = True
190 | elif token.type == 'IDENT' and not current_string:
191 | if family:
192 | family += ' '
193 | family += token.value
194 | elif token.type != 'S':
195 | family = ''
196 | break
197 | if family:
198 | yield family
199 | else:
200 | raise ParseError(token, 'invalid @font-feature-values selector')
201 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/page3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.page3
4 | ------------------
5 |
6 | Support for CSS 3 Paged Media syntax:
7 | http://dev.w3.org/csswg/css3-page/
8 |
9 | Adds support for named page selectors and margin rules.
10 |
11 | :copyright: (c) 2012 by Simon Sapin.
12 | :license: BSD, see LICENSE for more details.
13 | """
14 |
15 | from __future__ import division, unicode_literals
16 |
17 | from .css21 import CSS21Parser, ParseError
18 |
19 |
20 | class MarginRule(object):
21 | """A parsed at-rule for margin box.
22 |
23 | .. attribute:: at_keyword
24 |
25 | One of the 16 following strings:
26 |
27 | * ``@top-left-corner``
28 | * ``@top-left``
29 | * ``@top-center``
30 | * ``@top-right``
31 | * ``@top-right-corner``
32 | * ``@bottom-left-corner``
33 | * ``@bottom-left``
34 | * ``@bottom-center``
35 | * ``@bottom-right``
36 | * ``@bottom-right-corner``
37 | * ``@left-top``
38 | * ``@left-middle``
39 | * ``@left-bottom``
40 | * ``@right-top``
41 | * ``@right-middle``
42 | * ``@right-bottom``
43 |
44 | .. attribute:: declarations
45 |
46 | A list of :class:`~.css21.Declaration` objects.
47 |
48 | .. attribute:: line
49 |
50 | Source line where this was read.
51 |
52 | .. attribute:: column
53 |
54 | Source column where this was read.
55 |
56 | """
57 |
58 | def __init__(self, at_keyword, declarations, line, column):
59 | self.at_keyword = at_keyword
60 | self.declarations = declarations
61 | self.line = line
62 | self.column = column
63 |
64 |
65 | class CSSPage3Parser(CSS21Parser):
66 | """Extend :class:`~.css21.CSS21Parser` for `CSS 3 Paged Media`_ syntax.
67 |
68 | .. _CSS 3 Paged Media: http://dev.w3.org/csswg/css3-page/
69 |
70 | Compared to CSS 2.1, the ``at_rules`` and ``selector`` attributes of
71 | :class:`~.css21.PageRule` objects are modified:
72 |
73 | * ``at_rules`` is not always empty, it is a list of :class:`MarginRule`
74 | objects.
75 |
76 | * ``selector``, instead of a single string, is a tuple of the page name
77 | and the pseudo class. Each of these may be a ``None`` or a string.
78 |
79 | +--------------------------+------------------------+
80 | | CSS | Parsed selectors |
81 | +==========================+========================+
82 | | .. code-block:: css | .. code-block:: python |
83 | | | |
84 | | @page {} | (None, None) |
85 | | @page :first {} | (None, 'first') |
86 | | @page chapter {} | ('chapter', None) |
87 | | @page table:right {} | ('table', 'right') |
88 | +--------------------------+------------------------+
89 |
90 | """
91 |
92 | PAGE_MARGIN_AT_KEYWORDS = [
93 | '@top-left-corner',
94 | '@top-left',
95 | '@top-center',
96 | '@top-right',
97 | '@top-right-corner',
98 | '@bottom-left-corner',
99 | '@bottom-left',
100 | '@bottom-center',
101 | '@bottom-right',
102 | '@bottom-right-corner',
103 | '@left-top',
104 | '@left-middle',
105 | '@left-bottom',
106 | '@right-top',
107 | '@right-middle',
108 | '@right-bottom',
109 | ]
110 |
111 | def parse_at_rule(self, rule, previous_rules, errors, context):
112 | if rule.at_keyword in self.PAGE_MARGIN_AT_KEYWORDS:
113 | if context != '@page':
114 | raise ParseError(
115 | rule, '{0} rule not allowed in {1}'.format(
116 | rule.at_keyword, context))
117 | if rule.head:
118 | raise ParseError(
119 | rule.head[0],
120 | 'unexpected {0} token in {1} rule header'.format(
121 | rule.head[0].type, rule.at_keyword))
122 | declarations, body_errors = self.parse_declaration_list(rule.body)
123 | errors.extend(body_errors)
124 | return MarginRule(
125 | rule.at_keyword, declarations, rule.line, rule.column)
126 | return super(CSSPage3Parser, self).parse_at_rule(
127 | rule, previous_rules, errors, context)
128 |
129 | def parse_page_selector(self, head):
130 | """Parse an @page selector.
131 |
132 | :param head:
133 | The ``head`` attribute of an unparsed :class:`AtRule`.
134 | :returns:
135 | A page selector. For CSS 2.1, this is 'first', 'left', 'right'
136 | or None. 'blank' is added by GCPM.
137 | :raises:
138 | :class`~parsing.ParseError` on invalid selectors
139 |
140 | """
141 | if not head:
142 | return (None, None), (0, 0, 0)
143 | if head[0].type == 'IDENT':
144 | name = head.pop(0).value
145 | while head and head[0].type == 'S':
146 | head.pop(0)
147 | if not head:
148 | return (name, None), (1, 0, 0)
149 | name_specificity = (1,)
150 | else:
151 | name = None
152 | name_specificity = (0,)
153 | if (len(head) == 2 and head[0].type == ':' and
154 | head[1].type == 'IDENT'):
155 | pseudo_class = head[1].value
156 | specificity = {
157 | 'first': (1, 0), 'blank': (1, 0),
158 | 'left': (0, 1), 'right': (0, 1),
159 | }.get(pseudo_class)
160 | if specificity:
161 | return (name, pseudo_class), (name_specificity + specificity)
162 | raise ParseError(head[0], 'invalid @page selector')
163 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/parsing.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.parsing
4 | ---------------
5 |
6 | Utilities for parsing lists of tokens.
7 |
8 | :copyright: (c) 2012 by Simon Sapin.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 |
12 | from __future__ import unicode_literals
13 |
14 |
15 | # TODO: unit tests
16 |
17 | def split_on_comma(tokens):
18 | """Split a list of tokens on commas, ie ``,`` DELIM tokens.
19 |
20 | Only "top-level" comma tokens are splitting points, not commas inside a
21 | function or other :class:`ContainerToken`.
22 |
23 | :param tokens:
24 | An iterable of :class:`~.token_data.Token` or
25 | :class:`~.token_data.ContainerToken`.
26 | :returns:
27 | A list of lists of tokens
28 |
29 | """
30 | parts = []
31 | this_part = []
32 | for token in tokens:
33 | if token.type == 'DELIM' and token.value == ',':
34 | parts.append(this_part)
35 | this_part = []
36 | else:
37 | this_part.append(token)
38 | parts.append(this_part)
39 | return parts
40 |
41 |
42 | def strip_whitespace(tokens):
43 | """Remove whitespace at the beggining and end of a token list.
44 |
45 | Whitespace tokens in-between other tokens in the list are preserved.
46 |
47 | :param tokens:
48 | A list of :class:`~.token_data.Token` or
49 | :class:`~.token_data.ContainerToken`.
50 | :return:
51 | A new sub-sequence of the list.
52 |
53 | """
54 | for i, token in enumerate(tokens):
55 | if token.type != 'S':
56 | break
57 | else:
58 | return [] # only whitespace
59 | tokens = tokens[i:]
60 | while tokens and tokens[-1].type == 'S':
61 | tokens.pop()
62 | return tokens
63 |
64 |
65 | def remove_whitespace(tokens):
66 | """Remove any top-level whitespace in a token list.
67 |
68 | Whitespace tokens inside recursive :class:`~.token_data.ContainerToken`
69 | are preserved.
70 |
71 | :param tokens:
72 | A list of :class:`~.token_data.Token` or
73 | :class:`~.token_data.ContainerToken`.
74 | :return:
75 | A new sub-sequence of the list.
76 |
77 | """
78 | return [token for token in tokens if token.type != 'S']
79 |
80 |
81 | def validate_value(tokens):
82 | """Validate a property value.
83 |
84 | :param tokens:
85 | an iterable of tokens
86 | :raises:
87 | :class:`ParseError` if there is any invalid token for the 'value'
88 | production of the core grammar.
89 |
90 | """
91 | for token in tokens:
92 | type_ = token.type
93 | if type_ == '{':
94 | validate_block(token.content, 'property value')
95 | else:
96 | validate_any(token, 'property value')
97 |
98 |
99 | def validate_block(tokens, context):
100 | """
101 | :raises:
102 | :class:`ParseError` if there is any invalid token for the 'block'
103 | production of the core grammar.
104 | :param tokens: an iterable of tokens
105 | :param context: a string for the 'unexpected in ...' message
106 |
107 | """
108 | for token in tokens:
109 | type_ = token.type
110 | if type_ == '{':
111 | validate_block(token.content, context)
112 | elif type_ not in (';', 'ATKEYWORD'):
113 | validate_any(token, context)
114 |
115 |
116 | def validate_any(token, context):
117 | """
118 | :raises:
119 | :class:`ParseError` if this is an invalid token for the
120 | 'any' production of the core grammar.
121 | :param token: a single token
122 | :param context: a string for the 'unexpected in ...' message
123 |
124 | """
125 | type_ = token.type
126 | if type_ in ('FUNCTION', '(', '['):
127 | for token in token.content:
128 | validate_any(token, type_)
129 | elif type_ not in ('S', 'IDENT', 'DIMENSION', 'PERCENTAGE', 'NUMBER',
130 | 'INTEGER', 'URI', 'DELIM', 'STRING', 'HASH', ':',
131 | 'UNICODE-RANGE'):
132 | if type_ in ('}', ')', ']'):
133 | adjective = 'unmatched'
134 | else:
135 | adjective = 'unexpected'
136 | raise ParseError(
137 | token, '{0} {1} token in {2}'.format(adjective, type_, context))
138 |
139 |
140 | class ParseError(ValueError):
141 | """Details about a CSS syntax error. Usually indicates that something
142 | (a rule or a declaration) was ignored and will not appear as a parsed
143 | object.
144 |
145 | This exception is typically logged in a list rather than being propagated
146 | to the user API.
147 |
148 | .. attribute:: line
149 |
150 | Source line where the error occured.
151 |
152 | .. attribute:: column
153 |
154 | Column in the source line where the error occured.
155 |
156 | .. attribute:: reason
157 |
158 | What happend (a string).
159 |
160 | """
161 | def __init__(self, subject, reason):
162 | self.line = subject.line
163 | self.column = subject.column
164 | self.reason = reason
165 | super(ParseError, self).__init__(
166 | 'Parse error at {0.line}:{0.column}, {0.reason}'.format(self))
167 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/tests/__init__.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Test suite for tinycss
4 | ----------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import sys
14 |
15 |
16 | # Awful workaround to fix isort's "sys.setdefaultencoding('utf-8')".
17 | if sys.version_info[0] == 2:
18 | reload(sys) # noqa
19 | sys.setdefaultencoding('ascii')
20 |
21 |
22 | def assert_errors(errors, expected_errors):
23 | """Test not complete error messages but only substrings."""
24 | assert len(errors) == len(expected_errors)
25 | for error, expected in zip(errors, expected_errors):
26 | assert expected in str(error)
27 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/tests/speed.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Speed tests
4 | -----------
5 |
6 | Note: this file is not named test_*.py as it is not part of the
7 | test suite ran by pytest.
8 |
9 | :copyright: (c) 2012 by Simon Sapin.
10 | :license: BSD, see LICENSE for more details.
11 | """
12 |
13 |
14 | from __future__ import division, unicode_literals
15 |
16 | import contextlib
17 | import functools
18 | import os.path
19 | import sys
20 | import timeit
21 |
22 | from cssutils import parseString
23 |
24 | from .. import tokenizer
25 | from ..css21 import CSS21Parser
26 | from ..parsing import remove_whitespace
27 |
28 | CSS_REPEAT = 4
29 | TIMEIT_REPEAT = 3
30 | TIMEIT_NUMBER = 20
31 |
32 |
33 | def load_css():
34 | filename = os.path.join(os.path.dirname(__file__),
35 | '..', '..', 'docs', '_static', 'custom.css')
36 | with open(filename, 'rb') as fd:
37 | return b'\n'.join([fd.read()] * CSS_REPEAT)
38 |
39 |
40 | # Pre-load so that I/O is not measured
41 | CSS = load_css()
42 |
43 |
44 | @contextlib.contextmanager
45 | def install_tokenizer(name):
46 | original = tokenizer.tokenize_flat
47 | try:
48 | tokenizer.tokenize_flat = getattr(tokenizer, name)
49 | yield
50 | finally:
51 | tokenizer.tokenize_flat = original
52 |
53 |
54 | def parse(tokenizer_name):
55 | with install_tokenizer(tokenizer_name):
56 | stylesheet = CSS21Parser().parse_stylesheet_bytes(CSS)
57 | result = []
58 | for rule in stylesheet.rules:
59 | selector = rule.selector.as_css()
60 | declarations = [
61 | (declaration.name, len(list(remove_whitespace(declaration.value))))
62 | for declaration in rule.declarations]
63 | result.append((selector, declarations))
64 | return result
65 |
66 | parse_cython = functools.partial(parse, 'cython_tokenize_flat')
67 | parse_python = functools.partial(parse, 'python_tokenize_flat')
68 |
69 |
70 | def parse_cssutils():
71 | stylesheet = parseString(CSS)
72 | result = []
73 | for rule in stylesheet.cssRules:
74 | selector = rule.selectorText
75 | declarations = [
76 | (declaration.name, len(list(declaration.propertyValue)))
77 | for declaration in rule.style.getProperties(all=True)]
78 | result.append((selector, declarations))
79 | return result
80 |
81 |
82 | def check_consistency():
83 | result = parse_python()
84 | assert len(result) > 0
85 | if tokenizer.cython_tokenize_flat:
86 | assert parse_cython() == result
87 | assert parse_cssutils() == result
88 | version = '.'.join(map(str, sys.version_info[:3]))
89 | print('Python {}, consistency OK.'.format(version))
90 |
91 |
92 | def warm_up():
93 | is_pypy = hasattr(sys, 'pypy_translation_info')
94 | if is_pypy:
95 | print('Warming up for PyPy...')
96 | for i in range(80):
97 | for i in range(10):
98 | parse_python()
99 | parse_cssutils()
100 | sys.stdout.write('.')
101 | sys.stdout.flush()
102 | sys.stdout.write('\n')
103 |
104 |
105 | def time(function):
106 | seconds = timeit.Timer(function).repeat(TIMEIT_REPEAT, TIMEIT_NUMBER)
107 | miliseconds = int(min(seconds) * 1000)
108 | return miliseconds
109 |
110 |
111 | def run():
112 | if tokenizer.cython_tokenize_flat:
113 | data_set = [
114 | ('tinycss + speedups ', parse_cython),
115 | ]
116 | else:
117 | print('Speedups are NOT available.')
118 | data_set = []
119 | data_set += [
120 | ('tinycss WITHOUT speedups', parse_python),
121 | ('cssutils ', parse_cssutils),
122 | ]
123 | label, function = data_set.pop(0)
124 | ref = time(function)
125 | print('{} {} ms'.format(label, ref))
126 | for label, function in data_set:
127 | result = time(function)
128 | print('{} {} ms {:.2f}x'.format(label, result, result / ref))
129 |
130 |
131 | if __name__ == '__main__':
132 | check_consistency()
133 | warm_up()
134 | run()
135 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/tests/test_api.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for the public API
4 | ------------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | from pytest import raises
14 | from tinycss import make_parser
15 | from tinycss.page3 import CSSPage3Parser
16 |
17 |
18 | def test_make_parser():
19 | class MyParser(object):
20 | def __init__(self, some_config):
21 | self.some_config = some_config
22 |
23 | parsers = [
24 | make_parser(),
25 | make_parser('page3'),
26 | make_parser(CSSPage3Parser),
27 | make_parser(MyParser, some_config=42),
28 | make_parser(CSSPage3Parser, MyParser, some_config=42),
29 | make_parser(MyParser, 'page3', some_config=42),
30 | ]
31 |
32 | for parser, exp in zip(parsers, [False, True, True, False, True, True]):
33 | assert isinstance(parser, CSSPage3Parser) == exp
34 |
35 | for parser, exp in zip(parsers, [False, False, False, True, True, True]):
36 | assert isinstance(parser, MyParser) == exp
37 |
38 | for parser in parsers[3:]:
39 | assert parser.some_config == 42
40 |
41 | # Extra or missing named parameters
42 | raises(TypeError, make_parser, some_config=4)
43 | raises(TypeError, make_parser, 'page3', some_config=4)
44 | raises(TypeError, make_parser, MyParser)
45 | raises(TypeError, make_parser, MyParser, some_config=4, other_config=7)
46 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/tests/test_color3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for the CSS 3 color parser
4 | --------------------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import pytest
14 | from tinycss.color3 import hsl_to_rgb, parse_color_string
15 |
16 |
17 | @pytest.mark.parametrize(('css_source', 'expected_result'), [
18 | ('', None),
19 | (' /* hey */\n', None),
20 | ('4', None),
21 | ('top', None),
22 | ('/**/transparent', (0, 0, 0, 0)),
23 | ('transparent', (0, 0, 0, 0)),
24 | (' transparent\n', (0, 0, 0, 0)),
25 | ('TransParent', (0, 0, 0, 0)),
26 | ('currentColor', 'currentColor'),
27 | ('CURRENTcolor', 'currentColor'),
28 | ('current_Color', None),
29 |
30 | ('black', (0, 0, 0, 1)),
31 | ('white', (1, 1, 1, 1)),
32 | ('fuchsia', (1, 0, 1, 1)),
33 | ('cyan', (0, 1, 1, 1)),
34 | ('CyAn', (0, 1, 1, 1)),
35 | ('darkkhaki', (189 / 255., 183 / 255., 107 / 255., 1)),
36 |
37 | ('#', None),
38 | ('#f', None),
39 | ('#ff', None),
40 | ('#fff', (1, 1, 1, 1)),
41 | ('#ffg', None),
42 | ('#ffff', None),
43 | ('#fffff', None),
44 | ('#ffffff', (1, 1, 1, 1)),
45 | ('#fffffg', None),
46 | ('#fffffff', None),
47 | ('#ffffffff', None),
48 | ('#fffffffff', None),
49 |
50 | ('#cba987', (203 / 255., 169 / 255., 135 / 255., 1)),
51 | ('#CbA987', (203 / 255., 169 / 255., 135 / 255., 1)),
52 | ('#1122aA', (17 / 255., 34 / 255., 170 / 255., 1)),
53 | ('#12a', (17 / 255., 34 / 255., 170 / 255., 1)),
54 |
55 | ('rgb(203, 169, 135)', (203 / 255., 169 / 255., 135 / 255., 1)),
56 | ('RGB(255, 255, 255)', (1, 1, 1, 1)),
57 | ('rgB(0, 0, 0)', (0, 0, 0, 1)),
58 | ('rgB(0, 51, 255)', (0, .2, 1, 1)),
59 | ('rgb(0,51,255)', (0, .2, 1, 1)),
60 | ('rgb(0\t, 51 ,255)', (0, .2, 1, 1)),
61 | ('rgb(/* R */0, /* G */51, /* B */255)', (0, .2, 1, 1)),
62 | ('rgb(-51, 306, 0)', (-.2, 1.2, 0, 1)), # out of 0..1 is allowed
63 |
64 | ('rgb(42%, 3%, 50%)', (.42, .03, .5, 1)),
65 | ('RGB(100%, 100%, 100%)', (1, 1, 1, 1)),
66 | ('rgB(0%, 0%, 0%)', (0, 0, 0, 1)),
67 | ('rgB(10%, 20%, 30%)', (.1, .2, .3, 1)),
68 | ('rgb(10%,20%,30%)', (.1, .2, .3, 1)),
69 | ('rgb(10%\t, 20% ,30%)', (.1, .2, .3, 1)),
70 | ('rgb(/* R */10%, /* G */20%, /* B */30%)', (.1, .2, .3, 1)),
71 | ('rgb(-12%, 110%, 1400%)', (-.12, 1.1, 14, 1)), # out of 0..1 is allowed
72 |
73 | ('rgb(10%, 50%, 0)', None),
74 | ('rgb(255, 50%, 0%)', None),
75 | ('rgb(0, 0 0)', None),
76 | ('rgb(0, 0, 0deg)', None),
77 | ('rgb(0, 0, light)', None),
78 | ('rgb()', None),
79 | ('rgb(0)', None),
80 | ('rgb(0, 0)', None),
81 | ('rgb(0, 0, 0, 0)', None),
82 | ('rgb(0%)', None),
83 | ('rgb(0%, 0%)', None),
84 | ('rgb(0%, 0%, 0%, 0%)', None),
85 | ('rgb(0%, 0%, 0%, 0)', None),
86 |
87 | ('rgba(0, 0, 0, 0)', (0, 0, 0, 0)),
88 | ('rgba(203, 169, 135, 0.3)', (203 / 255., 169 / 255., 135 / 255., 0.3)),
89 | ('RGBA(255, 255, 255, 0)', (1, 1, 1, 0)),
90 | ('rgBA(0, 51, 255, 1)', (0, 0.2, 1, 1)),
91 | ('rgba(0, 51, 255, 1.1)', (0, 0.2, 1, 1)),
92 | ('rgba(0, 51, 255, 37)', (0, 0.2, 1, 1)),
93 | ('rgba(0, 51, 255, 0.42)', (0, 0.2, 1, 0.42)),
94 | ('rgba(0, 51, 255, 0)', (0, 0.2, 1, 0)),
95 | ('rgba(0, 51, 255, -0.1)', (0, 0.2, 1, 0)),
96 | ('rgba(0, 51, 255, -139)', (0, 0.2, 1, 0)),
97 |
98 | ('rgba(42%, 3%, 50%, 0.3)', (.42, .03, .5, 0.3)),
99 | ('RGBA(100%, 100%, 100%, 0)', (1, 1, 1, 0)),
100 | ('rgBA(0%, 20%, 100%, 1)', (0, 0.2, 1, 1)),
101 | ('rgba(0%, 20%, 100%, 1.1)', (0, 0.2, 1, 1)),
102 | ('rgba(0%, 20%, 100%, 37)', (0, 0.2, 1, 1)),
103 | ('rgba(0%, 20%, 100%, 0.42)', (0, 0.2, 1, 0.42)),
104 | ('rgba(0%, 20%, 100%, 0)', (0, 0.2, 1, 0)),
105 | ('rgba(0%, 20%, 100%, -0.1)', (0, 0.2, 1, 0)),
106 | ('rgba(0%, 20%, 100%, -139)', (0, 0.2, 1, 0)),
107 |
108 | ('rgba(255, 255, 255, 0%)', None),
109 | ('rgba(10%, 50%, 0, 1)', None),
110 | ('rgba(255, 50%, 0%, 1)', None),
111 | ('rgba(0, 0, 0 0)', None),
112 | ('rgba(0, 0, 0, 0deg)', None),
113 | ('rgba(0, 0, 0, light)', None),
114 | ('rgba()', None),
115 | ('rgba(0)', None),
116 | ('rgba(0, 0, 0)', None),
117 | ('rgba(0, 0, 0, 0, 0)', None),
118 | ('rgba(0%)', None),
119 | ('rgba(0%, 0%)', None),
120 | ('rgba(0%, 0%, 0%)', None),
121 | ('rgba(0%, 0%, 0%, 0%)', None),
122 | ('rgba(0%, 0%, 0%, 0%, 0%)', None),
123 |
124 | ('HSL(0, 0%, 0%)', (0, 0, 0, 1)),
125 | ('hsL(0, 100%, 50%)', (1, 0, 0, 1)),
126 | ('hsl(60, 100%, 37.5%)', (0.75, 0.75, 0, 1)),
127 | ('hsl(780, 100%, 37.5%)', (0.75, 0.75, 0, 1)),
128 | ('hsl(-300, 100%, 37.5%)', (0.75, 0.75, 0, 1)),
129 | ('hsl(300, 50%, 50%)', (0.75, 0.25, 0.75, 1)),
130 |
131 | ('hsl(10, 50%, 0)', None),
132 | ('hsl(50%, 50%, 0%)', None),
133 | ('hsl(0, 0% 0%)', None),
134 | ('hsl(30deg, 100%, 100%)', None),
135 | ('hsl(0, 0%, light)', None),
136 | ('hsl()', None),
137 | ('hsl(0)', None),
138 | ('hsl(0, 0%)', None),
139 | ('hsl(0, 0%, 0%, 0%)', None),
140 |
141 | ('HSLA(-300, 100%, 37.5%, 1)', (0.75, 0.75, 0, 1)),
142 | ('hsLA(-300, 100%, 37.5%, 12)', (0.75, 0.75, 0, 1)),
143 | ('hsla(-300, 100%, 37.5%, 0.2)', (0.75, 0.75, 0, .2)),
144 | ('hsla(-300, 100%, 37.5%, 0)', (0.75, 0.75, 0, 0)),
145 | ('hsla(-300, 100%, 37.5%, -3)', (0.75, 0.75, 0, 0)),
146 |
147 | ('hsla(10, 50%, 0, 1)', None),
148 | ('hsla(50%, 50%, 0%, 1)', None),
149 | ('hsla(0, 0% 0%, 1)', None),
150 | ('hsla(30deg, 100%, 100%, 1)', None),
151 | ('hsla(0, 0%, light, 1)', None),
152 | ('hsla()', None),
153 | ('hsla(0)', None),
154 | ('hsla(0, 0%)', None),
155 | ('hsla(0, 0%, 0%, 50%)', None),
156 | ('hsla(0, 0%, 0%, 1, 0%)', None),
157 |
158 | ('cmyk(0, 0, 0, 0)', None),
159 | ])
160 | def test_color(css_source, expected_result):
161 | result = parse_color_string(css_source)
162 | if isinstance(result, tuple):
163 | for got, expected in zip(result, expected_result):
164 | # Compensate for floating point errors:
165 | assert abs(got - expected) < 1e-10
166 | for i, attr in enumerate(['red', 'green', 'blue', 'alpha']):
167 | assert getattr(result, attr) == result[i]
168 | else:
169 | assert result == expected_result
170 |
171 |
172 | @pytest.mark.parametrize(('hsl', 'expected_rgb'), [
173 | # http://en.wikipedia.org/wiki/HSL_and_HSV#Examples
174 | ((0, 0, 100 ), (1, 1, 1 )), # noqa
175 | ((127, 0, 100 ), (1, 1, 1 )), # noqa
176 | ((0, 0, 50 ), (0.5, 0.5, 0.5 )), # noqa
177 | ((127, 0, 50 ), (0.5, 0.5, 0.5 )), # noqa
178 | ((0, 0, 0 ), (0, 0, 0 )), # noqa
179 | ((127, 0, 0 ), (0, 0, 0 )), # noqa
180 | ((0, 100, 50 ), (1, 0, 0 )), # noqa
181 | ((60, 100, 37.5), (0.75, 0.75, 0 )), # noqa
182 | ((780, 100, 37.5), (0.75, 0.75, 0 )), # noqa
183 | ((-300, 100, 37.5), (0.75, 0.75, 0 )), # noqa
184 | ((120, 100, 25 ), (0, 0.5, 0 )), # noqa
185 | ((180, 100, 75 ), (0.5, 1, 1 )), # noqa
186 | ((240, 100, 75 ), (0.5, 0.5, 1 )), # noqa
187 | ((300, 50, 50 ), (0.75, 0.25, 0.75 )), # noqa
188 | ((61.8, 63.8, 39.3), (0.628, 0.643, 0.142)), # noqa
189 | ((251.1, 83.2, 51.1), (0.255, 0.104, 0.918)), # noqa
190 | ((134.9, 70.7, 39.6), (0.116, 0.675, 0.255)), # noqa
191 | ((49.5, 89.3, 49.7), (0.941, 0.785, 0.053)), # noqa
192 | ((283.7, 77.5, 54.2), (0.704, 0.187, 0.897)), # noqa
193 | ((14.3, 81.7, 62.4), (0.931, 0.463, 0.316)), # noqa
194 | ((56.9, 99.1, 76.5), (0.998, 0.974, 0.532)), # noqa
195 | ((162.4, 77.9, 44.7), (0.099, 0.795, 0.591)), # noqa
196 | ((248.3, 60.1, 37.3), (0.211, 0.149, 0.597)), # noqa
197 | ((240.5, 29, 60.7), (0.495, 0.493, 0.721)), # noqa
198 | ])
199 | def test_hsl(hsl, expected_rgb):
200 | for got, expected in zip(hsl_to_rgb(*hsl), expected_rgb):
201 | # Compensate for floating point errors and Wikipedia’s rounding:
202 | assert abs(got - expected) < 0.001
203 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/tests/test_decoding.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for decoding bytes to Unicode
4 | -----------------------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import pytest
14 | from tinycss.decoding import decode
15 |
16 |
17 | def params(css, encoding, use_bom=False, expect_error=False, **kwargs):
18 | """Nicer syntax to make a tuple."""
19 | return css, encoding, use_bom, expect_error, kwargs
20 |
21 |
22 | @pytest.mark.parametrize(('css', 'encoding', 'use_bom', 'expect_error',
23 | 'kwargs'), [
24 | params('', 'utf8'), # default to utf8
25 | params('𐂃', 'utf8'),
26 | params('é', 'latin1'), # utf8 fails, fall back on ShiftJIS
27 | params('£', 'ShiftJIS', expect_error=True),
28 | params('£', 'ShiftJIS', protocol_encoding='Shift-JIS'),
29 | params('£', 'ShiftJIS', linking_encoding='Shift-JIS'),
30 | params('£', 'ShiftJIS', document_encoding='Shift-JIS'),
31 | params('£', 'ShiftJIS', protocol_encoding='utf8',
32 | document_encoding='ShiftJIS'),
33 | params('@charset "utf8"; £', 'ShiftJIS', expect_error=True),
34 | params('@charset "utf£8"; £', 'ShiftJIS', expect_error=True),
35 | params('@charset "unknown-encoding"; £', 'ShiftJIS', expect_error=True),
36 | params('@charset "utf8"; £', 'ShiftJIS', document_encoding='ShiftJIS'),
37 | params('£', 'ShiftJIS', linking_encoding='utf8',
38 | document_encoding='ShiftJIS'),
39 | params('@charset "utf-32"; 𐂃', 'utf-32-be'),
40 | params('@charset "Shift-JIS"; £', 'ShiftJIS'),
41 | params('@charset "ISO-8859-8"; £', 'ShiftJIS', expect_error=True),
42 | params('𐂃', 'utf-16-le', expect_error=True), # no BOM
43 | params('𐂃', 'utf-16-le', use_bom=True),
44 | params('𐂃', 'utf-32-be', expect_error=True),
45 | params('𐂃', 'utf-32-be', use_bom=True),
46 | params('𐂃', 'utf-32-be', document_encoding='utf-32-be'),
47 | params('𐂃', 'utf-32-be', linking_encoding='utf-32-be'),
48 | params('@charset "utf-32-le"; 𐂃', 'utf-32-be',
49 | use_bom=True, expect_error=True),
50 | # protocol_encoding takes precedence over @charset
51 | params('@charset "ISO-8859-8"; £', 'ShiftJIS',
52 | protocol_encoding='Shift-JIS'),
53 | params('@charset "unknown-encoding"; £', 'ShiftJIS',
54 | protocol_encoding='Shift-JIS'),
55 | params('@charset "Shift-JIS"; £', 'ShiftJIS',
56 | protocol_encoding='utf8'),
57 | # @charset takes precedence over document_encoding
58 | params('@charset "Shift-JIS"; £', 'ShiftJIS',
59 | document_encoding='ISO-8859-8'),
60 | # @charset takes precedence over linking_encoding
61 | params('@charset "Shift-JIS"; £', 'ShiftJIS',
62 | linking_encoding='ISO-8859-8'),
63 | # linking_encoding takes precedence over document_encoding
64 | params('£', 'ShiftJIS',
65 | linking_encoding='Shift-JIS', document_encoding='ISO-8859-8'),
66 | ])
67 | def test_decode(css, encoding, use_bom, expect_error, kwargs):
68 | # Workaround PyPy and CPython 3.0 bug: https://bugs.pypy.org/issue1094
69 | css = css.encode('utf16').decode('utf16')
70 | if use_bom:
71 | source = '\ufeff' + css
72 | else:
73 | source = css
74 | css_bytes = source.encode(encoding)
75 | result, result_encoding = decode(css_bytes, **kwargs)
76 | if expect_error:
77 | assert result != css, 'Unexpected unicode success'
78 | else:
79 | assert result == css, 'Unexpected unicode error'
80 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/tests/test_fonts3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for the Fonts 3 parser
4 | ----------------------------
5 |
6 | :copyright: (c) 2016 by Kozea.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import pytest
14 | from tinycss.fonts3 import CSSFonts3Parser
15 |
16 | from . import assert_errors
17 | from .test_tokenizer import jsonify
18 |
19 |
20 | @pytest.mark.parametrize(('css', 'expected_family_names', 'expected_errors'), [
21 | ('@font-feature-values foo {}', ('foo',), []),
22 | ('@font-feature-values Foo Test {}', ('Foo Test',), []),
23 | ('@font-feature-values \'Foo Test\' {}', ('Foo Test',), []),
24 | ('@font-feature-values Foo Test, Foo Lol, "Foo tooo"', (
25 | 'Foo Test', 'Foo Lol', 'Foo tooo'), []),
26 | ('@font-feature-values Foo , Foo lol {}', ('Foo', 'Foo lol'), []),
27 | ('@font-feature-values Foo , "Foobar" , Lol {}', (
28 | 'Foo', 'Foobar', 'Lol'), []),
29 | ('@font-feature-values Foo, {}', None, [
30 | 'invalid @font-feature-values selector']),
31 | ('@font-feature-values ,Foo {}', None, [
32 | 'invalid @font-feature-values selector']),
33 | ('@font-feature-values Test,"Foo", {}', None, [
34 | 'invalid @font-feature-values selector']),
35 | ('@font-feature-values Test "Foo" {}', None, [
36 | 'invalid @font-feature-values selector']),
37 | ('@font-feature-values Test Foo, Test "bar", "foo" {}', None, [
38 | 'invalid @font-feature-values selector']),
39 | ('@font-feature-values Test/Foo {}', None, [
40 | 'invalid @font-feature-values selector']),
41 | ('@font-feature-values /Foo {}', None, [
42 | 'invalid @font-feature-values selector']),
43 | ('@font-feature-values #Foo {}', None, [
44 | 'invalid @font-feature-values selector']),
45 | # TODO: this currently works but should not work
46 | # ('@font-feature-values test@foo {}', None, [
47 | # 'invalid @font-feature-values selector']),
48 | ('@font-feature-values Hawaii 5-0 {}', None, [
49 | 'invalid @font-feature-values selector']),
50 | ])
51 | def test_font_feature_values_selectors(css, expected_family_names,
52 | expected_errors):
53 | stylesheet = CSSFonts3Parser().parse_stylesheet(css)
54 | assert_errors(stylesheet.errors, expected_errors)
55 |
56 | if stylesheet.rules:
57 | assert len(stylesheet.rules) == 1
58 | rule = stylesheet.rules[0]
59 | assert rule.at_keyword == '@font-feature-values'
60 | assert rule.family_names == expected_family_names
61 |
62 |
63 | @pytest.mark.parametrize(('css', 'expected_declarations', 'expected_errors'), [
64 | ('@font-face {}', [], []),
65 | ('@font-face test { src: "lol"; font-family: "bar" }', None, [
66 | 'unexpected IDENT token in @font-face rule header']),
67 | ('@font-face { src: "lol"; font-family: "bar" }', [
68 | ('src', [('STRING', 'lol')]),
69 | ('font-family', [('STRING', 'bar')])], []),
70 | ('@font-face { src: "lol"; font-family: "bar"; src: "baz" }', [
71 | ('src', [('STRING', 'lol')]),
72 | ('font-family', [('STRING', 'bar')]),
73 | ('src', [('STRING', 'baz')])], []),
74 | ])
75 | def test_font_face_content(css, expected_declarations, expected_errors):
76 | stylesheet = CSSFonts3Parser().parse_stylesheet(css)
77 | assert_errors(stylesheet.errors, expected_errors)
78 |
79 | def declarations(rule):
80 | return [(decl.name, list(jsonify(decl.value)))
81 | for decl in rule.declarations]
82 |
83 | if expected_declarations is None:
84 | assert stylesheet.rules == []
85 | assert expected_errors
86 | else:
87 | assert len(stylesheet.rules) == 1
88 | rule = stylesheet.rules[0]
89 | assert rule.at_keyword == '@font-face'
90 | assert declarations(rule) == expected_declarations
91 |
92 |
93 | @pytest.mark.parametrize(
94 | ('css', 'expected_rules', 'expected_errors'), [
95 | ('''@annotation{}''', None, [
96 | '@annotation rule not allowed in stylesheet']),
97 | ('''@font-feature-values foo {}''', None, []),
98 | ('''@font-feature-values foo {
99 | @swash { ornate: 1; }
100 | @styleset { double-W: 14; sharp-terminals: 16 1; }
101 | }''', [
102 | ('@swash', [('ornate', [('INTEGER', 1)])]),
103 | ('@styleset', [
104 | ('double-w', [('INTEGER', 14)]),
105 | ('sharp-terminals', [
106 | ('INTEGER', 16), ('S', ' '), ('INTEGER', 1)])])], []),
107 | ('''@font-feature-values foo {
108 | @swash { ornate: 14; }
109 | @unknown { test: 1; }
110 | }''', [('@swash', [('ornate', [('INTEGER', 14)])])], [
111 | 'unknown at-rule in @font-feature-values context: @unknown']),
112 | ('''@font-feature-values foo {
113 | @annotation{boxed:1}
114 | bad: 2;
115 | @brokenstylesetbecauseofbadabove { sharp: 1}
116 | @styleset { sharp-terminals: 16 1; @bad {}}
117 | @styleset { @bad {} top-ignored: 3; top: 9000}
118 | really-bad
119 | }''', [
120 | ('@annotation', [('boxed', [('INTEGER', 1)])]),
121 | ('@styleset', [
122 | ('sharp-terminals', [
123 | ('INTEGER', 16), ('S', ' '), ('INTEGER', 1)])]),
124 | ('@styleset', [('top', [('INTEGER', 9000)])])], [
125 | 'unexpected ; token in selector',
126 | 'expected a property name, got ATKEYWORD',
127 | 'expected a property name, got ATKEYWORD',
128 | 'no declaration block found for ruleset']),
129 | ])
130 | def test_font_feature_values_content(css, expected_rules, expected_errors):
131 | stylesheet = CSSFonts3Parser().parse_stylesheet(css)
132 | assert_errors(stylesheet.errors, expected_errors)
133 |
134 | if expected_rules is not None:
135 | assert len(stylesheet.rules) == 1
136 | rule = stylesheet.rules[0]
137 | assert rule.at_keyword == '@font-feature-values'
138 |
139 | rules = [
140 | (at_rule.at_keyword, [
141 | (decl.name, list(jsonify(decl.value)))
142 | for decl in at_rule.declarations])
143 | for at_rule in rule.at_rules] if rule.at_rules else None
144 | assert rules == expected_rules
145 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/tests/test_page3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for the Paged Media 3 parser
4 | ----------------------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import pytest
14 | from tinycss.page3 import CSSPage3Parser
15 |
16 | from . import assert_errors
17 | from .test_tokenizer import jsonify
18 |
19 |
20 | @pytest.mark.parametrize(('css', 'expected_selector',
21 | 'expected_specificity', 'expected_errors'), [
22 | ('@page {}', (None, None), (0, 0, 0), []),
23 |
24 | ('@page :first {}', (None, 'first'), (0, 1, 0), []),
25 | ('@page:left{}', (None, 'left'), (0, 0, 1), []),
26 | ('@page :right {}', (None, 'right'), (0, 0, 1), []),
27 | ('@page :blank{}', (None, 'blank'), (0, 1, 0), []),
28 | ('@page :last {}', None, None, ['invalid @page selector']),
29 | ('@page : first {}', None, None, ['invalid @page selector']),
30 |
31 | ('@page foo:first {}', ('foo', 'first'), (1, 1, 0), []),
32 | ('@page bar :left {}', ('bar', 'left'), (1, 0, 1), []),
33 | (r'@page \26:right {}', ('&', 'right'), (1, 0, 1), []),
34 |
35 | ('@page foo {}', ('foo', None), (1, 0, 0), []),
36 | (r'@page \26 {}', ('&', None), (1, 0, 0), []),
37 |
38 | ('@page foo fist {}', None, None, ['invalid @page selector']),
39 | ('@page foo, bar {}', None, None, ['invalid @page selector']),
40 | ('@page foo&first {}', None, None, ['invalid @page selector']),
41 | ])
42 | def test_selectors(css, expected_selector, expected_specificity,
43 | expected_errors):
44 | stylesheet = CSSPage3Parser().parse_stylesheet(css)
45 | assert_errors(stylesheet.errors, expected_errors)
46 |
47 | if stylesheet.rules:
48 | assert len(stylesheet.rules) == 1
49 | rule = stylesheet.rules[0]
50 | assert rule.at_keyword == '@page'
51 | selector = rule.selector
52 | assert rule.specificity == expected_specificity
53 | else:
54 | selector = None
55 | assert selector == expected_selector
56 |
57 |
58 | @pytest.mark.parametrize(('css', 'expected_declarations',
59 | 'expected_rules', 'expected_errors'), [
60 | ('@page {}', [], [], []),
61 | ('@page { foo: 4; bar: z }',
62 | [('foo', [('INTEGER', 4)]), ('bar', [('IDENT', 'z')])], [], []),
63 | ('''@page { foo: 4;
64 | @top-center { content: "Awesome Title" }
65 | @bottom-left { content: counter(page) }
66 | bar: z
67 | }''',
68 | [('foo', [('INTEGER', 4)]), ('bar', [('IDENT', 'z')])],
69 | [('@top-center', [('content', [('STRING', 'Awesome Title')])]),
70 | ('@bottom-left', [('content', [
71 | ('FUNCTION', 'counter', [('IDENT', 'page')])])])],
72 | []),
73 | ('''@page { foo: 4;
74 | @bottom-top { content: counter(page) }
75 | bar: z
76 | }''',
77 | [('foo', [('INTEGER', 4)]), ('bar', [('IDENT', 'z')])],
78 | [],
79 | ['unknown at-rule in @page context: @bottom-top']),
80 |
81 | ('@page{} @top-right{}', [], [], [
82 | '@top-right rule not allowed in stylesheet']),
83 | ('@page{ @top-right 4 {} }', [], [], [
84 | 'unexpected INTEGER token in @top-right rule header']),
85 | # Not much error recovery tests here. This should be covered in test_css21
86 | ])
87 | def test_content(css, expected_declarations, expected_rules, expected_errors):
88 | stylesheet = CSSPage3Parser().parse_stylesheet(css)
89 | assert_errors(stylesheet.errors, expected_errors)
90 |
91 | def declarations(rule):
92 | return [(decl.name, list(jsonify(decl.value)))
93 | for decl in rule.declarations]
94 |
95 | assert len(stylesheet.rules) == 1
96 | rule = stylesheet.rules[0]
97 | assert rule.at_keyword == '@page'
98 | assert declarations(rule) == expected_declarations
99 | rules = [(margin_rule.at_keyword, declarations(margin_rule))
100 | for margin_rule in rule.at_rules]
101 | assert rules == expected_rules
102 |
--------------------------------------------------------------------------------
/python3.10libs/tinycss/version.py:
--------------------------------------------------------------------------------
1 | VERSION = '0.4'
2 |
--------------------------------------------------------------------------------
/python3.11libs/svg/__init__.py:
--------------------------------------------------------------------------------
1 | __path__ = __import__("pkgutil").extend_path(__path__, __name__)
2 |
--------------------------------------------------------------------------------
/python3.11libs/svg/path/__init__.py:
--------------------------------------------------------------------------------
1 | from .path import Path, Move, Line, Arc, Close # noqa: 401
2 | from .path import CubicBezier, QuadraticBezier # noqa: 401
3 | from .path import PathSegment, Linear, NonLinear # noqa: 401
4 | from .parser import parse_path # noqa: 401
5 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/__init__.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss
4 | -------
5 |
6 | A CSS parser, and nothing else.
7 |
8 | :copyright: (c) 2012 by Simon Sapin.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 |
12 | from .version import VERSION
13 |
14 | from .css21 import CSS21Parser
15 | from .page3 import CSSPage3Parser
16 | from .fonts3 import CSSFonts3Parser
17 |
18 |
19 | __version__ = VERSION
20 |
21 | PARSER_MODULES = {
22 | 'page3': CSSPage3Parser,
23 | 'fonts3': CSSFonts3Parser,
24 | }
25 |
26 |
27 | def make_parser(*features, **kwargs):
28 | """Make a parser object with the chosen features.
29 |
30 | :param features:
31 | Positional arguments are base classes the new parser class will extend.
32 | The string ``'page3'`` is accepted as short for
33 | :class:`~page3.CSSPage3Parser`.
34 | The string ``'fonts3'`` is accepted as short for
35 | :class:`~fonts3.CSSFonts3Parser`.
36 | :param kwargs:
37 | Keyword arguments are passed to the parser’s constructor.
38 | :returns:
39 | An instance of a new subclass of :class:`CSS21Parser`
40 |
41 | """
42 | if features:
43 | bases = tuple(PARSER_MODULES.get(f, f) for f in features)
44 | parser_class = type('CustomCSSParser', bases + (CSS21Parser,), {})
45 | else:
46 | parser_class = CSS21Parser
47 | return parser_class(**kwargs)
48 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/fonts3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.colors3
4 | ---------------
5 |
6 | Parser for CSS 3 Fonts syntax:
7 | https://www.w3.org/TR/css-fonts-3/
8 |
9 | Adds support for font-face and font-feature-values rules.
10 |
11 | :copyright: (c) 2016 by Kozea.
12 | :license: BSD, see LICENSE for more details.
13 | """
14 |
15 | from __future__ import division, unicode_literals
16 |
17 | from .css21 import CSS21Parser, ParseError
18 |
19 |
20 | class FontFaceRule(object):
21 | """A parsed at-rule for font faces.
22 |
23 | .. attribute:: at_keyword
24 |
25 | Always ``'@font-face'``.
26 |
27 | .. attribute:: declarations
28 |
29 | A list of :class:`~.css21.Declaration` objects.
30 |
31 | .. attribute:: line
32 |
33 | Source line where this was read.
34 |
35 | .. attribute:: column
36 |
37 | Source column where this was read.
38 |
39 | """
40 |
41 | def __init__(self, at_keyword, declarations, line, column):
42 | assert at_keyword == '@font-face'
43 | self.at_keyword = at_keyword
44 | self.declarations = declarations
45 | self.line = line
46 | self.column = column
47 |
48 |
49 | class FontFeatureValuesRule(object):
50 | """A parsed at-rule for font feature values.
51 |
52 | .. attribute:: at_keyword
53 |
54 | Always ``'@font-feature-values'``.
55 |
56 | .. attribute:: line
57 |
58 | Source line where this was read.
59 |
60 | .. attribute:: column
61 |
62 | Source column where this was read.
63 |
64 | .. attribute:: at_rules
65 |
66 | The list of parsed at-rules inside the @font-feature-values block, in
67 | source order.
68 |
69 | .. attribute:: family_names
70 |
71 | A list of strings representing font families.
72 |
73 | """
74 |
75 | def __init__(self, at_keyword, at_rules, family_names, line, column):
76 | assert at_keyword == '@font-feature-values'
77 | self.at_keyword = at_keyword
78 | self.family_names = family_names
79 | self.at_rules = at_rules
80 | self.line = line
81 | self.column = column
82 |
83 |
84 | class FontFeatureRule(object):
85 | """A parsed at-rule for font features.
86 |
87 | .. attribute:: at_keyword
88 |
89 | One of the 16 following strings:
90 |
91 | * ``@stylistic``
92 | * ``@styleset``
93 | * ``@character-variant``
94 | * ``@swash``
95 | * ``@ornaments``
96 | * ``@annotation``
97 |
98 | .. attribute:: declarations
99 |
100 | A list of :class:`~.css21.Declaration` objects.
101 |
102 | .. attribute:: line
103 |
104 | Source line where this was read.
105 |
106 | .. attribute:: column
107 |
108 | Source column where this was read.
109 |
110 | """
111 |
112 | def __init__(self, at_keyword, declarations, line, column):
113 | self.at_keyword = at_keyword
114 | self.declarations = declarations
115 | self.line = line
116 | self.column = column
117 |
118 |
119 | class CSSFonts3Parser(CSS21Parser):
120 | """Extend :class:`~.css21.CSS21Parser` for `CSS 3 Fonts`_ syntax.
121 |
122 | .. _CSS 3 Fonts: https://www.w3.org/TR/css-fonts-3/
123 |
124 | """
125 |
126 | FONT_FEATURE_VALUES_AT_KEYWORDS = [
127 | '@stylistic',
128 | '@styleset',
129 | '@character-variant',
130 | '@swash',
131 | '@ornaments',
132 | '@annotation',
133 | ]
134 |
135 | def parse_at_rule(self, rule, previous_rules, errors, context):
136 | if rule.at_keyword == '@font-face':
137 | if rule.head:
138 | raise ParseError(
139 | rule.head[0],
140 | 'unexpected {0} token in {1} rule header'.format(
141 | rule.head[0].type, rule.at_keyword))
142 | declarations, body_errors = self.parse_declaration_list(rule.body)
143 | errors.extend(body_errors)
144 | return FontFaceRule(
145 | rule.at_keyword, declarations, rule.line, rule.column)
146 | elif rule.at_keyword == '@font-feature-values':
147 | family_names = tuple(
148 | self.parse_font_feature_values_family_names(rule.head))
149 | at_rules, body_errors = (
150 | self.parse_rules(rule.body or [], '@font-feature-values'))
151 | errors.extend(body_errors)
152 | return FontFeatureValuesRule(
153 | rule.at_keyword, at_rules, family_names,
154 | rule.line, rule.column)
155 | elif rule.at_keyword in self.FONT_FEATURE_VALUES_AT_KEYWORDS:
156 | if context != '@font-feature-values':
157 | raise ParseError(
158 | rule, '{0} rule not allowed in {1}'.format(
159 | rule.at_keyword, context))
160 | declarations, body_errors = self.parse_declaration_list(rule.body)
161 | errors.extend(body_errors)
162 | return FontFeatureRule(
163 | rule.at_keyword, declarations, rule.line, rule.column)
164 | return super(CSSFonts3Parser, self).parse_at_rule(
165 | rule, previous_rules, errors, context)
166 |
167 | def parse_font_feature_values_family_names(self, tokens):
168 | """Parse an @font-feature-values selector.
169 |
170 | :param tokens:
171 | An iterable of token, typically from the ``head`` attribute of
172 | an unparsed :class:`AtRule`.
173 | :returns:
174 | A generator of strings representing font families.
175 | :raises:
176 | :class:`~.parsing.ParseError` on invalid selectors
177 |
178 | """
179 | family = ''
180 | current_string = False
181 | for token in tokens:
182 | if token.type == 'DELIM' and token.value == ',' and family:
183 | yield family
184 | family = ''
185 | current_string = False
186 | elif token.type == 'STRING' and not family and (
187 | current_string is False):
188 | family = token.value
189 | current_string = True
190 | elif token.type == 'IDENT' and not current_string:
191 | if family:
192 | family += ' '
193 | family += token.value
194 | elif token.type != 'S':
195 | family = ''
196 | break
197 | if family:
198 | yield family
199 | else:
200 | raise ParseError(token, 'invalid @font-feature-values selector')
201 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/page3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.page3
4 | ------------------
5 |
6 | Support for CSS 3 Paged Media syntax:
7 | http://dev.w3.org/csswg/css3-page/
8 |
9 | Adds support for named page selectors and margin rules.
10 |
11 | :copyright: (c) 2012 by Simon Sapin.
12 | :license: BSD, see LICENSE for more details.
13 | """
14 |
15 | from __future__ import division, unicode_literals
16 |
17 | from .css21 import CSS21Parser, ParseError
18 |
19 |
20 | class MarginRule(object):
21 | """A parsed at-rule for margin box.
22 |
23 | .. attribute:: at_keyword
24 |
25 | One of the 16 following strings:
26 |
27 | * ``@top-left-corner``
28 | * ``@top-left``
29 | * ``@top-center``
30 | * ``@top-right``
31 | * ``@top-right-corner``
32 | * ``@bottom-left-corner``
33 | * ``@bottom-left``
34 | * ``@bottom-center``
35 | * ``@bottom-right``
36 | * ``@bottom-right-corner``
37 | * ``@left-top``
38 | * ``@left-middle``
39 | * ``@left-bottom``
40 | * ``@right-top``
41 | * ``@right-middle``
42 | * ``@right-bottom``
43 |
44 | .. attribute:: declarations
45 |
46 | A list of :class:`~.css21.Declaration` objects.
47 |
48 | .. attribute:: line
49 |
50 | Source line where this was read.
51 |
52 | .. attribute:: column
53 |
54 | Source column where this was read.
55 |
56 | """
57 |
58 | def __init__(self, at_keyword, declarations, line, column):
59 | self.at_keyword = at_keyword
60 | self.declarations = declarations
61 | self.line = line
62 | self.column = column
63 |
64 |
65 | class CSSPage3Parser(CSS21Parser):
66 | """Extend :class:`~.css21.CSS21Parser` for `CSS 3 Paged Media`_ syntax.
67 |
68 | .. _CSS 3 Paged Media: http://dev.w3.org/csswg/css3-page/
69 |
70 | Compared to CSS 2.1, the ``at_rules`` and ``selector`` attributes of
71 | :class:`~.css21.PageRule` objects are modified:
72 |
73 | * ``at_rules`` is not always empty, it is a list of :class:`MarginRule`
74 | objects.
75 |
76 | * ``selector``, instead of a single string, is a tuple of the page name
77 | and the pseudo class. Each of these may be a ``None`` or a string.
78 |
79 | +--------------------------+------------------------+
80 | | CSS | Parsed selectors |
81 | +==========================+========================+
82 | | .. code-block:: css | .. code-block:: python |
83 | | | |
84 | | @page {} | (None, None) |
85 | | @page :first {} | (None, 'first') |
86 | | @page chapter {} | ('chapter', None) |
87 | | @page table:right {} | ('table', 'right') |
88 | +--------------------------+------------------------+
89 |
90 | """
91 |
92 | PAGE_MARGIN_AT_KEYWORDS = [
93 | '@top-left-corner',
94 | '@top-left',
95 | '@top-center',
96 | '@top-right',
97 | '@top-right-corner',
98 | '@bottom-left-corner',
99 | '@bottom-left',
100 | '@bottom-center',
101 | '@bottom-right',
102 | '@bottom-right-corner',
103 | '@left-top',
104 | '@left-middle',
105 | '@left-bottom',
106 | '@right-top',
107 | '@right-middle',
108 | '@right-bottom',
109 | ]
110 |
111 | def parse_at_rule(self, rule, previous_rules, errors, context):
112 | if rule.at_keyword in self.PAGE_MARGIN_AT_KEYWORDS:
113 | if context != '@page':
114 | raise ParseError(
115 | rule, '{0} rule not allowed in {1}'.format(
116 | rule.at_keyword, context))
117 | if rule.head:
118 | raise ParseError(
119 | rule.head[0],
120 | 'unexpected {0} token in {1} rule header'.format(
121 | rule.head[0].type, rule.at_keyword))
122 | declarations, body_errors = self.parse_declaration_list(rule.body)
123 | errors.extend(body_errors)
124 | return MarginRule(
125 | rule.at_keyword, declarations, rule.line, rule.column)
126 | return super(CSSPage3Parser, self).parse_at_rule(
127 | rule, previous_rules, errors, context)
128 |
129 | def parse_page_selector(self, head):
130 | """Parse an @page selector.
131 |
132 | :param head:
133 | The ``head`` attribute of an unparsed :class:`AtRule`.
134 | :returns:
135 | A page selector. For CSS 2.1, this is 'first', 'left', 'right'
136 | or None. 'blank' is added by GCPM.
137 | :raises:
138 | :class`~parsing.ParseError` on invalid selectors
139 |
140 | """
141 | if not head:
142 | return (None, None), (0, 0, 0)
143 | if head[0].type == 'IDENT':
144 | name = head.pop(0).value
145 | while head and head[0].type == 'S':
146 | head.pop(0)
147 | if not head:
148 | return (name, None), (1, 0, 0)
149 | name_specificity = (1,)
150 | else:
151 | name = None
152 | name_specificity = (0,)
153 | if (len(head) == 2 and head[0].type == ':' and
154 | head[1].type == 'IDENT'):
155 | pseudo_class = head[1].value
156 | specificity = {
157 | 'first': (1, 0), 'blank': (1, 0),
158 | 'left': (0, 1), 'right': (0, 1),
159 | }.get(pseudo_class)
160 | if specificity:
161 | return (name, pseudo_class), (name_specificity + specificity)
162 | raise ParseError(head[0], 'invalid @page selector')
163 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/parsing.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.parsing
4 | ---------------
5 |
6 | Utilities for parsing lists of tokens.
7 |
8 | :copyright: (c) 2012 by Simon Sapin.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 |
12 | from __future__ import unicode_literals
13 |
14 |
15 | # TODO: unit tests
16 |
17 | def split_on_comma(tokens):
18 | """Split a list of tokens on commas, ie ``,`` DELIM tokens.
19 |
20 | Only "top-level" comma tokens are splitting points, not commas inside a
21 | function or other :class:`ContainerToken`.
22 |
23 | :param tokens:
24 | An iterable of :class:`~.token_data.Token` or
25 | :class:`~.token_data.ContainerToken`.
26 | :returns:
27 | A list of lists of tokens
28 |
29 | """
30 | parts = []
31 | this_part = []
32 | for token in tokens:
33 | if token.type == 'DELIM' and token.value == ',':
34 | parts.append(this_part)
35 | this_part = []
36 | else:
37 | this_part.append(token)
38 | parts.append(this_part)
39 | return parts
40 |
41 |
42 | def strip_whitespace(tokens):
43 | """Remove whitespace at the beggining and end of a token list.
44 |
45 | Whitespace tokens in-between other tokens in the list are preserved.
46 |
47 | :param tokens:
48 | A list of :class:`~.token_data.Token` or
49 | :class:`~.token_data.ContainerToken`.
50 | :return:
51 | A new sub-sequence of the list.
52 |
53 | """
54 | for i, token in enumerate(tokens):
55 | if token.type != 'S':
56 | break
57 | else:
58 | return [] # only whitespace
59 | tokens = tokens[i:]
60 | while tokens and tokens[-1].type == 'S':
61 | tokens.pop()
62 | return tokens
63 |
64 |
65 | def remove_whitespace(tokens):
66 | """Remove any top-level whitespace in a token list.
67 |
68 | Whitespace tokens inside recursive :class:`~.token_data.ContainerToken`
69 | are preserved.
70 |
71 | :param tokens:
72 | A list of :class:`~.token_data.Token` or
73 | :class:`~.token_data.ContainerToken`.
74 | :return:
75 | A new sub-sequence of the list.
76 |
77 | """
78 | return [token for token in tokens if token.type != 'S']
79 |
80 |
81 | def validate_value(tokens):
82 | """Validate a property value.
83 |
84 | :param tokens:
85 | an iterable of tokens
86 | :raises:
87 | :class:`ParseError` if there is any invalid token for the 'value'
88 | production of the core grammar.
89 |
90 | """
91 | for token in tokens:
92 | type_ = token.type
93 | if type_ == '{':
94 | validate_block(token.content, 'property value')
95 | else:
96 | validate_any(token, 'property value')
97 |
98 |
99 | def validate_block(tokens, context):
100 | """
101 | :raises:
102 | :class:`ParseError` if there is any invalid token for the 'block'
103 | production of the core grammar.
104 | :param tokens: an iterable of tokens
105 | :param context: a string for the 'unexpected in ...' message
106 |
107 | """
108 | for token in tokens:
109 | type_ = token.type
110 | if type_ == '{':
111 | validate_block(token.content, context)
112 | elif type_ not in (';', 'ATKEYWORD'):
113 | validate_any(token, context)
114 |
115 |
116 | def validate_any(token, context):
117 | """
118 | :raises:
119 | :class:`ParseError` if this is an invalid token for the
120 | 'any' production of the core grammar.
121 | :param token: a single token
122 | :param context: a string for the 'unexpected in ...' message
123 |
124 | """
125 | type_ = token.type
126 | if type_ in ('FUNCTION', '(', '['):
127 | for token in token.content:
128 | validate_any(token, type_)
129 | elif type_ not in ('S', 'IDENT', 'DIMENSION', 'PERCENTAGE', 'NUMBER',
130 | 'INTEGER', 'URI', 'DELIM', 'STRING', 'HASH', ':',
131 | 'UNICODE-RANGE'):
132 | if type_ in ('}', ')', ']'):
133 | adjective = 'unmatched'
134 | else:
135 | adjective = 'unexpected'
136 | raise ParseError(
137 | token, '{0} {1} token in {2}'.format(adjective, type_, context))
138 |
139 |
140 | class ParseError(ValueError):
141 | """Details about a CSS syntax error. Usually indicates that something
142 | (a rule or a declaration) was ignored and will not appear as a parsed
143 | object.
144 |
145 | This exception is typically logged in a list rather than being propagated
146 | to the user API.
147 |
148 | .. attribute:: line
149 |
150 | Source line where the error occured.
151 |
152 | .. attribute:: column
153 |
154 | Column in the source line where the error occured.
155 |
156 | .. attribute:: reason
157 |
158 | What happend (a string).
159 |
160 | """
161 | def __init__(self, subject, reason):
162 | self.line = subject.line
163 | self.column = subject.column
164 | self.reason = reason
165 | super(ParseError, self).__init__(
166 | 'Parse error at {0.line}:{0.column}, {0.reason}'.format(self))
167 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/tests/__init__.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Test suite for tinycss
4 | ----------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import sys
14 |
15 |
16 | # Awful workaround to fix isort's "sys.setdefaultencoding('utf-8')".
17 | if sys.version_info[0] == 2:
18 | reload(sys) # noqa
19 | sys.setdefaultencoding('ascii')
20 |
21 |
22 | def assert_errors(errors, expected_errors):
23 | """Test not complete error messages but only substrings."""
24 | assert len(errors) == len(expected_errors)
25 | for error, expected in zip(errors, expected_errors):
26 | assert expected in str(error)
27 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/tests/speed.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Speed tests
4 | -----------
5 |
6 | Note: this file is not named test_*.py as it is not part of the
7 | test suite ran by pytest.
8 |
9 | :copyright: (c) 2012 by Simon Sapin.
10 | :license: BSD, see LICENSE for more details.
11 | """
12 |
13 |
14 | from __future__ import division, unicode_literals
15 |
16 | import contextlib
17 | import functools
18 | import os.path
19 | import sys
20 | import timeit
21 |
22 | from cssutils import parseString
23 |
24 | from .. import tokenizer
25 | from ..css21 import CSS21Parser
26 | from ..parsing import remove_whitespace
27 |
28 | CSS_REPEAT = 4
29 | TIMEIT_REPEAT = 3
30 | TIMEIT_NUMBER = 20
31 |
32 |
33 | def load_css():
34 | filename = os.path.join(os.path.dirname(__file__),
35 | '..', '..', 'docs', '_static', 'custom.css')
36 | with open(filename, 'rb') as fd:
37 | return b'\n'.join([fd.read()] * CSS_REPEAT)
38 |
39 |
40 | # Pre-load so that I/O is not measured
41 | CSS = load_css()
42 |
43 |
44 | @contextlib.contextmanager
45 | def install_tokenizer(name):
46 | original = tokenizer.tokenize_flat
47 | try:
48 | tokenizer.tokenize_flat = getattr(tokenizer, name)
49 | yield
50 | finally:
51 | tokenizer.tokenize_flat = original
52 |
53 |
54 | def parse(tokenizer_name):
55 | with install_tokenizer(tokenizer_name):
56 | stylesheet = CSS21Parser().parse_stylesheet_bytes(CSS)
57 | result = []
58 | for rule in stylesheet.rules:
59 | selector = rule.selector.as_css()
60 | declarations = [
61 | (declaration.name, len(list(remove_whitespace(declaration.value))))
62 | for declaration in rule.declarations]
63 | result.append((selector, declarations))
64 | return result
65 |
66 | parse_cython = functools.partial(parse, 'cython_tokenize_flat')
67 | parse_python = functools.partial(parse, 'python_tokenize_flat')
68 |
69 |
70 | def parse_cssutils():
71 | stylesheet = parseString(CSS)
72 | result = []
73 | for rule in stylesheet.cssRules:
74 | selector = rule.selectorText
75 | declarations = [
76 | (declaration.name, len(list(declaration.propertyValue)))
77 | for declaration in rule.style.getProperties(all=True)]
78 | result.append((selector, declarations))
79 | return result
80 |
81 |
82 | def check_consistency():
83 | result = parse_python()
84 | assert len(result) > 0
85 | if tokenizer.cython_tokenize_flat:
86 | assert parse_cython() == result
87 | assert parse_cssutils() == result
88 | version = '.'.join(map(str, sys.version_info[:3]))
89 | print('Python {}, consistency OK.'.format(version))
90 |
91 |
92 | def warm_up():
93 | is_pypy = hasattr(sys, 'pypy_translation_info')
94 | if is_pypy:
95 | print('Warming up for PyPy...')
96 | for i in range(80):
97 | for i in range(10):
98 | parse_python()
99 | parse_cssutils()
100 | sys.stdout.write('.')
101 | sys.stdout.flush()
102 | sys.stdout.write('\n')
103 |
104 |
105 | def time(function):
106 | seconds = timeit.Timer(function).repeat(TIMEIT_REPEAT, TIMEIT_NUMBER)
107 | miliseconds = int(min(seconds) * 1000)
108 | return miliseconds
109 |
110 |
111 | def run():
112 | if tokenizer.cython_tokenize_flat:
113 | data_set = [
114 | ('tinycss + speedups ', parse_cython),
115 | ]
116 | else:
117 | print('Speedups are NOT available.')
118 | data_set = []
119 | data_set += [
120 | ('tinycss WITHOUT speedups', parse_python),
121 | ('cssutils ', parse_cssutils),
122 | ]
123 | label, function = data_set.pop(0)
124 | ref = time(function)
125 | print('{} {} ms'.format(label, ref))
126 | for label, function in data_set:
127 | result = time(function)
128 | print('{} {} ms {:.2f}x'.format(label, result, result / ref))
129 |
130 |
131 | if __name__ == '__main__':
132 | check_consistency()
133 | warm_up()
134 | run()
135 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/tests/test_api.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for the public API
4 | ------------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | from pytest import raises
14 | from tinycss import make_parser
15 | from tinycss.page3 import CSSPage3Parser
16 |
17 |
18 | def test_make_parser():
19 | class MyParser(object):
20 | def __init__(self, some_config):
21 | self.some_config = some_config
22 |
23 | parsers = [
24 | make_parser(),
25 | make_parser('page3'),
26 | make_parser(CSSPage3Parser),
27 | make_parser(MyParser, some_config=42),
28 | make_parser(CSSPage3Parser, MyParser, some_config=42),
29 | make_parser(MyParser, 'page3', some_config=42),
30 | ]
31 |
32 | for parser, exp in zip(parsers, [False, True, True, False, True, True]):
33 | assert isinstance(parser, CSSPage3Parser) == exp
34 |
35 | for parser, exp in zip(parsers, [False, False, False, True, True, True]):
36 | assert isinstance(parser, MyParser) == exp
37 |
38 | for parser in parsers[3:]:
39 | assert parser.some_config == 42
40 |
41 | # Extra or missing named parameters
42 | raises(TypeError, make_parser, some_config=4)
43 | raises(TypeError, make_parser, 'page3', some_config=4)
44 | raises(TypeError, make_parser, MyParser)
45 | raises(TypeError, make_parser, MyParser, some_config=4, other_config=7)
46 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/tests/test_decoding.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for decoding bytes to Unicode
4 | -----------------------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import pytest
14 | from tinycss.decoding import decode
15 |
16 |
17 | def params(css, encoding, use_bom=False, expect_error=False, **kwargs):
18 | """Nicer syntax to make a tuple."""
19 | return css, encoding, use_bom, expect_error, kwargs
20 |
21 |
22 | @pytest.mark.parametrize(('css', 'encoding', 'use_bom', 'expect_error',
23 | 'kwargs'), [
24 | params('', 'utf8'), # default to utf8
25 | params('𐂃', 'utf8'),
26 | params('é', 'latin1'), # utf8 fails, fall back on ShiftJIS
27 | params('£', 'ShiftJIS', expect_error=True),
28 | params('£', 'ShiftJIS', protocol_encoding='Shift-JIS'),
29 | params('£', 'ShiftJIS', linking_encoding='Shift-JIS'),
30 | params('£', 'ShiftJIS', document_encoding='Shift-JIS'),
31 | params('£', 'ShiftJIS', protocol_encoding='utf8',
32 | document_encoding='ShiftJIS'),
33 | params('@charset "utf8"; £', 'ShiftJIS', expect_error=True),
34 | params('@charset "utf£8"; £', 'ShiftJIS', expect_error=True),
35 | params('@charset "unknown-encoding"; £', 'ShiftJIS', expect_error=True),
36 | params('@charset "utf8"; £', 'ShiftJIS', document_encoding='ShiftJIS'),
37 | params('£', 'ShiftJIS', linking_encoding='utf8',
38 | document_encoding='ShiftJIS'),
39 | params('@charset "utf-32"; 𐂃', 'utf-32-be'),
40 | params('@charset "Shift-JIS"; £', 'ShiftJIS'),
41 | params('@charset "ISO-8859-8"; £', 'ShiftJIS', expect_error=True),
42 | params('𐂃', 'utf-16-le', expect_error=True), # no BOM
43 | params('𐂃', 'utf-16-le', use_bom=True),
44 | params('𐂃', 'utf-32-be', expect_error=True),
45 | params('𐂃', 'utf-32-be', use_bom=True),
46 | params('𐂃', 'utf-32-be', document_encoding='utf-32-be'),
47 | params('𐂃', 'utf-32-be', linking_encoding='utf-32-be'),
48 | params('@charset "utf-32-le"; 𐂃', 'utf-32-be',
49 | use_bom=True, expect_error=True),
50 | # protocol_encoding takes precedence over @charset
51 | params('@charset "ISO-8859-8"; £', 'ShiftJIS',
52 | protocol_encoding='Shift-JIS'),
53 | params('@charset "unknown-encoding"; £', 'ShiftJIS',
54 | protocol_encoding='Shift-JIS'),
55 | params('@charset "Shift-JIS"; £', 'ShiftJIS',
56 | protocol_encoding='utf8'),
57 | # @charset takes precedence over document_encoding
58 | params('@charset "Shift-JIS"; £', 'ShiftJIS',
59 | document_encoding='ISO-8859-8'),
60 | # @charset takes precedence over linking_encoding
61 | params('@charset "Shift-JIS"; £', 'ShiftJIS',
62 | linking_encoding='ISO-8859-8'),
63 | # linking_encoding takes precedence over document_encoding
64 | params('£', 'ShiftJIS',
65 | linking_encoding='Shift-JIS', document_encoding='ISO-8859-8'),
66 | ])
67 | def test_decode(css, encoding, use_bom, expect_error, kwargs):
68 | # Workaround PyPy and CPython 3.0 bug: https://bugs.pypy.org/issue1094
69 | css = css.encode('utf16').decode('utf16')
70 | if use_bom:
71 | source = '\ufeff' + css
72 | else:
73 | source = css
74 | css_bytes = source.encode(encoding)
75 | result, result_encoding = decode(css_bytes, **kwargs)
76 | if expect_error:
77 | assert result != css, 'Unexpected unicode success'
78 | else:
79 | assert result == css, 'Unexpected unicode error'
80 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/tests/test_fonts3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for the Fonts 3 parser
4 | ----------------------------
5 |
6 | :copyright: (c) 2016 by Kozea.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import pytest
14 | from tinycss.fonts3 import CSSFonts3Parser
15 |
16 | from . import assert_errors
17 | from .test_tokenizer import jsonify
18 |
19 |
20 | @pytest.mark.parametrize(('css', 'expected_family_names', 'expected_errors'), [
21 | ('@font-feature-values foo {}', ('foo',), []),
22 | ('@font-feature-values Foo Test {}', ('Foo Test',), []),
23 | ('@font-feature-values \'Foo Test\' {}', ('Foo Test',), []),
24 | ('@font-feature-values Foo Test, Foo Lol, "Foo tooo"', (
25 | 'Foo Test', 'Foo Lol', 'Foo tooo'), []),
26 | ('@font-feature-values Foo , Foo lol {}', ('Foo', 'Foo lol'), []),
27 | ('@font-feature-values Foo , "Foobar" , Lol {}', (
28 | 'Foo', 'Foobar', 'Lol'), []),
29 | ('@font-feature-values Foo, {}', None, [
30 | 'invalid @font-feature-values selector']),
31 | ('@font-feature-values ,Foo {}', None, [
32 | 'invalid @font-feature-values selector']),
33 | ('@font-feature-values Test,"Foo", {}', None, [
34 | 'invalid @font-feature-values selector']),
35 | ('@font-feature-values Test "Foo" {}', None, [
36 | 'invalid @font-feature-values selector']),
37 | ('@font-feature-values Test Foo, Test "bar", "foo" {}', None, [
38 | 'invalid @font-feature-values selector']),
39 | ('@font-feature-values Test/Foo {}', None, [
40 | 'invalid @font-feature-values selector']),
41 | ('@font-feature-values /Foo {}', None, [
42 | 'invalid @font-feature-values selector']),
43 | ('@font-feature-values #Foo {}', None, [
44 | 'invalid @font-feature-values selector']),
45 | # TODO: this currently works but should not work
46 | # ('@font-feature-values test@foo {}', None, [
47 | # 'invalid @font-feature-values selector']),
48 | ('@font-feature-values Hawaii 5-0 {}', None, [
49 | 'invalid @font-feature-values selector']),
50 | ])
51 | def test_font_feature_values_selectors(css, expected_family_names,
52 | expected_errors):
53 | stylesheet = CSSFonts3Parser().parse_stylesheet(css)
54 | assert_errors(stylesheet.errors, expected_errors)
55 |
56 | if stylesheet.rules:
57 | assert len(stylesheet.rules) == 1
58 | rule = stylesheet.rules[0]
59 | assert rule.at_keyword == '@font-feature-values'
60 | assert rule.family_names == expected_family_names
61 |
62 |
63 | @pytest.mark.parametrize(('css', 'expected_declarations', 'expected_errors'), [
64 | ('@font-face {}', [], []),
65 | ('@font-face test { src: "lol"; font-family: "bar" }', None, [
66 | 'unexpected IDENT token in @font-face rule header']),
67 | ('@font-face { src: "lol"; font-family: "bar" }', [
68 | ('src', [('STRING', 'lol')]),
69 | ('font-family', [('STRING', 'bar')])], []),
70 | ('@font-face { src: "lol"; font-family: "bar"; src: "baz" }', [
71 | ('src', [('STRING', 'lol')]),
72 | ('font-family', [('STRING', 'bar')]),
73 | ('src', [('STRING', 'baz')])], []),
74 | ])
75 | def test_font_face_content(css, expected_declarations, expected_errors):
76 | stylesheet = CSSFonts3Parser().parse_stylesheet(css)
77 | assert_errors(stylesheet.errors, expected_errors)
78 |
79 | def declarations(rule):
80 | return [(decl.name, list(jsonify(decl.value)))
81 | for decl in rule.declarations]
82 |
83 | if expected_declarations is None:
84 | assert stylesheet.rules == []
85 | assert expected_errors
86 | else:
87 | assert len(stylesheet.rules) == 1
88 | rule = stylesheet.rules[0]
89 | assert rule.at_keyword == '@font-face'
90 | assert declarations(rule) == expected_declarations
91 |
92 |
93 | @pytest.mark.parametrize(
94 | ('css', 'expected_rules', 'expected_errors'), [
95 | ('''@annotation{}''', None, [
96 | '@annotation rule not allowed in stylesheet']),
97 | ('''@font-feature-values foo {}''', None, []),
98 | ('''@font-feature-values foo {
99 | @swash { ornate: 1; }
100 | @styleset { double-W: 14; sharp-terminals: 16 1; }
101 | }''', [
102 | ('@swash', [('ornate', [('INTEGER', 1)])]),
103 | ('@styleset', [
104 | ('double-w', [('INTEGER', 14)]),
105 | ('sharp-terminals', [
106 | ('INTEGER', 16), ('S', ' '), ('INTEGER', 1)])])], []),
107 | ('''@font-feature-values foo {
108 | @swash { ornate: 14; }
109 | @unknown { test: 1; }
110 | }''', [('@swash', [('ornate', [('INTEGER', 14)])])], [
111 | 'unknown at-rule in @font-feature-values context: @unknown']),
112 | ('''@font-feature-values foo {
113 | @annotation{boxed:1}
114 | bad: 2;
115 | @brokenstylesetbecauseofbadabove { sharp: 1}
116 | @styleset { sharp-terminals: 16 1; @bad {}}
117 | @styleset { @bad {} top-ignored: 3; top: 9000}
118 | really-bad
119 | }''', [
120 | ('@annotation', [('boxed', [('INTEGER', 1)])]),
121 | ('@styleset', [
122 | ('sharp-terminals', [
123 | ('INTEGER', 16), ('S', ' '), ('INTEGER', 1)])]),
124 | ('@styleset', [('top', [('INTEGER', 9000)])])], [
125 | 'unexpected ; token in selector',
126 | 'expected a property name, got ATKEYWORD',
127 | 'expected a property name, got ATKEYWORD',
128 | 'no declaration block found for ruleset']),
129 | ])
130 | def test_font_feature_values_content(css, expected_rules, expected_errors):
131 | stylesheet = CSSFonts3Parser().parse_stylesheet(css)
132 | assert_errors(stylesheet.errors, expected_errors)
133 |
134 | if expected_rules is not None:
135 | assert len(stylesheet.rules) == 1
136 | rule = stylesheet.rules[0]
137 | assert rule.at_keyword == '@font-feature-values'
138 |
139 | rules = [
140 | (at_rule.at_keyword, [
141 | (decl.name, list(jsonify(decl.value)))
142 | for decl in at_rule.declarations])
143 | for at_rule in rule.at_rules] if rule.at_rules else None
144 | assert rules == expected_rules
145 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/tests/test_page3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | Tests for the Paged Media 3 parser
4 | ----------------------------------
5 |
6 | :copyright: (c) 2012 by Simon Sapin.
7 | :license: BSD, see LICENSE for more details.
8 | """
9 |
10 |
11 | from __future__ import unicode_literals
12 |
13 | import pytest
14 | from tinycss.page3 import CSSPage3Parser
15 |
16 | from . import assert_errors
17 | from .test_tokenizer import jsonify
18 |
19 |
20 | @pytest.mark.parametrize(('css', 'expected_selector',
21 | 'expected_specificity', 'expected_errors'), [
22 | ('@page {}', (None, None), (0, 0, 0), []),
23 |
24 | ('@page :first {}', (None, 'first'), (0, 1, 0), []),
25 | ('@page:left{}', (None, 'left'), (0, 0, 1), []),
26 | ('@page :right {}', (None, 'right'), (0, 0, 1), []),
27 | ('@page :blank{}', (None, 'blank'), (0, 1, 0), []),
28 | ('@page :last {}', None, None, ['invalid @page selector']),
29 | ('@page : first {}', None, None, ['invalid @page selector']),
30 |
31 | ('@page foo:first {}', ('foo', 'first'), (1, 1, 0), []),
32 | ('@page bar :left {}', ('bar', 'left'), (1, 0, 1), []),
33 | (r'@page \26:right {}', ('&', 'right'), (1, 0, 1), []),
34 |
35 | ('@page foo {}', ('foo', None), (1, 0, 0), []),
36 | (r'@page \26 {}', ('&', None), (1, 0, 0), []),
37 |
38 | ('@page foo fist {}', None, None, ['invalid @page selector']),
39 | ('@page foo, bar {}', None, None, ['invalid @page selector']),
40 | ('@page foo&first {}', None, None, ['invalid @page selector']),
41 | ])
42 | def test_selectors(css, expected_selector, expected_specificity,
43 | expected_errors):
44 | stylesheet = CSSPage3Parser().parse_stylesheet(css)
45 | assert_errors(stylesheet.errors, expected_errors)
46 |
47 | if stylesheet.rules:
48 | assert len(stylesheet.rules) == 1
49 | rule = stylesheet.rules[0]
50 | assert rule.at_keyword == '@page'
51 | selector = rule.selector
52 | assert rule.specificity == expected_specificity
53 | else:
54 | selector = None
55 | assert selector == expected_selector
56 |
57 |
58 | @pytest.mark.parametrize(('css', 'expected_declarations',
59 | 'expected_rules', 'expected_errors'), [
60 | ('@page {}', [], [], []),
61 | ('@page { foo: 4; bar: z }',
62 | [('foo', [('INTEGER', 4)]), ('bar', [('IDENT', 'z')])], [], []),
63 | ('''@page { foo: 4;
64 | @top-center { content: "Awesome Title" }
65 | @bottom-left { content: counter(page) }
66 | bar: z
67 | }''',
68 | [('foo', [('INTEGER', 4)]), ('bar', [('IDENT', 'z')])],
69 | [('@top-center', [('content', [('STRING', 'Awesome Title')])]),
70 | ('@bottom-left', [('content', [
71 | ('FUNCTION', 'counter', [('IDENT', 'page')])])])],
72 | []),
73 | ('''@page { foo: 4;
74 | @bottom-top { content: counter(page) }
75 | bar: z
76 | }''',
77 | [('foo', [('INTEGER', 4)]), ('bar', [('IDENT', 'z')])],
78 | [],
79 | ['unknown at-rule in @page context: @bottom-top']),
80 |
81 | ('@page{} @top-right{}', [], [], [
82 | '@top-right rule not allowed in stylesheet']),
83 | ('@page{ @top-right 4 {} }', [], [], [
84 | 'unexpected INTEGER token in @top-right rule header']),
85 | # Not much error recovery tests here. This should be covered in test_css21
86 | ])
87 | def test_content(css, expected_declarations, expected_rules, expected_errors):
88 | stylesheet = CSSPage3Parser().parse_stylesheet(css)
89 | assert_errors(stylesheet.errors, expected_errors)
90 |
91 | def declarations(rule):
92 | return [(decl.name, list(jsonify(decl.value)))
93 | for decl in rule.declarations]
94 |
95 | assert len(stylesheet.rules) == 1
96 | rule = stylesheet.rules[0]
97 | assert rule.at_keyword == '@page'
98 | assert declarations(rule) == expected_declarations
99 | rules = [(margin_rule.at_keyword, declarations(margin_rule))
100 | for margin_rule in rule.at_rules]
101 | assert rules == expected_rules
102 |
--------------------------------------------------------------------------------
/python3.11libs/tinycss/version.py:
--------------------------------------------------------------------------------
1 | VERSION = '0.4'
2 |
--------------------------------------------------------------------------------
/python3.9libs/svg/__init__.py:
--------------------------------------------------------------------------------
1 | __path__ = __import__("pkgutil").extend_path(__path__, __name__)
2 |
--------------------------------------------------------------------------------
/python3.9libs/svg/path/__init__.py:
--------------------------------------------------------------------------------
1 | from .path import Path, Move, Line, Arc, Close # noqa: 401
2 | from .path import CubicBezier, QuadraticBezier # noqa: 401
3 | from .parser import parse_path # noqa: 401
4 |
--------------------------------------------------------------------------------
/python3.9libs/svg/path/parser.py:
--------------------------------------------------------------------------------
1 | # SVG Path specification parser
2 |
3 | import re
4 | from . import path
5 |
6 | COMMANDS = set("MmZzLlHhVvCcSsQqTtAa")
7 | UPPERCASE = set("MZLHVCSQTA")
8 |
9 | COMMAND_RE = re.compile(r"([MmZzLlHhVvCcSsQqTtAa])")
10 | FLOAT_RE = re.compile(r"[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?")
11 |
12 |
13 | def _tokenize_path(pathdef):
14 | for x in COMMAND_RE.split(pathdef):
15 | if x in COMMANDS:
16 | yield x
17 | for token in FLOAT_RE.findall(x):
18 | yield token
19 |
20 |
21 | def parse_path(pathdef, current_pos=0j):
22 | # In the SVG specs, initial movetos are absolute, even if
23 | # specified as 'm'. This is the default behavior here as well.
24 | # But if you pass in a current_pos variable, the initial moveto
25 | # will be relative to that current_pos. This is useful.
26 | elements = list(_tokenize_path(pathdef))
27 | # Reverse for easy use of .pop()
28 | elements.reverse()
29 |
30 | segments = path.Path()
31 | start_pos = None
32 | command = None
33 |
34 | while elements:
35 |
36 | if elements[-1] in COMMANDS:
37 | # New command.
38 | last_command = command # Used by S and T
39 | command = elements.pop()
40 | absolute = command in UPPERCASE
41 | command = command.upper()
42 | else:
43 | # If this element starts with numbers, it is an implicit command
44 | # and we don't change the command. Check that it's allowed:
45 | if command is None:
46 | raise ValueError(
47 | "Unallowed implicit command in %s, position %s"
48 | % (pathdef, len(pathdef.split()) - len(elements))
49 | )
50 | last_command = command # Used by S and T
51 |
52 | if command == "M":
53 | # Moveto command.
54 | x = elements.pop()
55 | y = elements.pop()
56 | pos = float(x) + float(y) * 1j
57 | if absolute:
58 | current_pos = pos
59 | else:
60 | current_pos += pos
61 | segments.append(path.Move(current_pos))
62 | # when M is called, reset start_pos
63 | # This behavior of Z is defined in svg spec:
64 | # http://www.w3.org/TR/SVG/paths.html#PathDataClosePathCommand
65 | start_pos = current_pos
66 |
67 | # Implicit moveto commands are treated as lineto commands.
68 | # So we set command to lineto here, in case there are
69 | # further implicit commands after this moveto.
70 | command = "L"
71 |
72 | elif command == "Z":
73 | # Close path
74 | segments.append(path.Close(current_pos, start_pos))
75 | current_pos = start_pos
76 | start_pos = None
77 | command = None # You can't have implicit commands after closing.
78 |
79 | elif command == "L":
80 | x = elements.pop()
81 | y = elements.pop()
82 | pos = float(x) + float(y) * 1j
83 | if not absolute:
84 | pos += current_pos
85 | segments.append(path.Line(current_pos, pos))
86 | current_pos = pos
87 |
88 | elif command == "H":
89 | x = elements.pop()
90 | pos = float(x) + current_pos.imag * 1j
91 | if not absolute:
92 | pos += current_pos.real
93 | segments.append(path.Line(current_pos, pos))
94 | current_pos = pos
95 |
96 | elif command == "V":
97 | y = elements.pop()
98 | pos = current_pos.real + float(y) * 1j
99 | if not absolute:
100 | pos += current_pos.imag * 1j
101 | segments.append(path.Line(current_pos, pos))
102 | current_pos = pos
103 |
104 | elif command == "C":
105 | control1 = float(elements.pop()) + float(elements.pop()) * 1j
106 | control2 = float(elements.pop()) + float(elements.pop()) * 1j
107 | end = float(elements.pop()) + float(elements.pop()) * 1j
108 |
109 | if not absolute:
110 | control1 += current_pos
111 | control2 += current_pos
112 | end += current_pos
113 |
114 | segments.append(path.CubicBezier(current_pos, control1, control2, end))
115 | current_pos = end
116 |
117 | elif command == "S":
118 | # Smooth curve. First control point is the "reflection" of
119 | # the second control point in the previous path.
120 |
121 | if last_command not in "CS":
122 | # If there is no previous command or if the previous command
123 | # was not an C, c, S or s, assume the first control point is
124 | # coincident with the current point.
125 | control1 = current_pos
126 | else:
127 | # The first control point is assumed to be the reflection of
128 | # the second control point on the previous command relative
129 | # to the current point.
130 | control1 = current_pos + current_pos - segments[-1].control2
131 |
132 | control2 = float(elements.pop()) + float(elements.pop()) * 1j
133 | end = float(elements.pop()) + float(elements.pop()) * 1j
134 |
135 | if not absolute:
136 | control2 += current_pos
137 | end += current_pos
138 |
139 | segments.append(path.CubicBezier(current_pos, control1, control2, end))
140 | current_pos = end
141 |
142 | elif command == "Q":
143 | control = float(elements.pop()) + float(elements.pop()) * 1j
144 | end = float(elements.pop()) + float(elements.pop()) * 1j
145 |
146 | if not absolute:
147 | control += current_pos
148 | end += current_pos
149 |
150 | segments.append(path.QuadraticBezier(current_pos, control, end))
151 | current_pos = end
152 |
153 | elif command == "T":
154 | # Smooth curve. Control point is the "reflection" of
155 | # the second control point in the previous path.
156 |
157 | if last_command not in "QT":
158 | # If there is no previous command or if the previous command
159 | # was not an Q, q, T or t, assume the first control point is
160 | # coincident with the current point.
161 | control = current_pos
162 | else:
163 | # The control point is assumed to be the reflection of
164 | # the control point on the previous command relative
165 | # to the current point.
166 | control = current_pos + current_pos - segments[-1].control
167 |
168 | end = float(elements.pop()) + float(elements.pop()) * 1j
169 |
170 | if not absolute:
171 | end += current_pos
172 |
173 | segments.append(path.QuadraticBezier(current_pos, control, end))
174 | current_pos = end
175 |
176 | elif command == "A":
177 | radius = float(elements.pop()) + float(elements.pop()) * 1j
178 | rotation = float(elements.pop())
179 | arc = float(elements.pop())
180 | sweep = float(elements.pop())
181 | end = float(elements.pop()) + float(elements.pop()) * 1j
182 |
183 | if not absolute:
184 | end += current_pos
185 |
186 | segments.append(path.Arc(current_pos, radius, rotation, arc, sweep, end))
187 | current_pos = end
188 |
189 | return segments
190 |
--------------------------------------------------------------------------------
/python3.9libs/tinycss/__init__.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss
4 | -------
5 |
6 | A CSS parser, and nothing else.
7 |
8 | :copyright: (c) 2012 by Simon Sapin.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 |
12 | from .version import VERSION
13 |
14 | from .css21 import CSS21Parser
15 | from .page3 import CSSPage3Parser
16 | from .fonts3 import CSSFonts3Parser
17 |
18 |
19 | __version__ = VERSION
20 |
21 | PARSER_MODULES = {
22 | 'page3': CSSPage3Parser,
23 | 'fonts3': CSSFonts3Parser,
24 | }
25 |
26 |
27 | def make_parser(*features, **kwargs):
28 | """Make a parser object with the chosen features.
29 |
30 | :param features:
31 | Positional arguments are base classes the new parser class will extend.
32 | The string ``'page3'`` is accepted as short for
33 | :class:`~page3.CSSPage3Parser`.
34 | The string ``'fonts3'`` is accepted as short for
35 | :class:`~fonts3.CSSFonts3Parser`.
36 | :param kwargs:
37 | Keyword arguments are passed to the parser’s constructor.
38 | :returns:
39 | An instance of a new subclass of :class:`CSS21Parser`
40 |
41 | """
42 | if features:
43 | bases = tuple(PARSER_MODULES.get(f, f) for f in features)
44 | parser_class = type('CustomCSSParser', bases + (CSS21Parser,), {})
45 | else:
46 | parser_class = CSS21Parser
47 | return parser_class(**kwargs)
48 |
--------------------------------------------------------------------------------
/python3.9libs/tinycss/fonts3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.colors3
4 | ---------------
5 |
6 | Parser for CSS 3 Fonts syntax:
7 | https://www.w3.org/TR/css-fonts-3/
8 |
9 | Adds support for font-face and font-feature-values rules.
10 |
11 | :copyright: (c) 2016 by Kozea.
12 | :license: BSD, see LICENSE for more details.
13 | """
14 |
15 | from __future__ import division, unicode_literals
16 |
17 | from .css21 import CSS21Parser, ParseError
18 |
19 |
20 | class FontFaceRule(object):
21 | """A parsed at-rule for font faces.
22 |
23 | .. attribute:: at_keyword
24 |
25 | Always ``'@font-face'``.
26 |
27 | .. attribute:: declarations
28 |
29 | A list of :class:`~.css21.Declaration` objects.
30 |
31 | .. attribute:: line
32 |
33 | Source line where this was read.
34 |
35 | .. attribute:: column
36 |
37 | Source column where this was read.
38 |
39 | """
40 |
41 | def __init__(self, at_keyword, declarations, line, column):
42 | assert at_keyword == '@font-face'
43 | self.at_keyword = at_keyword
44 | self.declarations = declarations
45 | self.line = line
46 | self.column = column
47 |
48 |
49 | class FontFeatureValuesRule(object):
50 | """A parsed at-rule for font feature values.
51 |
52 | .. attribute:: at_keyword
53 |
54 | Always ``'@font-feature-values'``.
55 |
56 | .. attribute:: line
57 |
58 | Source line where this was read.
59 |
60 | .. attribute:: column
61 |
62 | Source column where this was read.
63 |
64 | .. attribute:: at_rules
65 |
66 | The list of parsed at-rules inside the @font-feature-values block, in
67 | source order.
68 |
69 | .. attribute:: family_names
70 |
71 | A list of strings representing font families.
72 |
73 | """
74 |
75 | def __init__(self, at_keyword, at_rules, family_names, line, column):
76 | assert at_keyword == '@font-feature-values'
77 | self.at_keyword = at_keyword
78 | self.family_names = family_names
79 | self.at_rules = at_rules
80 | self.line = line
81 | self.column = column
82 |
83 |
84 | class FontFeatureRule(object):
85 | """A parsed at-rule for font features.
86 |
87 | .. attribute:: at_keyword
88 |
89 | One of the 16 following strings:
90 |
91 | * ``@stylistic``
92 | * ``@styleset``
93 | * ``@character-variant``
94 | * ``@swash``
95 | * ``@ornaments``
96 | * ``@annotation``
97 |
98 | .. attribute:: declarations
99 |
100 | A list of :class:`~.css21.Declaration` objects.
101 |
102 | .. attribute:: line
103 |
104 | Source line where this was read.
105 |
106 | .. attribute:: column
107 |
108 | Source column where this was read.
109 |
110 | """
111 |
112 | def __init__(self, at_keyword, declarations, line, column):
113 | self.at_keyword = at_keyword
114 | self.declarations = declarations
115 | self.line = line
116 | self.column = column
117 |
118 |
119 | class CSSFonts3Parser(CSS21Parser):
120 | """Extend :class:`~.css21.CSS21Parser` for `CSS 3 Fonts`_ syntax.
121 |
122 | .. _CSS 3 Fonts: https://www.w3.org/TR/css-fonts-3/
123 |
124 | """
125 |
126 | FONT_FEATURE_VALUES_AT_KEYWORDS = [
127 | '@stylistic',
128 | '@styleset',
129 | '@character-variant',
130 | '@swash',
131 | '@ornaments',
132 | '@annotation',
133 | ]
134 |
135 | def parse_at_rule(self, rule, previous_rules, errors, context):
136 | if rule.at_keyword == '@font-face':
137 | if rule.head:
138 | raise ParseError(
139 | rule.head[0],
140 | 'unexpected {0} token in {1} rule header'.format(
141 | rule.head[0].type, rule.at_keyword))
142 | declarations, body_errors = self.parse_declaration_list(rule.body)
143 | errors.extend(body_errors)
144 | return FontFaceRule(
145 | rule.at_keyword, declarations, rule.line, rule.column)
146 | elif rule.at_keyword == '@font-feature-values':
147 | family_names = tuple(
148 | self.parse_font_feature_values_family_names(rule.head))
149 | at_rules, body_errors = (
150 | self.parse_rules(rule.body or [], '@font-feature-values'))
151 | errors.extend(body_errors)
152 | return FontFeatureValuesRule(
153 | rule.at_keyword, at_rules, family_names,
154 | rule.line, rule.column)
155 | elif rule.at_keyword in self.FONT_FEATURE_VALUES_AT_KEYWORDS:
156 | if context != '@font-feature-values':
157 | raise ParseError(
158 | rule, '{0} rule not allowed in {1}'.format(
159 | rule.at_keyword, context))
160 | declarations, body_errors = self.parse_declaration_list(rule.body)
161 | errors.extend(body_errors)
162 | return FontFeatureRule(
163 | rule.at_keyword, declarations, rule.line, rule.column)
164 | return super(CSSFonts3Parser, self).parse_at_rule(
165 | rule, previous_rules, errors, context)
166 |
167 | def parse_font_feature_values_family_names(self, tokens):
168 | """Parse an @font-feature-values selector.
169 |
170 | :param tokens:
171 | An iterable of token, typically from the ``head`` attribute of
172 | an unparsed :class:`AtRule`.
173 | :returns:
174 | A generator of strings representing font families.
175 | :raises:
176 | :class:`~.parsing.ParseError` on invalid selectors
177 |
178 | """
179 | family = ''
180 | current_string = False
181 | for token in tokens:
182 | if token.type == 'DELIM' and token.value == ',' and family:
183 | yield family
184 | family = ''
185 | current_string = False
186 | elif token.type == 'STRING' and not family and (
187 | current_string is False):
188 | family = token.value
189 | current_string = True
190 | elif token.type == 'IDENT' and not current_string:
191 | if family:
192 | family += ' '
193 | family += token.value
194 | elif token.type != 'S':
195 | family = ''
196 | break
197 | if family:
198 | yield family
199 | else:
200 | raise ParseError(token, 'invalid @font-feature-values selector')
201 |
--------------------------------------------------------------------------------
/python3.9libs/tinycss/page3.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.page3
4 | ------------------
5 |
6 | Support for CSS 3 Paged Media syntax:
7 | http://dev.w3.org/csswg/css3-page/
8 |
9 | Adds support for named page selectors and margin rules.
10 |
11 | :copyright: (c) 2012 by Simon Sapin.
12 | :license: BSD, see LICENSE for more details.
13 | """
14 |
15 | from __future__ import division, unicode_literals
16 |
17 | from .css21 import CSS21Parser, ParseError
18 |
19 |
20 | class MarginRule(object):
21 | """A parsed at-rule for margin box.
22 |
23 | .. attribute:: at_keyword
24 |
25 | One of the 16 following strings:
26 |
27 | * ``@top-left-corner``
28 | * ``@top-left``
29 | * ``@top-center``
30 | * ``@top-right``
31 | * ``@top-right-corner``
32 | * ``@bottom-left-corner``
33 | * ``@bottom-left``
34 | * ``@bottom-center``
35 | * ``@bottom-right``
36 | * ``@bottom-right-corner``
37 | * ``@left-top``
38 | * ``@left-middle``
39 | * ``@left-bottom``
40 | * ``@right-top``
41 | * ``@right-middle``
42 | * ``@right-bottom``
43 |
44 | .. attribute:: declarations
45 |
46 | A list of :class:`~.css21.Declaration` objects.
47 |
48 | .. attribute:: line
49 |
50 | Source line where this was read.
51 |
52 | .. attribute:: column
53 |
54 | Source column where this was read.
55 |
56 | """
57 |
58 | def __init__(self, at_keyword, declarations, line, column):
59 | self.at_keyword = at_keyword
60 | self.declarations = declarations
61 | self.line = line
62 | self.column = column
63 |
64 |
65 | class CSSPage3Parser(CSS21Parser):
66 | """Extend :class:`~.css21.CSS21Parser` for `CSS 3 Paged Media`_ syntax.
67 |
68 | .. _CSS 3 Paged Media: http://dev.w3.org/csswg/css3-page/
69 |
70 | Compared to CSS 2.1, the ``at_rules`` and ``selector`` attributes of
71 | :class:`~.css21.PageRule` objects are modified:
72 |
73 | * ``at_rules`` is not always empty, it is a list of :class:`MarginRule`
74 | objects.
75 |
76 | * ``selector``, instead of a single string, is a tuple of the page name
77 | and the pseudo class. Each of these may be a ``None`` or a string.
78 |
79 | +--------------------------+------------------------+
80 | | CSS | Parsed selectors |
81 | +==========================+========================+
82 | | .. code-block:: css | .. code-block:: python |
83 | | | |
84 | | @page {} | (None, None) |
85 | | @page :first {} | (None, 'first') |
86 | | @page chapter {} | ('chapter', None) |
87 | | @page table:right {} | ('table', 'right') |
88 | +--------------------------+------------------------+
89 |
90 | """
91 |
92 | PAGE_MARGIN_AT_KEYWORDS = [
93 | '@top-left-corner',
94 | '@top-left',
95 | '@top-center',
96 | '@top-right',
97 | '@top-right-corner',
98 | '@bottom-left-corner',
99 | '@bottom-left',
100 | '@bottom-center',
101 | '@bottom-right',
102 | '@bottom-right-corner',
103 | '@left-top',
104 | '@left-middle',
105 | '@left-bottom',
106 | '@right-top',
107 | '@right-middle',
108 | '@right-bottom',
109 | ]
110 |
111 | def parse_at_rule(self, rule, previous_rules, errors, context):
112 | if rule.at_keyword in self.PAGE_MARGIN_AT_KEYWORDS:
113 | if context != '@page':
114 | raise ParseError(
115 | rule, '{0} rule not allowed in {1}'.format(
116 | rule.at_keyword, context))
117 | if rule.head:
118 | raise ParseError(
119 | rule.head[0],
120 | 'unexpected {0} token in {1} rule header'.format(
121 | rule.head[0].type, rule.at_keyword))
122 | declarations, body_errors = self.parse_declaration_list(rule.body)
123 | errors.extend(body_errors)
124 | return MarginRule(
125 | rule.at_keyword, declarations, rule.line, rule.column)
126 | return super(CSSPage3Parser, self).parse_at_rule(
127 | rule, previous_rules, errors, context)
128 |
129 | def parse_page_selector(self, head):
130 | """Parse an @page selector.
131 |
132 | :param head:
133 | The ``head`` attribute of an unparsed :class:`AtRule`.
134 | :returns:
135 | A page selector. For CSS 2.1, this is 'first', 'left', 'right'
136 | or None. 'blank' is added by GCPM.
137 | :raises:
138 | :class`~parsing.ParseError` on invalid selectors
139 |
140 | """
141 | if not head:
142 | return (None, None), (0, 0, 0)
143 | if head[0].type == 'IDENT':
144 | name = head.pop(0).value
145 | while head and head[0].type == 'S':
146 | head.pop(0)
147 | if not head:
148 | return (name, None), (1, 0, 0)
149 | name_specificity = (1,)
150 | else:
151 | name = None
152 | name_specificity = (0,)
153 | if (len(head) == 2 and head[0].type == ':' and
154 | head[1].type == 'IDENT'):
155 | pseudo_class = head[1].value
156 | specificity = {
157 | 'first': (1, 0), 'blank': (1, 0),
158 | 'left': (0, 1), 'right': (0, 1),
159 | }.get(pseudo_class)
160 | if specificity:
161 | return (name, pseudo_class), (name_specificity + specificity)
162 | raise ParseError(head[0], 'invalid @page selector')
163 |
--------------------------------------------------------------------------------
/python3.9libs/tinycss/parsing.py:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | """
3 | tinycss.parsing
4 | ---------------
5 |
6 | Utilities for parsing lists of tokens.
7 |
8 | :copyright: (c) 2012 by Simon Sapin.
9 | :license: BSD, see LICENSE for more details.
10 | """
11 |
12 | from __future__ import unicode_literals
13 |
14 |
15 | # TODO: unit tests
16 |
17 | def split_on_comma(tokens):
18 | """Split a list of tokens on commas, ie ``,`` DELIM tokens.
19 |
20 | Only "top-level" comma tokens are splitting points, not commas inside a
21 | function or other :class:`ContainerToken`.
22 |
23 | :param tokens:
24 | An iterable of :class:`~.token_data.Token` or
25 | :class:`~.token_data.ContainerToken`.
26 | :returns:
27 | A list of lists of tokens
28 |
29 | """
30 | parts = []
31 | this_part = []
32 | for token in tokens:
33 | if token.type == 'DELIM' and token.value == ',':
34 | parts.append(this_part)
35 | this_part = []
36 | else:
37 | this_part.append(token)
38 | parts.append(this_part)
39 | return parts
40 |
41 |
42 | def strip_whitespace(tokens):
43 | """Remove whitespace at the beggining and end of a token list.
44 |
45 | Whitespace tokens in-between other tokens in the list are preserved.
46 |
47 | :param tokens:
48 | A list of :class:`~.token_data.Token` or
49 | :class:`~.token_data.ContainerToken`.
50 | :return:
51 | A new sub-sequence of the list.
52 |
53 | """
54 | for i, token in enumerate(tokens):
55 | if token.type != 'S':
56 | break
57 | else:
58 | return [] # only whitespace
59 | tokens = tokens[i:]
60 | while tokens and tokens[-1].type == 'S':
61 | tokens.pop()
62 | return tokens
63 |
64 |
65 | def remove_whitespace(tokens):
66 | """Remove any top-level whitespace in a token list.
67 |
68 | Whitespace tokens inside recursive :class:`~.token_data.ContainerToken`
69 | are preserved.
70 |
71 | :param tokens:
72 | A list of :class:`~.token_data.Token` or
73 | :class:`~.token_data.ContainerToken`.
74 | :return:
75 | A new sub-sequence of the list.
76 |
77 | """
78 | return [token for token in tokens if token.type != 'S']
79 |
80 |
81 | def validate_value(tokens):
82 | """Validate a property value.
83 |
84 | :param tokens:
85 | an iterable of tokens
86 | :raises:
87 | :class:`ParseError` if there is any invalid token for the 'value'
88 | production of the core grammar.
89 |
90 | """
91 | for token in tokens:
92 | type_ = token.type
93 | if type_ == '{':
94 | validate_block(token.content, 'property value')
95 | else:
96 | validate_any(token, 'property value')
97 |
98 |
99 | def validate_block(tokens, context):
100 | """
101 | :raises:
102 | :class:`ParseError` if there is any invalid token for the 'block'
103 | production of the core grammar.
104 | :param tokens: an iterable of tokens
105 | :param context: a string for the 'unexpected in ...' message
106 |
107 | """
108 | for token in tokens:
109 | type_ = token.type
110 | if type_ == '{':
111 | validate_block(token.content, context)
112 | elif type_ not in (';', 'ATKEYWORD'):
113 | validate_any(token, context)
114 |
115 |
116 | def validate_any(token, context):
117 | """
118 | :raises:
119 | :class:`ParseError` if this is an invalid token for the
120 | 'any' production of the core grammar.
121 | :param token: a single token
122 | :param context: a string for the 'unexpected in ...' message
123 |
124 | """
125 | type_ = token.type
126 | if type_ in ('FUNCTION', '(', '['):
127 | for token in token.content:
128 | validate_any(token, type_)
129 | elif type_ not in ('S', 'IDENT', 'DIMENSION', 'PERCENTAGE', 'NUMBER',
130 | 'INTEGER', 'URI', 'DELIM', 'STRING', 'HASH', ':',
131 | 'UNICODE-RANGE'):
132 | if type_ in ('}', ')', ']'):
133 | adjective = 'unmatched'
134 | else:
135 | adjective = 'unexpected'
136 | raise ParseError(
137 | token, '{0} {1} token in {2}'.format(adjective, type_, context))
138 |
139 |
140 | class ParseError(ValueError):
141 | """Details about a CSS syntax error. Usually indicates that something
142 | (a rule or a declaration) was ignored and will not appear as a parsed
143 | object.
144 |
145 | This exception is typically logged in a list rather than being propagated
146 | to the user API.
147 |
148 | .. attribute:: line
149 |
150 | Source line where the error occured.
151 |
152 | .. attribute:: column
153 |
154 | Column in the source line where the error occured.
155 |
156 | .. attribute:: reason
157 |
158 | What happend (a string).
159 |
160 | """
161 | def __init__(self, subject, reason):
162 | self.line = subject.line
163 | self.column = subject.column
164 | self.reason = reason
165 | super(ParseError, self).__init__(
166 | 'Parse error at {0.line}:{0.column}, {0.reason}'.format(self))
167 |
--------------------------------------------------------------------------------
/python3.9libs/tinycss/version.py:
--------------------------------------------------------------------------------
1 | VERSION = '0.4'
2 |
--------------------------------------------------------------------------------
/scripts/python/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/scripts/python/__init__.py
--------------------------------------------------------------------------------
/scripts/python/ae_tools.py:
--------------------------------------------------------------------------------
1 | import hou
2 |
3 | # ========================
4 | # Utils
5 | # ========================
6 |
7 | def get_all_hda_definitions():
8 | result = []
9 | for category in hou.nodeTypeCategories().values():
10 | for node_type in category.nodeTypes().values():
11 | definition = node_type.definition()
12 | if definition is None:
13 | continue
14 | if definition not in result:
15 | result.append(definition)
16 | return result
17 |
18 | def filter_aelib_hdadefs(defs):
19 | return [d for d in defs if "ae::" in d.nodeTypeName()]
20 |
21 | def get_aelib_hdadefs():
22 | alldefs = get_all_hda_definitions()
23 | return filter_aelib_hdadefs(alldefs)
24 |
25 | def set_oncreated(defs):
26 | for d in defs:
27 | if "OnCreated" in defs.sections().keys():
28 | s = defs.sections["OnCreated"]
29 | oncr = s.contents()
30 | oncr += "\n"
31 | oncr += "#TEST"
32 | s.setContents(oncr)
33 | else:
34 | new_oncreated = d.addSection("OnCreated", contents="#TEST")
35 |
36 | def camel_to_underscored(s):
37 | # doesnt convert lower case
38 | # dont use this.. dangerous
39 | return ''.join(['_'+c if c.isupper() else c for c in s]).lstrip('_')
40 |
41 | def replace_underscored_in_hda_label_with_spaces(defs):
42 | for d in defs:
43 | des = d.description()
44 | # x = camel_to_underscored(des)
45 | # print(x)
46 | x = des.replace("_", " ")
47 | print(x)
48 | d.setDescription(x)
49 |
--------------------------------------------------------------------------------
/scripts/python/atcq/ATCQ_Widget.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 |
3 | import sys, os
4 | try:
5 | from pathlib import Path
6 | import urllib.request as url
7 | except:
8 | from pathlib2 import Path
9 | import urllib2 as url
10 |
11 | try:
12 | import hou
13 | import toolutils
14 | except:
15 | pass
16 |
17 | from PIL import Image
18 | import json
19 |
20 | import numpy as np
21 |
22 | from PySide2.QtGui import *
23 | from PySide2.QtWidgets import *
24 | from PySide2 import QtCore
25 | from PySide2.QtWebEngineWidgets import QWebEngineView
26 | from PySide2.QtWebChannel import QWebChannel
27 |
28 | # Can we use the houdini embedded browser at all? https://www.sidefx.com/docs/houdini/hom/browserpython.html
29 |
30 | '''
31 | TODO
32 | Cache the quantize result so we can change the target colours without redoing
33 | improve button layout
34 | add this stuff to palette manager base
35 | '''
36 |
37 | class ATCQ_Dialog(QDialog):
38 | def __init__(self, node=None):
39 | super(ATCQ_Dialog, self).__init__()
40 | self.SCRIPT_PATH = Path(os.path.realpath(__file__)).parent
41 | self.node = node
42 | self.initUI()
43 |
44 | def initUI(self):
45 | QtCore.qInstallMessageHandler(self.handler) # ignore warnings
46 |
47 | vbox = QVBoxLayout(self)
48 | self.webEngineView = QWebEngineView()
49 |
50 | self.channel = QWebChannel()
51 | self.channel.registerObject("atcq", self)
52 | self.webEngineView.page().setWebChannel(self.channel)
53 | self.webEngineView.loadFinished.connect(self.on_load_finished)
54 | self.load_page()
55 |
56 | vbox.addWidget(self.webEngineView)
57 | self.setLayout(vbox)
58 | self.setGeometry(100, 100, 650, 250)
59 | self.setWindowTitle('ATCQ')
60 | self.show()
61 |
62 | def handler(self, msg_type, msg_log_context, msg_string):
63 | pass
64 |
65 | def load_page(self):
66 | # SETHTML DO NOT USE! This will not initialise the working directory and so you cannot load external js, css etc
67 | # MUST use setURL with the correct local URL for imports to work
68 | file = str(self.SCRIPT_PATH.joinpath("web/index.html"))
69 | self.webEngineView.setUrl(QtCore.QUrl.fromLocalFile(file))
70 |
71 | @QtCore.Slot()
72 | def on_load_finished(self):
73 | p = str(self.SCRIPT_PATH.joinpath("atcq_image.png"))
74 | pp = p.replace("\\", "/")
75 | self.webEngineView.page().runJavaScript("window.setImagePath('{}');".format(pp))
76 |
77 | @QtCore.Slot(str)
78 | def resize(self, file):
79 | try:
80 | im = Image.open(file)
81 | print("file image resized")
82 | except:
83 | im = Image.open(url.urlopen(file))
84 | print("url image resized")
85 | sc = im.resize((350,350))
86 | write_path = str(self.SCRIPT_PATH.joinpath("atcq_image.png"))
87 | sc.save(write_path, format="PNG")
88 | print("resized image")
89 | self.webEngineView.page().runJavaScript('window.setStatus("Image processed. Quantization will follow...");')
90 |
91 | # https://stackoverflow.com/questions/58210400/how-to-receive-data-from-python-to-js-using-qwebchannel
92 | # @QtCore.Slot(str) @QtCore.Slot(QJsonValue) @QtCore.Slot("QJsonObject") @QtCore.Slot(list)
93 | @QtCore.Slot(str, str) # generic json str which we parse
94 | def send_palette(self, palette, weights):
95 | self.palette = json.loads(palette)
96 | self.weights = json.loads(weights)
97 | self.setPaletteManagerRamp()
98 |
99 | @QtCore.Slot(str)
100 | def print(self, t):
101 | print(t)
102 |
103 | @QtCore.Slot(float)
104 | def exit(self, a):
105 | sys.exit()
106 |
107 | '''
108 | Setting Ramp on the Palette Manager
109 | '''
110 |
111 | def colourConvert(self, col):
112 | c = col
113 | if (sum(col) / float(len(col)) > 1.0):
114 | c = [a / 255.0 for a in col]
115 | return tuple(c)
116 |
117 | # process these in the palette manager
118 | def setPaletteManagerRamp(self):
119 | ramp = self.node.parm("ramp")
120 | nodes = len(self.palette)
121 |
122 | wts = self.weights
123 | wts.insert(0, 0) # prepend 0 so cumsum gives us the correct positions
124 | placements = np.cumsum(wts)
125 |
126 | ramp.set(nodes)
127 | for i in range(nodes):
128 | posParm = self.node.parm(ramp.name() + str(i + 1) + "pos")
129 | posParm.set(placements[i])
130 |
131 | # set colours, check if hex or rgb triplet
132 | v = self.palette[i % len(self.palette)]
133 | clrParm = self.node.parmTuple(ramp.name() + str(i + 1) + "c")
134 | clrParm.set(self.colourConvert(v))
135 |
136 | # set basis to constant
137 | basisParm = self.node.parm(ramp.name() + str(i + 1) + "interp")
138 | basisParm.set(0)
139 |
140 | def main():
141 | app = QApplication(sys.argv)
142 | ex = ATCQ_Dialog()
143 | ex.show()
144 | app.exec_()
145 | # sys.exit(app.exec_())
146 |
147 | if __name__ == '__main__':
148 | main()
149 |
150 | # note on returning values to js without calling js function explicitly?
151 | # https://stackoverflow.com/questions/58210400/how-to-receive-data-from-python-to-js-using-qwebchannel
152 | # In C++ so that a method can return a value it must be declared as Q_INVOKABLE and the equivalent in PyQt is to use result in the @pyqtSlot decorator:
153 | # @QtCore.pyqtSlot(int, result=int)
154 | # def getRef(self, x):
155 | # print("inside getRef", x)
156 | # return x + 5
--------------------------------------------------------------------------------
/scripts/python/atcq/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/scripts/python/atcq/__init__.py
--------------------------------------------------------------------------------
/scripts/python/atcq/atcq_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Aeoll/Aelib/fafd51467f86e8ff57bffb78c09f28ceceba4554/scripts/python/atcq/atcq_image.png
--------------------------------------------------------------------------------
/scripts/python/atcq/web/css/main.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 14px;
3 | padding: 14px;
4 | }
5 |
6 | label {
7 | display: inline-block;
8 | clear: left;
9 | width: 160px;
10 | text-align: right;
11 | }
12 |
13 | input {
14 | display: inline-block;
15 | width: 100px;
16 | }
17 |
18 | .inputwide{
19 | display: inline-block;
20 | width: 300px;
21 | }
22 |
--------------------------------------------------------------------------------
/scripts/python/atcq/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/vex/include/array2d.h:
--------------------------------------------------------------------------------
1 | #ifndef __arrays_detail_
2 | #define __arrays_detail_
3 |
4 | // Macros for easier array2d method usage
5 | #define set2d(arr, x, y, val) arr.f[x * arr.cols + y] = val
6 | #define get2d(arr, x, y) arr.f[x * arr.cols + y]
7 |
8 | #define a2d(var, r, c) \
9 | array2d var; \
10 | var->init(r, c)
11 |
12 | #define zeros(var, r, c) \
13 | array2d var; \
14 | var->init(r, c, 0.0)
15 |
16 | // Want to support int, float, vector array2d but its not straightforward? keep them separate? array2di/array2df/array2dv?
17 | // separate structs? this would mean reproducing a of functions..?
18 | struct array2d
19 | {
20 | int rows;
21 | int cols;
22 | float f[];
23 |
24 | function void init()
25 | {
26 | resize(f, rows * cols);
27 | }
28 |
29 | function void init(int r; int c)
30 | {
31 | rows = r;
32 | cols = c;
33 | resize(f, rows * cols);
34 | }
35 |
36 | // initialise with value for all?
37 | function void init(int r; int c; float val)
38 | {
39 | rows = r;
40 | cols = c;
41 | resize(f, rows * cols);
42 | for (int i = 0; i < len(f); i++)
43 | {
44 | f[i] = val;
45 | }
46 | }
47 |
48 | function void init(int r; int c; float a[])
49 | {
50 | rows = r;
51 | cols = c;
52 | resize(f, rows * cols);
53 | f = a;
54 | }
55 |
56 | // =======================================
57 | // Utility
58 | // =======================================
59 | void resize(int r; int c)
60 | {
61 | rows = r;
62 | cols = c;
63 | resize(f, rows * cols);
64 | }
65 |
66 | vector2 index(int i)
67 | {
68 | int x = int(i / cols);
69 | int y = int(i % cols);
70 | return set(x, y);
71 | }
72 |
73 | int index(vector2 xy)
74 | {
75 | return int(xy.x * cols) + int(xy.y);
76 | }
77 |
78 | // not finished
79 | int l(int x; int y)
80 | {
81 | if (x >= cols || y >= rows)
82 | {
83 | return -1;
84 | }
85 | else
86 | {
87 | return x - 1;
88 | }
89 | }
90 |
91 | float getf(int x; int y)
92 | {
93 | return f[x * cols + y];
94 | }
95 |
96 | void setf(int x; int y; float v)
97 | {
98 | f[x * cols + y] = v;
99 | }
100 |
101 | // slice the current array2d along both axes
102 | // TODO still not working?
103 | array2d subarray(int x_min; int x_max; int y_min; int y_max)
104 | {
105 | array2d sub;
106 | int r = x_max - x_min;
107 | int c = y_max - y_min;
108 | sub->init(r, c);
109 | for (int i = 0; i < r; i++)
110 | {
111 | for (int j = 0; j < c; j++)
112 | {
113 | float v = this->getf(x_min + i, y_min + j);
114 | sub->setf(i, j, v);
115 | }
116 | }
117 | return sub;
118 | }
119 |
120 | // sets all values of the array2d subarray to val
121 | // TODO not working atm...
122 | void setSubarray(int x_min; int x_max; int y_min; int y_max; float val)
123 | {
124 | int r = x_max - x_min;
125 | int c = y_max - y_min;
126 | for (int i = 0; i < r; i++)
127 | {
128 | for (int j = 0; j < c; j++)
129 | {
130 | this->setf(x_min + i, y_min + j, val);
131 | }
132 | }
133 | }
134 |
135 | // count number of nonzero elements
136 | int count_nonzero()
137 | {
138 | int c = 0;
139 | foreach (float val; f)
140 | {
141 | c += (val != 0) ? 1 : 0;
142 | }
143 | return c;
144 | }
145 |
146 | // get nonzero elements
147 | // any advantage to returning array of vec2 instead of array2d like python does?
148 | vector2[] nonzero()
149 | {
150 | vector2 nonzero[];
151 | foreach (int ind; float val; f)
152 | {
153 | if (val != 0)
154 | {
155 | vector2 xy = this->index(ind);
156 | append(nonzero, xy);
157 | }
158 | }
159 | return nonzero;
160 | }
161 |
162 | // print
163 | void print2d()
164 | {
165 | printf("%dx%d\n", rows, cols);
166 | for (int i = 0; i < rows; i++)
167 | {
168 | int y = cols * i;
169 | int x = (i * cols) + cols;
170 | printf("%g)\t%8d\n ", i + 1, slice(f, y, x));
171 | }
172 | }
173 | };
174 |
175 | #endif
--------------------------------------------------------------------------------
/vex/include/array3d.h:
--------------------------------------------------------------------------------
1 | #ifndef __arrays3d_detail_
2 | #define __arrays3d_detail_
3 |
4 | // Macros for easier array3d method usage
5 | #define set3d(arr, x, y, z, val) arr.f[x + y * arr.cols + z * arr.rows * arr.cols] = val
6 | #define get3d(arr, x, y, z) arr.f[x + y * arr.cols + z * arr.rows * arr.cols]
7 |
8 | #define a3d(var, r, c, s) \
9 | array3d var; \
10 | var->init(r, c, s)
11 |
12 | #define zeros(var, r, c, s) \
13 | array3d var; \
14 | var->init(r, c, s, 0.0)
15 |
16 | // Want to support int, float, vector array3d but its not straightforward? keep them separate? array3di/array3df/array3dv?
17 | // separate structs? this would mean reproducing a of functions..?
18 | struct array3d
19 | {
20 | int rows;
21 | int cols;
22 | int slices;
23 | float f[];
24 |
25 | function void init()
26 | {
27 | resize(f, rows * cols * slices);
28 | }
29 |
30 | function void init(int r; int c; int s)
31 | {
32 | rows = r;
33 | cols = c;
34 | slices = s;
35 | resize(f, rows * cols * slices);
36 | }
37 |
38 | // initialise with value for all?
39 | function void init(int r; int c; int s; float val)
40 | {
41 | rows = r;
42 | cols = c;
43 | slices = s;
44 | resize(f, rows * cols * slices);
45 | for (int i = 0; i < len(f); i++)
46 | {
47 | f[i] = val;
48 | }
49 | }
50 |
51 | function void init(int r; int c; int s; float a[])
52 | {
53 | rows = r;
54 | cols = c;
55 | slices = s;
56 | resize(f, rows * cols * slices);
57 | f = a;
58 | }
59 |
60 | // =======================================
61 | // Utility
62 | // =======================================
63 | void resize(int r; int c; int s)
64 | {
65 | cols = c;
66 | rows = r;
67 | slices = s;
68 | resize(f, rows * cols * slices);
69 | }
70 |
71 | vector index(int i)
72 | {
73 | // int x = int(i/cols);
74 | // int y = int(i%cols);
75 | // int z = int(i/(rows*cols));
76 | int z = int(i / (rows * cols));
77 | int i2 = i - (z * rows * cols);
78 | int y = int(i2 / cols);
79 | int x = int(i2 % cols);
80 | return set(x, y, z);
81 | }
82 |
83 | int index(vector xyz)
84 | {
85 | return int(xyz.x) + int(xyz.y * cols) + int(xyz.z * rows * cols);
86 | }
87 |
88 | int printlen()
89 | {
90 | printf("%d", len(f));
91 | }
92 |
93 | float getf(int x; int y; int z)
94 | {
95 | float a = f[x + cols * y + z * rows * cols];
96 | return a;
97 | }
98 |
99 | void setf(int x; int y; int z; float v)
100 | {
101 | f[x + y * cols + z * rows * cols] = v;
102 | }
103 |
104 | // slice the current array3d along axes
105 | // TODO still not working?
106 | array3d subarray(int x_min; int x_max; int y_min; int y_max; int z_min; int z_max)
107 | {
108 | array3d sub;
109 | int c = x_max - x_min;
110 | int r = y_max - y_min;
111 | int s = z_max - z_min;
112 | sub->init(r, c, s);
113 | for (int i = 0; i < c; i++)
114 | {
115 | for (int j = 0; j < r; j++)
116 | {
117 | for (int k = 0; k < s; k++)
118 | {
119 | float v = this->getf(x_min + i, y_min + j, z_min + k);
120 | sub->setf(i, j, k, v);
121 | }
122 | }
123 | }
124 | sub->resize(r, c, s); // this breaks things but appears to be necessary???
125 | return sub;
126 | }
127 |
128 | // sets all values of the array3d subarray to val
129 | // TODO not working atm...
130 | void setSubarray(int x_min; int x_max; int y_min; int y_max; int z_min; int z_max; float val)
131 | {
132 | int c = x_max - x_min;
133 | int r = y_max - y_min;
134 | int s = z_max - z_min;
135 | for (int i = 0; i < c; i++)
136 | {
137 | for (int j = 0; j < r; j++)
138 | {
139 | for (int k = 0; l < s; k++)
140 | {
141 | this->setf(x_min + i, y_min + j, z_min + k, val);
142 | }
143 | }
144 | }
145 | }
146 |
147 | // count number of nonzero elements
148 | int count_nonzero()
149 | {
150 | int c = 0;
151 | for (int i = 0; i < len(f); i++)
152 | {
153 | float val = f[i];
154 | c += (val > 0) ? 1 : 0;
155 | }
156 | return c;
157 | }
158 |
159 | // get nonzero elements
160 | // any advantage to returning array of vec2 instead of array2d like python does?
161 | vector[] nonzero()
162 | {
163 | vector nonzero[];
164 | foreach (int ind; float val; f)
165 | {
166 | if (val != 0)
167 | {
168 | vector xyz = this->index(ind);
169 | append(nonzero, xyz);
170 | }
171 | }
172 | return nonzero;
173 | }
174 |
175 | void print3d()
176 | {
177 | // printf("%dx%dx%d\n", rows, cols, slices);
178 | // for (int i = 0; i < rows; i++) {
179 | // for (int j = 0; j < cols; j++) {
180 | // int y = cols * i;
181 | // int x = (i *cols) + cols;
182 | // printf("%g)\t%8d\n ", i + 1, slice(f, y, x));
183 | // }
184 | // }
185 | printf("array: \n");
186 | for (int k = 0; k < slices; k++)
187 | {
188 | for (int i = 0; i < cols; i++)
189 | {
190 | for (int j = 0; j < rows; j++)
191 | {
192 | float val = this->getf(i, j, k);
193 | printf("%d", val);
194 | }
195 | printf("_\n");
196 | }
197 | printf("____\n");
198 | }
199 | printf("\n");
200 | printf("f: %d\n", f);
201 | }
202 |
203 | void printdim()
204 | {
205 | printf("dimensions: %d\n", set(rows, cols, slices));
206 | }
207 |
208 | void printsize()
209 | {
210 | printf("size: %d\t ", set(rows, cols, slices));
211 | printf("f:%d\n", len(f));
212 | printf("__\n");
213 | }
214 | };
215 |
216 | #endif
--------------------------------------------------------------------------------