@classcad/react-cad 0.0.0-stage → 3.0.0-beta.20261119090857
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +98 -2
- package/build/components/UI/CAD/Constraints.d.ts +30 -0
- package/build/components/UI/CAD/Drawing.d.ts +83 -0
- package/build/components/UI/CAD/ListPlaceholder.d.ts +3 -0
- package/build/components/UI/CAD/Messages/Message.d.ts +8 -0
- package/build/components/UI/CAD/Messages/Messages.d.ts +43 -0
- package/build/components/UI/CAD/Messages/index.d.ts +1 -0
- package/build/components/UI/CAD/Messages/msgStore.d.ts +18 -0
- package/build/components/UI/CAD/ModelTree/AssemblyNode.d.ts +5 -0
- package/build/components/UI/CAD/ModelTree/FeatureList/Feature.d.ts +8 -0
- package/build/components/UI/CAD/ModelTree/FeatureList/FeatureList.d.ts +6 -0
- package/build/components/UI/CAD/ModelTree/FeatureList/index.d.ts +1 -0
- package/build/components/UI/CAD/ModelTree/FeatureList/utils.d.ts +26 -0
- package/build/components/UI/CAD/ModelTree/ModelTree.d.ts +56 -0
- package/build/components/UI/CAD/ModelTree/ModelTreeHeader.d.ts +15 -0
- package/build/components/UI/CAD/ModelTree/index.d.ts +1 -0
- package/build/components/UI/CAD/ModelTree/primitives.d.ts +6 -0
- package/build/components/UI/CAD/ModelTree/useContextMenuItems.d.ts +4 -0
- package/build/components/UI/CAD/PluginBounds.d.ts +8 -0
- package/build/components/UI/CAD/PluginTooltip.d.ts +5 -0
- package/build/components/UI/CAD/PluginsWindows.d.ts +99 -0
- package/build/components/UI/CAD/ReadOnlyContext.d.ts +10 -0
- package/build/components/UI/CAD/SideBar.d.ts +40 -0
- package/build/components/UI/CAD/Solids/Solids.d.ts +23 -0
- package/build/components/UI/CAD/Solids/index.d.ts +1 -0
- package/build/components/UI/CAD/Solids/useContextMenuItems.d.ts +4 -0
- package/build/components/UI/CAD/Solids/useVisibleSolids.d.ts +30 -0
- package/build/components/UI/CAD/StageHud.d.ts +9 -0
- package/build/components/UI/CAD/StatusBar.d.ts +11 -0
- package/build/components/UI/CAD/ThemeToggle.d.ts +25 -0
- package/build/components/UI/CAD/ToolBar/AssemblyModeCmds.d.ts +3 -0
- package/build/components/UI/CAD/ToolBar/PartModeCmds.d.ts +3 -0
- package/build/components/UI/CAD/ToolBar/ToolBar.d.ts +24 -0
- package/build/components/UI/CAD/ToolBar/index.d.ts +1 -0
- package/build/components/UI/CAD/ToolBar/useCommands.d.ts +12 -0
- package/build/components/UI/CAD/ViewOptionsBar/ViewOptionButtons.d.ts +30 -0
- package/build/components/UI/CAD/ViewOptionsBar/useOptionCommands.d.ts +65 -0
- package/build/components/UI/CAD/ViewPlugButtons.d.ts +43 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/DraggableModal.d.ts +18 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/DraggableModalContext.d.ts +9 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/DraggableModalInner.d.ts +27 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/DraggableModalProvider.d.ts +4 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/OverlayScrollbar.d.ts +6 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/ResizeHandle.d.ts +2 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/clamp.d.ts +1 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/draggableModalReducer.d.ts +123 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/getWindowSize.d.ts +4 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/index.d.ts +3 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/useDrag.d.ts +5 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/usePrevious.d.ts +1 -0
- package/build/components/UI/CAD/ant-design-draggable-modal/useResize.d.ts +7 -0
- package/build/components/UI/CAD/common/BlankDiv.d.ts +3 -0
- package/build/components/UI/CAD/common/Collapse.d.ts +13 -0
- package/build/components/UI/CAD/common/ContextMenu.d.ts +115 -0
- package/build/components/UI/CAD/common/Divider.d.ts +4 -0
- package/build/components/UI/CAD/common/EntityName.d.ts +14 -0
- package/build/components/UI/CAD/common/Img.d.ts +6 -0
- package/build/components/UI/CAD/common/LoadingScreen/LoadingScreen.d.ts +8 -0
- package/build/components/UI/CAD/common/LoadingScreen/Spinner.d.ts +3 -0
- package/build/components/UI/CAD/common/LoadingScreen/index.d.ts +1 -0
- package/build/components/UI/CAD/common/Menu.d.ts +81 -0
- package/build/components/UI/CAD/common/MultiSelect.d.ts +12 -0
- package/build/components/UI/CAD/common/NameEdit.d.ts +7 -0
- package/build/components/UI/CAD/common/SectionHeader.d.ts +9 -0
- package/build/components/UI/CAD/common/primitives.d.ts +36 -0
- package/build/components/UI/CAD/common/reveal.d.ts +12 -0
- package/build/components/UI/CAD/hooks/index.d.ts +13 -0
- package/build/components/UI/CAD/hooks/useContextMenuInteraction.d.ts +7 -0
- package/build/components/UI/CAD/hooks/useContextMenuItems.d.ts +4 -0
- package/build/components/UI/CAD/hooks/useCurrentInstance.d.ts +2 -0
- package/build/components/UI/CAD/hooks/useCurrentProduct.d.ts +2 -0
- package/build/components/UI/CAD/hooks/useEditMode.d.ts +40 -0
- package/build/components/UI/CAD/hooks/useFeatureCount.d.ts +6 -0
- package/build/components/UI/CAD/hooks/useGlobalMateInfo.d.ts +6 -0
- package/build/components/UI/CAD/hooks/useHasPending.d.ts +27 -0
- package/build/components/UI/CAD/hooks/useIsDisabled.d.ts +2 -0
- package/build/components/UI/CAD/hooks/useIsLoading.d.ts +25 -0
- package/build/components/UI/CAD/hooks/useIsSketchActive.d.ts +26 -0
- package/build/components/UI/CAD/hooks/useObjectDetails.d.ts +12 -0
- package/build/components/UI/CAD/hooks/useOperationSequence.d.ts +29 -0
- package/build/components/UI/CAD/hooks/useRollbackBar.d.ts +8 -0
- package/build/components/UI/CAD/hooks/useRoot.d.ts +2 -0
- package/build/components/UI/CAD/index.d.ts +27 -0
- package/build/components/UI/CAD/plugins/ProductManagement/ProdTable.d.ts +10 -0
- package/build/components/UI/CAD/plugins/ProductManagement/Root.d.ts +11 -0
- package/build/components/UI/CAD/plugins/ProductManagement/View.d.ts +11 -0
- package/build/components/UI/CAD/plugins/ProductManagement/index.d.ts +34 -0
- package/build/components/UI/CAD/plugins/ProductManagement/types.d.ts +4 -0
- package/build/components/UI/CAD/plugins/ProductManagement/useContextMenuItems.d.ts +4 -0
- package/build/components/UI/CAD/plugins/SessionManagement/Root.d.ts +11 -0
- package/build/components/UI/CAD/plugins/SessionManagement/index.d.ts +36 -0
- package/build/components/UI/CAD/plugins/SessionManagement/types.d.ts +3 -0
- package/build/components/UI/CAD/store/CADActions.d.ts +29 -0
- package/build/components/UI/CAD/store/CADStore.d.ts +68 -0
- package/build/components/UI/CAD/store/instances.d.ts +7 -0
- package/build/components/UI/Readfile.d.ts +39 -0
- package/build/components/UI/ThemeVars.d.ts +6 -0
- package/build/components/UI/editors/BooleanEditor/BooleanEditor.d.ts +8 -0
- package/build/components/UI/editors/BooleanEditor/index.d.ts +2 -0
- package/build/components/UI/editors/BooleanEditor/useBoolParam.d.ts +3 -0
- package/build/components/UI/editors/CSysEditor/CSysEditor.d.ts +11 -0
- package/build/components/UI/editors/CSysEditor/index.d.ts +2 -0
- package/build/components/UI/editors/CSysEditor/useCSysParam.d.ts +9 -0
- package/build/components/UI/editors/ColorEditor/ColorEditor.d.ts +12 -0
- package/build/components/UI/editors/ColorEditor/index.d.ts +2 -0
- package/build/components/UI/editors/ColorEditor/useColorParam.d.ts +9 -0
- package/build/components/UI/editors/ExpressionEditor/ExpressionEditor.d.ts +20 -0
- package/build/components/UI/editors/ExpressionEditor/index.d.ts +2 -0
- package/build/components/UI/editors/ExpressionEditor/useExpressionsParam.d.ts +5 -0
- package/build/components/UI/editors/NumberEditor/Inputs.d.ts +18 -0
- package/build/components/UI/editors/NumberEditor/Mentions.d.ts +10 -0
- package/build/components/UI/editors/NumberEditor/NumOrExpr.d.ts +12 -0
- package/build/components/UI/editors/NumberEditor/NumberEditor.d.ts +12 -0
- package/build/components/UI/editors/NumberEditor/index.d.ts +2 -0
- package/build/components/UI/editors/NumberEditor/useNumParam.d.ts +5 -0
- package/build/components/UI/editors/PointEditor/PointEditor.d.ts +10 -0
- package/build/components/UI/editors/PointEditor/index.d.ts +2 -0
- package/build/components/UI/editors/PointEditor/usePointParam.d.ts +5 -0
- package/build/components/UI/editors/RefsEditors/ChainFinder.d.ts +12 -0
- package/build/components/UI/editors/RefsEditors/MateEditor.d.ts +13 -0
- package/build/components/UI/editors/RefsEditors/MateOrientationEditor.d.ts +9 -0
- package/build/components/UI/editors/RefsEditors/RefEditor.d.ts +24 -0
- package/build/components/UI/editors/RefsEditors/RefsEditor.d.ts +16 -0
- package/build/components/UI/editors/RefsEditors/index.d.ts +8 -0
- package/build/components/UI/editors/RefsEditors/pickers.d.ts +4 -0
- package/build/components/UI/editors/RefsEditors/useIdParam.d.ts +3 -0
- package/build/components/UI/editors/RefsEditors/useMateParam.d.ts +19 -0
- package/build/components/UI/editors/RefsEditors/useModes.d.ts +11 -0
- package/build/components/UI/editors/RefsEditors/useRefsParam.d.ts +3 -0
- package/build/components/UI/editors/RefsEditors/useSelectedItems.d.ts +18 -0
- package/build/components/UI/editors/ToleranceEditor/ToleranceEditor.d.ts +7 -0
- package/build/components/UI/editors/ToleranceEditor/index.d.ts +2 -0
- package/build/components/UI/editors/ToleranceEditor/useToleranceParam.d.ts +3 -0
- package/build/components/UI/editors/TypeEditor/TypeEditor.d.ts +10 -0
- package/build/components/UI/editors/TypeEditor/index.d.ts +2 -0
- package/build/components/UI/editors/TypeEditor/useTypeParam.d.ts +3 -0
- package/build/components/UI/editors/TypeWrapper.d.ts +6 -0
- package/build/components/UI/editors/Wrapper.d.ts +16 -0
- package/build/components/UI/editors/useParam.d.ts +20 -0
- package/build/components/UI/editors/useValidation.d.ts +4 -0
- package/build/components/graphics/Badge.d.ts +70 -0
- package/build/components/graphics/CSysDisplay.d.ts +108 -0
- package/build/components/graphics/CompositeCurveObj.d.ts +33 -0
- package/build/components/graphics/GeometryOverrides/GeometryOverridesManager.d.ts +41 -0
- package/build/components/graphics/GeometryOverrides/GeometryOverridesStore.d.ts +28 -0
- package/build/components/graphics/GeometryOverrides/index.d.ts +2 -0
- package/build/components/graphics/GeometryOverrides/useOverrideGeometryColor.d.ts +36 -0
- package/build/components/graphics/HUD.d.ts +44 -0
- package/build/components/graphics/HoveredConstraintDisplay.d.ts +24 -0
- package/build/components/graphics/InfinityPlane.d.ts +4 -0
- package/build/components/graphics/Outlines/AAPass.d.ts +8 -0
- package/build/components/graphics/Outlines/IDPass.d.ts +12 -0
- package/build/components/graphics/Outlines/Outline.d.ts +62 -0
- package/build/components/graphics/Outlines/OutlineEffect.d.ts +48 -0
- package/build/components/graphics/Outlines/OutlineMaterial.d.ts +9 -0
- package/build/components/graphics/Outlines/WidenPass.d.ts +17 -0
- package/build/components/graphics/PluginGeometryBounds.d.ts +40 -0
- package/build/components/graphics/SelectableMate.d.ts +3 -0
- package/build/components/graphics/SelectedMateObj.d.ts +54 -0
- package/build/components/graphics/StageLook.d.ts +51 -0
- package/build/components/graphics/WorkAxisObj.d.ts +33 -0
- package/build/components/graphics/WorkCSysObj.d.ts +33 -0
- package/build/components/graphics/WorkCoordSystemObj.d.ts +32 -0
- package/build/components/graphics/WorkPlaneObj.d.ts +33 -0
- package/build/components/graphics/WorkPointObj.d.ts +57 -0
- package/build/components/graphics/graphics.d.ts +61 -0
- package/build/components/graphics/utils/MatePathTransform.d.ts +10 -0
- package/build/components/graphics/utils/useCsysMatrix.d.ts +4 -0
- package/build/components/utils/CompValidation/ErrorBoundary.d.ts +28 -0
- package/build/components/utils/CompValidation/validators/CSysDisplayValidator.d.ts +12 -0
- package/build/components/utils/CompValidation/validators/DrawingValidator.d.ts +12 -0
- package/build/components/utils/CompValidation/validators/ExpressionsValidator.d.ts +12 -0
- package/build/components/utils/CompValidation/validators/FPluginValidator.d.ts +16 -0
- package/build/components/utils/CompValidation/validators/FeatureListValidator.d.ts +12 -0
- package/build/components/utils/CompValidation/validators/ProductManagementValidator.d.ts +14 -0
- package/build/components/utils/CompValidation/verifiers.d.ts +32 -0
- package/build/components/utils/FtVisibilityController.d.ts +26 -0
- package/build/elements/index.d.ts +162 -0
- package/build/icons/axes.d.ts +73 -0
- package/build/icons/draw.d.ts +75 -0
- package/build/icons/features.d.ts +71 -0
- package/build/icons/glyphs.d.ts +10 -0
- package/build/icons/index.d.ts +152 -0
- package/build/icons/legacy.d.ts +159 -0
- package/build/icons/mates.d.ts +26 -0
- package/build/icons/params.d.ts +77 -0
- package/build/icons/refs.d.ts +61 -0
- package/build/icons/sheets.d.ts +302 -0
- package/build/icons/sketch.d.ts +102 -0
- package/build/icons/types.d.ts +74 -0
- package/build/icons/ui.d.ts +114 -0
- package/build/icons.cjs.js +1751 -0
- package/build/icons.js +1742 -0
- package/build/index.cjs.js +44948 -0
- package/build/index.d.ts +115 -0
- package/build/index.js +44800 -0
- package/build/plugins/AppearanceEditor/Root.d.ts +12 -0
- package/build/plugins/AppearanceEditor/index.d.ts +42 -0
- package/build/plugins/Boolean/Root.d.ts +11 -0
- package/build/plugins/Boolean/index.d.ts +39 -0
- package/build/plugins/BoundingBoxInfo/Root.d.ts +12 -0
- package/build/plugins/BoundingBoxInfo/View.d.ts +11 -0
- package/build/plugins/BoundingBoxInfo/index.d.ts +35 -0
- package/build/plugins/Box/Root.d.ts +11 -0
- package/build/plugins/Box/index.d.ts +34 -0
- package/build/plugins/Chamfer/Root.d.ts +11 -0
- package/build/plugins/Chamfer/index.d.ts +35 -0
- package/build/plugins/CircularPattern/Root.d.ts +11 -0
- package/build/plugins/CircularPattern/index.d.ts +35 -0
- package/build/plugins/CompositeCurve/Root.d.ts +11 -0
- package/build/plugins/CompositeCurve/View.d.ts +11 -0
- package/build/plugins/CompositeCurve/index.d.ts +36 -0
- package/build/plugins/Cone/Root.d.ts +11 -0
- package/build/plugins/Cone/index.d.ts +36 -0
- package/build/plugins/Cylinder/Root.d.ts +11 -0
- package/build/plugins/Cylinder/index.d.ts +35 -0
- package/build/plugins/Dimensions/DimContext.d.ts +10 -0
- package/build/plugins/Dimensions/Root.d.ts +11 -0
- package/build/plugins/Dimensions/View.d.ts +11 -0
- package/build/plugins/Dimensions/graphics/DimGraphics.d.ts +7 -0
- package/build/plugins/Dimensions/graphics/DimensionSet.d.ts +8 -0
- package/build/plugins/Dimensions/graphics/primitives.d.ts +34 -0
- package/build/plugins/Dimensions/index.d.ts +34 -0
- package/build/plugins/Dimensions/utils.d.ts +5 -0
- package/build/plugins/EntityDeletion/Root.d.ts +11 -0
- package/build/plugins/EntityDeletion/index.d.ts +34 -0
- package/build/plugins/Expressions/Root.d.ts +11 -0
- package/build/plugins/Expressions/index.d.ts +34 -0
- package/build/plugins/Expressions/useContextMenuItems.d.ts +4 -0
- package/build/plugins/Extrusion/Root.d.ts +11 -0
- package/build/plugins/Extrusion/View.d.ts +11 -0
- package/build/plugins/Extrusion/index.d.ts +50 -0
- package/build/plugins/Fillet/Root.d.ts +11 -0
- package/build/plugins/Fillet/index.d.ts +35 -0
- package/build/plugins/HLConstraints/CircularPattern/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/CircularPattern/View.d.ts +11 -0
- package/build/plugins/HLConstraints/CircularPattern/index.d.ts +38 -0
- package/build/plugins/HLConstraints/Cylindrical/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Cylindrical/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Cylindrical/index.d.ts +37 -0
- package/build/plugins/HLConstraints/Fastened/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Fastened/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Fastened/index.d.ts +37 -0
- package/build/plugins/HLConstraints/FastenedOrigin/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/FastenedOrigin/View.d.ts +11 -0
- package/build/plugins/HLConstraints/FastenedOrigin/index.d.ts +37 -0
- package/build/plugins/HLConstraints/Gear/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Gear/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Gear/index.d.ts +36 -0
- package/build/plugins/HLConstraints/Group/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Group/index.d.ts +34 -0
- package/build/plugins/HLConstraints/LinearPattern/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/LinearPattern/View.d.ts +11 -0
- package/build/plugins/HLConstraints/LinearPattern/index.d.ts +38 -0
- package/build/plugins/HLConstraints/Parallel/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Parallel/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Parallel/index.d.ts +37 -0
- package/build/plugins/HLConstraints/Planar/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Planar/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Planar/index.d.ts +37 -0
- package/build/plugins/HLConstraints/Revolute/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Revolute/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Revolute/index.d.ts +37 -0
- package/build/plugins/HLConstraints/Slider/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Slider/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Slider/index.d.ts +37 -0
- package/build/plugins/HLConstraints/Spherical/Root.d.ts +11 -0
- package/build/plugins/HLConstraints/Spherical/View.d.ts +11 -0
- package/build/plugins/HLConstraints/Spherical/index.d.ts +36 -0
- package/build/plugins/HLConstraints/components/CSysDisplayWrapper.d.ts +7 -0
- package/build/plugins/HLConstraints/components/HLConstrIcon.d.ts +7 -0
- package/build/plugins/HLConstraints/components/LimitedValue.d.ts +12 -0
- package/build/plugins/HLConstraints/components/Limits.d.ts +25 -0
- package/build/plugins/HLConstraints/components/LimitsCollapse.d.ts +12 -0
- package/build/plugins/HLConstraints/validators.d.ts +2 -0
- package/build/plugins/Import/Root.d.ts +11 -0
- package/build/plugins/Import/index.d.ts +35 -0
- package/build/plugins/LinearPattern/Root.d.ts +11 -0
- package/build/plugins/LinearPattern/index.d.ts +36 -0
- package/build/plugins/Measure/Digits.d.ts +7 -0
- package/build/plugins/Measure/Root.d.ts +11 -0
- package/build/plugins/Measure/View.d.ts +15 -0
- package/build/plugins/Measure/config.d.ts +1 -0
- package/build/plugins/Measure/graphics/MeasureGraphics.d.ts +24 -0
- package/build/plugins/Measure/index.d.ts +39 -0
- package/build/plugins/Measure/utils.d.ts +2 -0
- package/build/plugins/Mirror/Root.d.ts +11 -0
- package/build/plugins/Mirror/index.d.ts +34 -0
- package/build/plugins/Revolve/Root.d.ts +11 -0
- package/build/plugins/Revolve/index.d.ts +37 -0
- package/build/plugins/Rotate/Root.d.ts +11 -0
- package/build/plugins/Rotate/index.d.ts +35 -0
- package/build/plugins/Sketch/Root/Constraints/Constraints.d.ts +2 -0
- package/build/plugins/Sketch/Root/Constraints/constraintsHelpers.d.ts +22 -0
- package/build/plugins/Sketch/Root/Constraints/index.d.ts +2 -0
- package/build/plugins/Sketch/Root/Constraints/utils.d.ts +6 -0
- package/build/plugins/Sketch/Root/CopyPatterns.d.ts +2 -0
- package/build/plugins/Sketch/Root/Details.d.ts +2 -0
- package/build/plugins/Sketch/Root/Handlers.d.ts +2 -0
- package/build/plugins/Sketch/Root/PlaneSelection.d.ts +7 -0
- package/build/plugins/Sketch/Root/Position.d.ts +2 -0
- package/build/plugins/Sketch/Root/Regions.d.ts +2 -0
- package/build/plugins/Sketch/Root/Root.d.ts +11 -0
- package/build/plugins/Sketch/Root/RootContext.d.ts +7 -0
- package/build/plugins/Sketch/Root/SketchGroup.d.ts +15 -0
- package/build/plugins/Sketch/Root/index.d.ts +1 -0
- package/build/plugins/Sketch/Root/useContextMenuItems.d.ts +4 -0
- package/build/plugins/Sketch/Root/useLayoutSize.d.ts +11 -0
- package/build/plugins/Sketch/View/View.d.ts +11 -0
- package/build/plugins/Sketch/View/ViewContext.d.ts +8 -0
- package/build/plugins/Sketch/View/graphics/Constraints.d.ts +5 -0
- package/build/plugins/Sketch/View/graphics/IconGroups.d.ts +7 -0
- package/build/plugins/Sketch/View/graphics/Merged/Arc.d.ts +20 -0
- package/build/plugins/Sketch/View/graphics/Merged/ArcGeometry.d.ts +2 -0
- package/build/plugins/Sketch/View/graphics/Merged/ArcMaterial.d.ts +2 -0
- package/build/plugins/Sketch/View/graphics/Merged/Bezier.d.ts +19 -0
- package/build/plugins/Sketch/View/graphics/Merged/BezierGeometry.d.ts +12 -0
- package/build/plugins/Sketch/View/graphics/Merged/BezierMaterial.d.ts +2 -0
- package/build/plugins/Sketch/View/graphics/Merged/Circle.d.ts +9 -0
- package/build/plugins/Sketch/View/graphics/Merged/Line.d.ts +15 -0
- package/build/plugins/Sketch/View/graphics/Merged/LineGeometry.d.ts +2 -0
- package/build/plugins/Sketch/View/graphics/Merged/LineMaterial.d.ts +2 -0
- package/build/plugins/Sketch/View/graphics/Merged/MergedWrapper.d.ts +16 -0
- package/build/plugins/Sketch/View/graphics/Merged/Point.d.ts +8 -0
- package/build/plugins/Sketch/View/graphics/Merged/Spline.d.ts +17 -0
- package/build/plugins/Sketch/View/graphics/Merged/SplineGeometry.d.ts +11 -0
- package/build/plugins/Sketch/View/graphics/Merged/SplineMaterial.d.ts +2 -0
- package/build/plugins/Sketch/View/graphics/MousePosition.d.ts +2 -0
- package/build/plugins/Sketch/View/graphics/Regions.d.ts +5 -0
- package/build/plugins/Sketch/View/graphics/TmpAngularDimension.d.ts +8 -0
- package/build/plugins/Sketch/View/graphics/graphics.d.ts +5 -0
- package/build/plugins/Sketch/View/graphics/hooks.d.ts +49 -0
- package/build/plugins/Sketch/View/graphics/primitives.d.ts +34 -0
- package/build/plugins/Sketch/View/graphics/scale.d.ts +6 -0
- package/build/plugins/Sketch/View/graphics/tmpGraphics.d.ts +3 -0
- package/build/plugins/Sketch/View/graphics/transform.d.ts +4 -0
- package/build/plugins/Sketch/View/handlers/CreateAngle.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/CreateConstraint.d.ts +10 -0
- package/build/plugins/Sketch/View/handlers/Drag.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/DrawArc.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/DrawCircle.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/DrawLine.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/DrawNurbs.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/DrawPoint.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/DrawRectangle.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/Fillet.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/HandlersConstructors.d.ts +33 -0
- package/build/plugins/Sketch/View/handlers/Hover.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/SSelect.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/Split.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/Trim.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/Use.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/constraintCreation.d.ts +10 -0
- package/build/plugins/Sketch/View/handlers/filletHelpers.d.ts +24 -0
- package/build/plugins/Sketch/View/handlers/hoverHelpers.d.ts +3 -0
- package/build/plugins/Sketch/View/handlers/snapper.d.ts +11 -0
- package/build/plugins/Sketch/View/handlers/splitHelpers.d.ts +20 -0
- package/build/plugins/Sketch/View/index.d.ts +1 -0
- package/build/plugins/Sketch/constants.d.ts +5 -0
- package/build/plugins/Sketch/description.d.ts +7 -0
- package/build/plugins/Sketch/index.d.ts +35 -0
- package/build/plugins/Sketch/resources.d.ts +5 -0
- package/build/plugins/Sketch/types.d.ts +148 -0
- package/build/plugins/Sketch/utils/Interaction.d.ts +7 -0
- package/build/plugins/Sketch/utils/OverdefinedStateManager.d.ts +6 -0
- package/build/plugins/Sketch/utils/getSketchState.d.ts +3 -0
- package/build/plugins/Sketch/utils/useSketchRegions.d.ts +2 -0
- package/build/plugins/Sketch/utils/useSketchState.d.ts +3 -0
- package/build/plugins/Slice/Root.d.ts +11 -0
- package/build/plugins/Slice/index.d.ts +34 -0
- package/build/plugins/SliceBySheet/Root.d.ts +11 -0
- package/build/plugins/SliceBySheet/index.d.ts +35 -0
- package/build/plugins/Sphere/Root.d.ts +11 -0
- package/build/plugins/Sphere/index.d.ts +35 -0
- package/build/plugins/TransformByCsys/Root.d.ts +11 -0
- package/build/plugins/TransformByCsys/index.d.ts +35 -0
- package/build/plugins/Translate/Root.d.ts +11 -0
- package/build/plugins/Translate/index.d.ts +35 -0
- package/build/plugins/Twist/Root.d.ts +11 -0
- package/build/plugins/Twist/View.d.ts +11 -0
- package/build/plugins/Twist/index.d.ts +48 -0
- package/build/plugins/WorkAxis/Root.d.ts +11 -0
- package/build/plugins/WorkAxis/View.d.ts +11 -0
- package/build/plugins/WorkAxis/index.d.ts +37 -0
- package/build/plugins/WorkCSys/Root.d.ts +11 -0
- package/build/plugins/WorkCSys/View.d.ts +11 -0
- package/build/plugins/WorkCSys/index.d.ts +53 -0
- package/build/plugins/WorkCoordSystem/Root.d.ts +11 -0
- package/build/plugins/WorkCoordSystem/View.d.ts +11 -0
- package/build/plugins/WorkCoordSystem/index.d.ts +55 -0
- package/build/plugins/WorkPlane/Root.d.ts +11 -0
- package/build/plugins/WorkPlane/View.d.ts +11 -0
- package/build/plugins/WorkPlane/index.d.ts +38 -0
- package/build/plugins/WorkPlane/validators.d.ts +1 -0
- package/build/plugins/WorkPoint/Root.d.ts +11 -0
- package/build/plugins/WorkPoint/View.d.ts +11 -0
- package/build/plugins/WorkPoint/index.d.ts +38 -0
- package/build/plugins/components/PluginForm.d.ts +24 -0
- package/build/plugins/utils/useRefsReset.d.ts +2 -0
- package/build/session/identity.d.ts +46 -0
- package/build/session/sessionClient.d.ts +140 -0
- package/build/session/types.d.ts +52 -0
- package/build/session/viewpoints.d.ts +90 -0
- package/build/theme/AppStyle.d.ts +33 -0
- package/build/theme/fonts/mono.d.ts +29 -0
- package/build/theme/stage.d.ts +148 -0
- package/build/theme/styles/antdChoices.d.ts +1 -0
- package/build/theme/styles/antdControls.d.ts +1 -0
- package/build/theme/styles/antdSurfaces.d.ts +1 -0
- package/build/theme/styles/editors.d.ts +1 -0
- package/build/theme/styles/fields.d.ts +1 -0
- package/build/theme/styles/frame.d.ts +1 -0
- package/build/theme/styles/panes.d.ts +1 -0
- package/build/theme/styles/parts.d.ts +2 -0
- package/build/theme/styles/rest.d.ts +1 -0
- package/build/theme/styles/sketch.d.ts +1 -0
- package/build/theme/styles/toolbar.d.ts +1 -0
- package/build/theme/styles/tools.d.ts +1 -0
- package/build/theme/styles/windows.d.ts +1 -0
- package/build/theme/themeStore.d.ts +305 -0
- package/build/types/jsx-compat.d.ts +8 -0
- package/build/types.d.ts +16 -0
- package/build/utils/FileUtils.d.ts +20 -0
- package/build/utils/bezierMatrices.d.ts +3 -0
- package/build/utils/conversionUtils.d.ts +78 -0
- package/build/utils/cubicSplineInterpolation.d.ts +5 -0
- package/build/utils/defaultValues.d.ts +3 -0
- package/build/utils/drawing/index.d.ts +3 -0
- package/build/utils/drawing/useDrawingArr.d.ts +10 -0
- package/build/utils/drawing/useDrawingCCId.d.ts +10 -0
- package/build/utils/drawing/useDrawingStr.d.ts +10 -0
- package/build/utils/getHighlightedColor.d.ts +6 -0
- package/build/utils/getMatePath.d.ts +2 -0
- package/build/utils/getMateRefIds.d.ts +30 -0
- package/build/utils/helpers.d.ts +19 -0
- package/build/utils/mateUtils.d.ts +35 -0
- package/build/utils/nurbsUtils.d.ts +35 -0
- package/build/utils/selection/filters.d.ts +12 -0
- package/build/utils/selection/scopes/mateSelection.d.ts +49 -0
- package/build/utils/selection/scopes/treeObjInteraction.d.ts +74 -0
- package/build/utils/selection/useSelectorsOrder.d.ts +12 -0
- package/build/utils/sketchIntersectionUtils.d.ts +139 -0
- package/build/utils/sketchUtils.d.ts +235 -0
- package/build/utils/useAllObjects.d.ts +31 -0
- package/build/utils/useIsUncommited.d.ts +2 -0
- package/build/utils/useRetainVisibility.d.ts +2 -0
- package/build/utils/useScale.d.ts +5 -0
- package/build/utils/validation.d.ts +11 -0
- package/doc/api/advanced/session.md +646 -0
- package/doc/api/advanced/utilities.md +1306 -0
- package/doc/api/assembly-constraints.md +340 -0
- package/doc/api/feature-plugins.md +613 -0
- package/doc/api/graphics.md +848 -0
- package/doc/api/hooks.md +300 -0
- package/doc/api/icons.md +812 -0
- package/doc/api/index.md +87 -0
- package/doc/api/other.md +369 -0
- package/doc/api/panels.md +754 -0
- package/doc/api/theme.md +551 -0
- package/doc/api/tool-plugins.md +191 -0
- package/doc/api/ui-elements.md +310 -0
- package/doc/api/work-geometry.md +154 -0
- package/icons/package.json +8 -0
- package/package.json +108 -4
- package/tools/fonts/brotli.py +29 -0
- package/tools/fonts/build.py +76 -0
- package/tools/icons/preview.mjs +74 -0
- package/tsconfig.build.json +16 -0
- package/typedoc.json +18 -0
- package/vitest.config.mts +25 -0
package/build/icons.js
ADDED
|
@@ -0,0 +1,1742 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An icon is a small sign on a 20 × 20 sheet, in layers, back to front. A layer is a path and the
|
|
6
|
+
* pen it is drawn with. A sign has two tones: ink for what it is about, grey for what that is done
|
|
7
|
+
* to or was there before. No colour, but an axis' own where the sign is about that axis.
|
|
8
|
+
*
|
|
9
|
+
* '' ink: what the sign is about
|
|
10
|
+
* 'sub' grey: what it is done to, what was there before
|
|
11
|
+
* 'dash' ink, dashed
|
|
12
|
+
* 'sub-dash' grey, dashed: what is hidden, what was taken away
|
|
13
|
+
* 'axis' grey, chain-dashed: an axis, a line to mirror in
|
|
14
|
+
* 'fill' filled, ink: a point
|
|
15
|
+
* 'sub-fill' filled, grey
|
|
16
|
+
* 'point' a point of a sketch: a ring in ink, its centre light. What lies under it is cut away
|
|
17
|
+
* 'sub-point' the same, grey
|
|
18
|
+
* 'tone' a wash of ink: the face of what the sign is about
|
|
19
|
+
* 'x' 'y' 'z' a line in an axis' own colour (red, green, blue)
|
|
20
|
+
*
|
|
21
|
+
* Every line has the same weight. A sign that is one path in ink can be written as just that path.
|
|
22
|
+
*
|
|
23
|
+
* In a line's path, a part in square brackets is solid: filled in the line's own tone as well as
|
|
24
|
+
* drawn. That is an arrow's head: `M3 10H13[M17 10L13 8V12Z]`.
|
|
25
|
+
*
|
|
26
|
+
* @category Icons
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** Whether a layer's pen draws points, which cut away what lies under their centres. @internal */
|
|
30
|
+
const isPointPen = pen => pen === 'point' || pen === 'sub-point';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A layer of an icon: the pen it is drawn with ({@link IconPen}), and its SVG path on the 20 × 20 sheet.
|
|
34
|
+
*
|
|
35
|
+
* @category Icons
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An icon's drawing: its layers, back to front, each a pen and an SVG path on the 20 × 20 sheet (`[pen, d]`); or, for
|
|
40
|
+
* a sign that is one path in ink, just that path.
|
|
41
|
+
*
|
|
42
|
+
* The pens are `''` (ink: what the sign is about), `'sub'` (grey: what it is done to), `'dash'` and `'sub-dash'`,
|
|
43
|
+
* `'axis'` (grey, chain-dashed), `'fill'` and `'sub-fill'` (filled), `'point'` and `'sub-point'` (a sketch's point: a
|
|
44
|
+
* ring with a light centre, given as its circle), `'tone'` (a wash of ink: the face of what the
|
|
45
|
+
* sign is about), and `'x'`, `'y'`, `'z'` (a line in an axis' own colour). In a path, a part in square brackets is
|
|
46
|
+
* filled as well as drawn: an arrow's head, `M3 10H13[M17 10L13 8V12Z]`.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import type { IconDrawing } from '@classcad/react-cad'
|
|
51
|
+
*
|
|
52
|
+
* // a sign that is one path in ink, and one in layers: what is done to in grey, what it is about in ink
|
|
53
|
+
* const plus: IconDrawing = 'M10 4v12M4 10h12'
|
|
54
|
+
* const eyeOff: IconDrawing = [
|
|
55
|
+
* ['sub', 'M2 10C4 6.7 6.8 5 10 5s6 1.7 8 5c-2 3.3-4.8 5-8 5s-6-1.7-8-5Z'],
|
|
56
|
+
* ['', 'M4 16 16 4'],
|
|
57
|
+
* ]
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @advanced
|
|
61
|
+
* @category Icons
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A layer's path, taken apart: what is drawn as lines, and what is solid (the parts in brackets).
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
const partsOf = d => {
|
|
70
|
+
if (!d.includes('[')) return {
|
|
71
|
+
lines: d,
|
|
72
|
+
solid: ''
|
|
73
|
+
};
|
|
74
|
+
let solid = '';
|
|
75
|
+
const lines = d.replace(/\[([^\]]*)\]/g, (_, part) => {
|
|
76
|
+
solid += part;
|
|
77
|
+
return '';
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
lines,
|
|
81
|
+
solid
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A sheet of signs, typed by the names on it.
|
|
87
|
+
*
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
const sheet = drawings => drawings;
|
|
91
|
+
|
|
92
|
+
// The pen the hand-drawn icons share: a few shapes on the 20 × 20 sheet, and the one camera every
|
|
93
|
+
// drawing of a body is seen through. It is the camera of the family's feature drawings: iso, from
|
|
94
|
+
// the front-right-top corner (+X, −Y, +Z), so X runs down to the right, Y up to the right, Z up.
|
|
95
|
+
|
|
96
|
+
const n = v => {
|
|
97
|
+
const s = (Math.round(v * 100) / 100).toString();
|
|
98
|
+
return s === '-0' ? '0' : s;
|
|
99
|
+
};
|
|
100
|
+
const COS$1 = Math.sqrt(3) / 2;
|
|
101
|
+
|
|
102
|
+
/** The camera: a point in space, to the sheet. `s` is how long a unit is, `o` where the origin lies. */
|
|
103
|
+
const iso = (s = 1, o = [10, 10]) => ([x, y, z]) => [o[0] + (x + y) * COS$1 * s, o[1] + (x - y) * 0.5 * s - z * s];
|
|
104
|
+
|
|
105
|
+
/** A line through points; closed when asked. */
|
|
106
|
+
const line = (pts, close = false) => 'M' + pts.map(p => `${n(p[0])} ${n(p[1])}`).join('L') + (close ? 'Z' : '');
|
|
107
|
+
|
|
108
|
+
/** A circle (as two arcs, so it can be stroked from its start). */
|
|
109
|
+
const circle = (cx, cy, r) => `M${n(cx - r)} ${n(cy)}a${n(r)} ${n(r)} 0 1 0 ${n(2 * r)} 0a${n(r)} ${n(r)} 0 1 0 ${n(-2 * r)} 0Z`;
|
|
110
|
+
|
|
111
|
+
/** An ellipse, its axes along the sheet's. */
|
|
112
|
+
const ellipse = (cx, cy, rx, ry) => `M${n(cx - rx)} ${n(cy)}a${n(rx)} ${n(ry)} 0 1 0 ${n(2 * rx)} 0a${n(rx)} ${n(ry)} 0 1 0 ${n(-2 * rx)} 0Z`;
|
|
113
|
+
|
|
114
|
+
/** Part of an ellipse, from angle a0 to a1 (degrees, clockwise on the sheet from its right). */
|
|
115
|
+
const arc = (cx, cy, rx, ry, a0, a1) => {
|
|
116
|
+
const at = a => [cx + rx * Math.cos(a * Math.PI / 180), cy + ry * Math.sin(a * Math.PI / 180)];
|
|
117
|
+
const [p, q] = [at(a0), at(a1)];
|
|
118
|
+
const large = Math.abs(a1 - a0) > 180 ? 1 : 0;
|
|
119
|
+
const sweep = a1 > a0 ? 1 : 0;
|
|
120
|
+
return `M${n(p[0])} ${n(p[1])}A${n(rx)} ${n(ry)} 0 ${large} ${sweep} ${n(q[0])} ${n(q[1])}`;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/** A rectangle with round corners. */
|
|
124
|
+
const rect = (x, y, w, h, r = 0) => r ? `M${n(x + r)} ${n(y)}h${n(w - 2 * r)}a${n(r)} ${n(r)} 0 0 1 ${n(r)} ${n(r)}v${n(h - 2 * r)}a${n(r)} ${n(r)} 0 0 1 ${n(-r)} ${n(r)}h${n(-(w - 2 * r))}a${n(r)} ${n(r)} 0 0 1 ${n(-r)} ${n(-r)}v${n(-(h - 2 * r))}a${n(r)} ${n(r)} 0 0 1 ${n(r)} ${n(-r)}Z` : `M${n(x)} ${n(y)}h${n(w)}v${n(h)}h${n(-w)}Z`;
|
|
125
|
+
|
|
126
|
+
// An arrow's head is a solid triangle: an open one is two hairs at the size a sign is shown at.
|
|
127
|
+
// It is this much wider than half its length.
|
|
128
|
+
const HEAD = 0.62;
|
|
129
|
+
|
|
130
|
+
/** An arrow's head at `to`, coming from `from`: a solid triangle, `size` long. */
|
|
131
|
+
const head = (from, to, size = 3) => {
|
|
132
|
+
const a = Math.atan2(to[1] - from[1], to[0] - from[0]);
|
|
133
|
+
const [c, s] = [Math.cos(a), Math.sin(a)];
|
|
134
|
+
const [bx, by] = [to[0] - size * c, to[1] - size * s];
|
|
135
|
+
const half = size * HEAD;
|
|
136
|
+
return `[${line([to, [bx - half * s, by + half * c], [bx + half * s, by - half * c]], true)}]`;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// where a shaft ends under a head at `to`: at the head's back
|
|
140
|
+
const under = (from, to, size) => {
|
|
141
|
+
const d = Math.hypot(to[0] - from[0], to[1] - from[1]) || 1;
|
|
142
|
+
const t = Math.min(size, d) / d;
|
|
143
|
+
return [to[0] + (from[0] - to[0]) * t, to[1] + (from[1] - to[1]) * t];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** The box from `lo` to `hi`, as the camera sees it: its outline and the three edges of its near corner. */
|
|
147
|
+
const box = (cam, lo, hi) => {
|
|
148
|
+
const [x0, y0, z0] = lo;
|
|
149
|
+
const [x1, y1, z1] = hi;
|
|
150
|
+
const outline = line([[x0, y0, z1], [x0, y1, z1], [x1, y1, z1], [x1, y1, z0], [x1, y0, z0], [x0, y0, z0]].map(p => cam(p)), true);
|
|
151
|
+
const near = cam([x1, y0, z1]);
|
|
152
|
+
const corner = line([cam([x0, y0, z1]), near, cam([x1, y1, z1])]) + line([near, cam([x1, y0, z0])]);
|
|
153
|
+
return {
|
|
154
|
+
outline,
|
|
155
|
+
corner,
|
|
156
|
+
all: outline + corner
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** A flat face in space, as the camera sees it. */
|
|
161
|
+
const face = (cam, pts) => line(pts.map(cam), true);
|
|
162
|
+
|
|
163
|
+
// ---- what the signs share: the same points, the same arrows, the same cube
|
|
164
|
+
|
|
165
|
+
const rad$1 = a => a * Math.PI / 180;
|
|
166
|
+
|
|
167
|
+
/** A point on an ellipse about `c`, by its angle (degrees, clockwise on the sheet from its right). */
|
|
168
|
+
const on$1 = (c, rx, ry, a) => [c[0] + rx * Math.cos(rad$1(a)), c[1] + ry * Math.sin(rad$1(a))];
|
|
169
|
+
|
|
170
|
+
/** A point of a sign: a small filled dot. */
|
|
171
|
+
const dot$1 = (p, r = 1.35) => circle(p[0], p[1], r);
|
|
172
|
+
|
|
173
|
+
/** An arrow: its shaft, and a solid head. */
|
|
174
|
+
const arrowTo = (from, to, size = 3) => line([from, under(from, to, size)]) + head(from, to, size);
|
|
175
|
+
|
|
176
|
+
/** A length, as a dimension is drawn: a shaft with a head at either end. */
|
|
177
|
+
const spanTo = (a, b, size = 3) => line([under(b, a, size), under(a, b, size)]) + head(a, b, size) + head(b, a, size);
|
|
178
|
+
|
|
179
|
+
/** A turn: part of an ellipse, with an arrow's head where it ends. */
|
|
180
|
+
const turn = (c, rx, ry, a0, a1, size = 3) => {
|
|
181
|
+
// the head lies along the last of the arc: as much of it as the head is long
|
|
182
|
+
const back = (a1 > a0 ? -1 : 1) * size * 360 / (Math.PI * (rx + ry));
|
|
183
|
+
return arc(c[0], c[1], rx, ry, a0, a1) + head(on$1(c, rx, ry, a1 + back), on$1(c, rx, ry, a1), size);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/** A block from `lo` to `hi` in the one camera: its lines, its outline alone, and its top face. */
|
|
187
|
+
const block = (s, o, lo = [-0.5, -0.5, -0.5], hi = [0.5, 0.5, 0.5]) => {
|
|
188
|
+
const cam = iso(s, o);
|
|
189
|
+
const b = box(cam, lo, hi);
|
|
190
|
+
return {
|
|
191
|
+
cam,
|
|
192
|
+
lines: b.all,
|
|
193
|
+
outline: b.outline,
|
|
194
|
+
top: face(cam, [[lo[0], lo[1], hi[2]], [lo[0], hi[1], hi[2]], [hi[0], hi[1], hi[2]], [hi[0], lo[1], hi[2]]]),
|
|
195
|
+
/** The face that looks along +X (to the right), and the one that looks along −Y (to the left). */
|
|
196
|
+
right: face(cam, [[hi[0], lo[1], hi[2]], [hi[0], hi[1], hi[2]], [hi[0], hi[1], lo[2]], [hi[0], lo[1], lo[2]]]),
|
|
197
|
+
left: face(cam, [[lo[0], lo[1], hi[2]], [hi[0], lo[1], hi[2]], [hi[0], lo[1], lo[2]], [lo[0], lo[1], lo[2]]])
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/** The cube every sign of a body starts from: it fills the sheet. */
|
|
202
|
+
const cube = block(7, [10, 10]);
|
|
203
|
+
|
|
204
|
+
/** A plate lying flat, as the camera sees it: its middle at `m`, `w` half its width on the sheet. */
|
|
205
|
+
const plate = (m, w) => line([180, 270, 0, 90].map(a => on$1(m, w, w / Math.sqrt(3), a)), true);
|
|
206
|
+
|
|
207
|
+
// ---- several things in one sign. They stand apart: what is closer than a couple of pixels at the
|
|
208
|
+
// size a sign is shown at runs together and reads as one thing. So what a sign has several of is
|
|
209
|
+
// small and solid (an outline would close the gap from both sides), with clear room between.
|
|
210
|
+
|
|
211
|
+
/** One of several: a small solid tile about `m`. For a pen that fills. */
|
|
212
|
+
const tile$1 = (m, side = 4) => rect(m[0] - side / 2, m[1] - side / 2, side, side, 0.9);
|
|
213
|
+
|
|
214
|
+
/** Where three tiles in a row lie, the sheet wide. */
|
|
215
|
+
const ROW = [3.2, 10, 16.8];
|
|
216
|
+
|
|
217
|
+
/** Three about a middle: the one that was there at the top, its copies to either side below. */
|
|
218
|
+
const AROUND = {
|
|
219
|
+
m: [10, 10.8],
|
|
220
|
+
r: 6.8,
|
|
221
|
+
at: [-90, 30, 150]
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/** A pattern along a line: the one that was there in grey, its copies in ink, in a row at `y`. */
|
|
225
|
+
const copiesInRow = (y, way = p => p) => [['sub-fill', tile$1(way([ROW[0], y]))], ['fill', tile$1(way([ROW[1], y])) + tile$1(way([ROW[2], y]))]];
|
|
226
|
+
|
|
227
|
+
/** A pattern about a middle: the circle the copies lie on (in grey, between them), and the three on it. */
|
|
228
|
+
const copiesAround = (m = AROUND.m, r = AROUND.r) => {
|
|
229
|
+
const [a, b, c] = AROUND.at;
|
|
230
|
+
// (the circle stops short of every tile)
|
|
231
|
+
const open = Math.atan(2 / r) * 180 / Math.PI + 14;
|
|
232
|
+
const between = [[a + open, b - open], [b + open, c - open], [c + open, a + 360 - open]];
|
|
233
|
+
return [['sub', between.map(([a0, a1]) => arc(m[0], m[1], r, r, a0, a1)).join('')], ['sub-fill', tile$1(on$1(m, r, r, a))], ['fill', tile$1(on$1(m, r, r, b)) + tile$1(on$1(m, r, r, c))]];
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/** The closed shape a sign is about, as a body: its wash, then its outline. */
|
|
237
|
+
const toned = d => [['tone', d], ['', d]];
|
|
238
|
+
|
|
239
|
+
// The app's own signs: what its bars, rows and menus are worked with. One weight, round ends; ink,
|
|
240
|
+
const tray = 'M3.5 12v3c0 .8.7 1.5 1.5 1.5h10c.8 0 1.5-.7 1.5-1.5v-3';
|
|
241
|
+
// (four tiles with clear room between them: closer, they run into one square at the size of a row)
|
|
242
|
+
const tile = (x, y) => rect(x, y, 5, 5, 1.2);
|
|
243
|
+
const tiles = tile(3, 3) + tile(12, 3) + tile(3, 12);
|
|
244
|
+
const eye = 'M2 10C4 6.7 6.8 5 10 5s6 1.7 8 5c-2 3.3-4.8 5-8 5s-6-1.7-8-5Z';
|
|
245
|
+
const drop = 'M10 3c3 3.4 4.8 6 4.8 8.2a4.8 4.8 0 0 1-9.6 0C5.2 9 7 6.4 10 3Z';
|
|
246
|
+
const disc = circle(10, 10, 7.2);
|
|
247
|
+
// the cube's corners that are seen, and the three edges that are not
|
|
248
|
+
const c$2 = cube.cam;
|
|
249
|
+
const corners = [c$2([-0.5, -0.5, 0.5]), c$2([-0.5, 0.5, 0.5]), c$2([0.5, 0.5, 0.5]), c$2([0.5, 0.5, -0.5]), c$2([0.5, -0.5, -0.5]), c$2([-0.5, -0.5, -0.5]), c$2([0.5, -0.5, 0.5])];
|
|
250
|
+
const far = c$2([-0.5, 0.5, -0.5]);
|
|
251
|
+
const hidden = line([corners[1], far]) + line([corners[5], far, corners[3]]);
|
|
252
|
+
const inner = block(3.6, [10, 10.6]);
|
|
253
|
+
const ui = sheet({
|
|
254
|
+
// ---- ways through the app
|
|
255
|
+
/** Three bars: a menu. */
|
|
256
|
+
menu: 'M3.5 5.5h13M3.5 10h13M3.5 14.5h13',
|
|
257
|
+
/** An arrow that turns back: undo. */
|
|
258
|
+
undo: 'M7 8.5h5.2a4.3 4.3 0 0 1 0 8.6H9' + head([8, 8.5], [3.4, 8.5], 3.6),
|
|
259
|
+
/** An arrow that turns on: redo. */
|
|
260
|
+
redo: 'M13 8.5H7.8a4.3 4.3 0 0 0 0 8.6H11' + head([12, 8.5], [16.6, 8.5], 3.6),
|
|
261
|
+
/** An arrow to the left: back. */
|
|
262
|
+
back: arrowTo([16.5, 10], [3.5, 10], 4),
|
|
263
|
+
// (a chevron fills its sheet: it is shown small, beside a row or a tool, and has to be made out there)
|
|
264
|
+
/** A chevron to the left. */
|
|
265
|
+
chevronLeft: 'M13 3.6 6.6 10l6.4 6.4',
|
|
266
|
+
/** A chevron to the right: a row or a section that opens. */
|
|
267
|
+
chevronRight: 'M7 3.6l6.4 6.4L7 16.4',
|
|
268
|
+
/** A chevron down. */
|
|
269
|
+
chevronDown: 'M3.6 7l6.4 6.4L16.4 7',
|
|
270
|
+
/** A chevron up. */
|
|
271
|
+
chevronUp: 'M3.6 13 10 6.6l6.4 6.4',
|
|
272
|
+
/** A wide chevron down: opens a set, such as a tool button's. */
|
|
273
|
+
caret: 'M3.2 6.8l6.8 6.8 6.8-6.8',
|
|
274
|
+
/** An arrow to the right. */
|
|
275
|
+
arrowRight: arrowTo([3.5, 10], [16.5, 10], 4),
|
|
276
|
+
/** A cross: close. */
|
|
277
|
+
close: 'M5 5l10 10M15 5 5 15',
|
|
278
|
+
/** A tick: done, on. */
|
|
279
|
+
check: 'M4 10.6 8 14.5 16 5.5',
|
|
280
|
+
/** A plus: add, create. */
|
|
281
|
+
plus: 'M10 4v12M4 10h12',
|
|
282
|
+
/** A minus: remove. */
|
|
283
|
+
minus: 'M4 10h12',
|
|
284
|
+
/** Three dots: more, a row's menu. */
|
|
285
|
+
more: [['fill', dot$1([4.2, 10], 1.4) + dot$1([10, 10], 1.4) + dot$1([15.8, 10], 1.4)]],
|
|
286
|
+
/** Six dots: what is dragged. */
|
|
287
|
+
grip: [['fill', [5, 10, 15].map(y => dot$1([7, y], 1.2) + dot$1([13, y], 1.2)).join('')]],
|
|
288
|
+
/** A lens: search. */
|
|
289
|
+
search: circle(8.6, 8.6, 5.1) + 'M12.4 12.4 17 17',
|
|
290
|
+
// ---- the sidebar: the app's frame with its left pane, there (inked) and put away (empty)
|
|
291
|
+
/** The app's frame with its sidebar there: hide the sidebar. */
|
|
292
|
+
sidebar: [['fill', 'M4.5 4H8V16H4.5C3.7 16 3 15.3 3 14.5V5.5C3 4.7 3.7 4 4.5 4Z'], ['', rect(3, 4, 14, 12, 1.5) + 'M8 4V16']],
|
|
293
|
+
/** The frame with the sidebar put away: show the sidebar. */
|
|
294
|
+
sidebarOff: [['sub', 'M8 4V16'], ['', rect(3, 4, 14, 12, 1.5)]],
|
|
295
|
+
// ---- shown, and not shown: an eye; the same, struck through
|
|
296
|
+
/** An eye: shown. */
|
|
297
|
+
eye: [['tone', eye], ['', eye], ['fill', dot$1([10, 10], 2.2)]],
|
|
298
|
+
/** The eye struck through: hidden. */
|
|
299
|
+
eyeOff: [['sub', eye], ['sub-fill', dot$1([10, 10], 2.2)], ['', 'M4 16 16 4']],
|
|
300
|
+
// ---- what is done to a thing
|
|
301
|
+
/** A bin: delete. */
|
|
302
|
+
trash: 'M3.8 6h12.4M8 6V4.2h4V6M5.4 6l.8 9.6c0 .5.5.9 1 .9h5.6c.5 0 1-.4 1-.9l.8-9.6M8.4 9.2v4.2M11.6 9.2v4.2',
|
|
303
|
+
/** A pen: edit. */
|
|
304
|
+
edit: 'M3.6 16.4l.9-3.7 8.7-8.7a1.5 1.5 0 0 1 2.1 0l.7.7a1.5 1.5 0 0 1 0 2.1l-8.7 8.7-3.7.9ZM11.6 5.6l2.8 2.8',
|
|
305
|
+
// a name being written: its field, and the caret in it
|
|
306
|
+
/** A field with its caret: rename. */
|
|
307
|
+
rename: [['sub', rect(2.4, 5.8, 15.2, 8.4, 2)], ['', 'M10 3.6v12.8M7.8 3.6h4.4M7.8 16.4h4.4']],
|
|
308
|
+
/** Two sheets, one over the other: copy. */
|
|
309
|
+
copy: [['sub', 'M6.4 12.8H5c-.8 0-1.5-.7-1.5-1.5V5c0-.8.7-1.5 1.5-1.5h6.3c.8 0 1.5.7 1.5 1.5v1.4'], ['tone', rect(7.2, 7.2, 9.3, 9.3, 1.5)], ['', rect(7.2, 7.2, 9.3, 9.3, 1.5)]],
|
|
310
|
+
/** Two links of a chain: a link. */
|
|
311
|
+
link: 'M8.6 11.4a3.2 3.2 0 0 0 4.5 0l2.6-2.6a3.2 3.2 0 0 0-4.5-4.5l-.9.9M11.4 8.6a3.2 3.2 0 0 0-4.5 0l-2.6 2.6a3.2 3.2 0 0 0 4.5 4.5l.9-.9',
|
|
312
|
+
/** A pointer: select. */
|
|
313
|
+
select: [['tone', 'M4.6 3.4 15 9.6l-4.6 1 2.7 4.8-2 1.1-2.7-4.8-3.2 3.4Z'], ['', 'M4.6 3.4 15 9.6l-4.6 1 2.7 4.8-2 1.1-2.7-4.8-3.2 3.4Z']],
|
|
314
|
+
/** A pin: pin. */
|
|
315
|
+
pin: 'M12.2 3.4l4.4 4.4-1.7.6-2.7 2.7.2 3.3-1.3 1.3-6.5-6.5 1.3-1.3 3.3.2 2.7-2.7.3-2ZM7.8 12.2 3.8 16.2',
|
|
316
|
+
// into a product, to work on it: through its frame
|
|
317
|
+
/** An arrow into a frame: go into a product to work on it. */
|
|
318
|
+
enter: [['sub', 'M10.5 4h4c.8 0 1.5.7 1.5 1.5v9c0 .8-.7 1.5-1.5 1.5h-4'], ['', arrowTo([3.2, 10], [12, 10], 3.4)]],
|
|
319
|
+
// ---- out of the app, and into it
|
|
320
|
+
/** An arrow up out of a tray: export. */
|
|
321
|
+
export: tray + arrowTo([10, 12.6], [10, 3], 3.6),
|
|
322
|
+
/** An arrow down into a tray: download. */
|
|
323
|
+
download: tray + arrowTo([10, 3], [10, 12.6], 3.6),
|
|
324
|
+
/** An arrow down into a tray: import. */
|
|
325
|
+
import: tray + arrowTo([10, 3], [10, 12.6], 3.6),
|
|
326
|
+
/** A folder: open. */
|
|
327
|
+
open: 'M3 6c0-.8.7-1.5 1.5-1.5h3l1.6 1.8h6.4c.8 0 1.5.7 1.5 1.5v6.7c0 .8-.7 1.5-1.5 1.5h-11C3.7 16 3 15.3 3 14.5V6Z',
|
|
328
|
+
/** A sheet with a folded corner: a file. */
|
|
329
|
+
file: 'M6 3h5l4 4v8.5c0 .8-.7 1.5-1.5 1.5H6c-.8 0-1.5-.7-1.5-1.5v-11C4.5 3.7 5.2 3 6 3ZM11 3v4h4',
|
|
330
|
+
// ---- the theme: a disc, half inked
|
|
331
|
+
/** A disc, half inked: the theme. */
|
|
332
|
+
theme: [['', disc], ['fill', 'M10 2.8a7.2 7.2 0 0 1 0 14.4Z']],
|
|
333
|
+
// ---- what the app has to say
|
|
334
|
+
/** A speech bubble: messages. */
|
|
335
|
+
message: 'M4.5 4h11c.8 0 1.5.7 1.5 1.5V12c0 .8-.7 1.5-1.5 1.5H9.6L6.4 16.5v-3H4.5C3.7 13.5 3 12.8 3 12V5.5C3 4.7 3.7 4 4.5 4Z',
|
|
336
|
+
/** A question mark in a disc: help. */
|
|
337
|
+
question: disc + 'M7.9 8a2.2 2.2 0 1 1 3.3 1.9c-.8.5-1.2 1-1.2 1.9' + 'M10 14.2v.1',
|
|
338
|
+
/** An i in a disc: a note. */
|
|
339
|
+
info: disc + 'M10 9.2v4.6M10 6.2v.1',
|
|
340
|
+
/** An exclamation mark in a triangle: a warning. */
|
|
341
|
+
warning: 'M10 3 17.6 16.2H2.4L10 3ZM10 8v3.8M10 14v.1',
|
|
342
|
+
/** A cross in a disc: an error. */
|
|
343
|
+
error: disc + 'M7.3 7.3l5.4 5.4M12.7 7.3l-5.4 5.4',
|
|
344
|
+
/** A tick in a disc: done. */
|
|
345
|
+
success: disc + 'M6.6 10.2l2.4 2.4 4.4-5',
|
|
346
|
+
// ---- products: the parts a model is put together from; one more of them
|
|
347
|
+
/** Four tiles: the products a model is put together from. */
|
|
348
|
+
products: tiles + tile(12, 12),
|
|
349
|
+
/** Three tiles and a plus: convert to a subassembly. */
|
|
350
|
+
toSubassembly: [['sub', tiles], ['', 'M14.5 11.4v6.2M11.4 14.5h6.2']],
|
|
351
|
+
/** Three people, linked: a shared session. */
|
|
352
|
+
session: [['sub', 'M8.6 7.8 7 11.2M11.4 7.8 13 11.2M8.6 13.8h2.8'], ['', circle(5.8, 13.8, 2.6) + circle(14.2, 13.8, 2.6) + circle(10, 5.4, 2.6)]],
|
|
353
|
+
// ---- how the model is shown: its faces, its mesh, its edges, its points
|
|
354
|
+
/** A cube with its faces: show the faces. */
|
|
355
|
+
viewFaces: [['tone', cube.outline], ['tone', cube.top], ['', cube.outline]],
|
|
356
|
+
/** A cube's wires: show the faces as wires. */
|
|
357
|
+
viewWire: [['sub', line([corners[0], corners[2]]) + line([corners[0], corners[4]]) + line([corners[6], corners[3]])], ['', cube.lines]],
|
|
358
|
+
/** A cube's edges, the hidden ones dashed: show the edges. */
|
|
359
|
+
viewEdges: [['sub-dash', hidden], ['', cube.lines]],
|
|
360
|
+
/** A cube's corners: show the points. */
|
|
361
|
+
viewPoints: [['sub', cube.lines], ['fill', corners.map(p => dot$1(p, 1.5)).join('')]],
|
|
362
|
+
// how a body is drawn: a ball with its own shadow and a gleam, lit (and, unpressed, drawn flat)
|
|
363
|
+
/** A lit ball: how the bodies are drawn. */
|
|
364
|
+
look: [['tone', 'M15.09 4.91A7.2 7.2 0 0 1 4.91 15.09A9.2 9.2 0 0 0 15.09 4.91Z'], ['', disc], ['sub', 'M6.4 8.6a4 4 0 0 1 2.4-2.8']],
|
|
365
|
+
// ---- what is laid over the model: its dimensions, a measure, its box
|
|
366
|
+
/** A span between two rules: the dimensions. */
|
|
367
|
+
dims: [['sub', 'M2.6 4v12M17.4 4v12'], ['', spanTo([5, 10], [15, 10], 2.8)]],
|
|
368
|
+
/** A ruler: measure. */
|
|
369
|
+
measure: [['tone', 'M12.6 3 17 7.4 7.4 17 3 12.6Z'], ['', 'M12.6 3 17 7.4 7.4 17 3 12.6ZM9.9 5.7l2 2M7.2 8.4l2 2']],
|
|
370
|
+
/** A block in a dashed cube: the bounding box. */
|
|
371
|
+
bbox: [['sub-dash', cube.lines], ['tone', inner.top], ['', inner.lines]],
|
|
372
|
+
// ---- the view: all of it in the frame; along a plane's normal; how a body looks
|
|
373
|
+
/** Corners around a square: zoom to fit. */
|
|
374
|
+
zoomFit: [['', 'M3.5 7V3.5H7M13 3.5h3.5V7M16.5 13v3.5H13M7 16.5H3.5V13'], ['tone', rect(7.2, 7.2, 5.6, 5.6, 1)], ['', rect(7.2, 7.2, 5.6, 5.6, 1)]],
|
|
375
|
+
/** An arrow that stands on a plane: look along a plane's normal. */
|
|
376
|
+
viewNormal: [['tone', 'M2.4 13 10 8.6 17.6 13 10 17.4Z'], ['sub', 'M2.4 13 10 8.6 17.6 13 10 17.4Z'], ['', arrowTo([10, 13], [10, 2.4], 3.2)]],
|
|
377
|
+
/** A drop: the appearance, a body's colour. */
|
|
378
|
+
appearance: [['tone', drop], ['', drop]],
|
|
379
|
+
// ---- expressions: a value given by its name
|
|
380
|
+
/** An f and an x: the expressions. */
|
|
381
|
+
expressions: 'M8.6 4.2c-1.8-.3-2.8.5-3 2.4L4.6 15.8M3.4 9h4.2' + 'M10.4 9.6l5.8 6.2M16.2 9.6l-5.8 6.2'
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// The features' signs: what a part is built from. Each says what its feature does, as a sign that
|
|
385
|
+
const f$2 = v => Math.round(v * 100) / 100;
|
|
386
|
+
const at$2 = p => `${f$2(p[0])} ${f$2(p[1])}`;
|
|
387
|
+
|
|
388
|
+
// ---- what an extrusion makes: a body, tall on the sheet, and the way it was raised out of its top
|
|
389
|
+
const raised = block(6, [10, 12.3], [-0.5, -0.5, -0.45], [0.5, 0.5, 0.45]);
|
|
390
|
+
const raisedTop = [10, 9.6];
|
|
391
|
+
|
|
392
|
+
// ---- a bar raised with a twist: its top is turned against its foot by `by` degrees, and its
|
|
393
|
+
// corners run up between them as screws. Drawn as a body is: its outline (what it covers on the
|
|
394
|
+
// sheet, so the waist the twist gives it is one clean line), its top, and of its corners what
|
|
395
|
+
// lies within the outline and is turned towards the camera.
|
|
396
|
+
const twisted = (by, r, h) => {
|
|
397
|
+
const COS = Math.sqrt(3) / 2;
|
|
398
|
+
const o = [10, 18 - 0.4 - r * Math.SQRT1_2];
|
|
399
|
+
// a corner of the bar: the `k`th, `t` of the way up
|
|
400
|
+
const angle = (k, t) => 45 + 90 * k + by * t;
|
|
401
|
+
const corner = (k, t) => {
|
|
402
|
+
const a = angle(k, t) * Math.PI / 180;
|
|
403
|
+
const [x, y] = [r * Math.cos(a), r * Math.sin(a)];
|
|
404
|
+
return [o[0] + (x + y) * COS, o[1] + (x - y) * 0.5 - t * h];
|
|
405
|
+
};
|
|
406
|
+
const section = t => [0, 1, 2, 3].map(k => corner(k, t));
|
|
407
|
+
// the bar as a stack of its sections, and, row by row down the sheet, how far they reach to either side
|
|
408
|
+
const SECTIONS = 60;
|
|
409
|
+
const stack = Array.from({
|
|
410
|
+
length: SECTIONS + 1
|
|
411
|
+
}, (_, i) => section(i / SECTIONS));
|
|
412
|
+
const heights = stack.reduce((all, q) => all.concat(q.map(point => point[1])), []);
|
|
413
|
+
const [y0, y1] = [Math.min(...heights), Math.max(...heights)];
|
|
414
|
+
const ROWS = 72;
|
|
415
|
+
const rows = [];
|
|
416
|
+
for (let i = 0; i <= ROWS; i++) {
|
|
417
|
+
const y = y0 + (y1 - y0) * i / ROWS;
|
|
418
|
+
let [lo, hi] = [Infinity, -Infinity];
|
|
419
|
+
for (const q of stack) {
|
|
420
|
+
for (let k = 0; k < 4; k++) {
|
|
421
|
+
const [a, b] = [q[k], q[(k + 1) % 4]];
|
|
422
|
+
if ((a[1] - y) * (b[1] - y) > 1e-9) continue;
|
|
423
|
+
const xs = Math.abs(a[1] - b[1]) < 1e-9 ? [a[0], b[0]] : [a[0] + (b[0] - a[0]) * (y - a[1]) / (b[1] - a[1])];
|
|
424
|
+
lo = Math.min(lo, ...xs);
|
|
425
|
+
hi = Math.max(hi, ...xs);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (lo <= hi) rows.push({
|
|
429
|
+
y,
|
|
430
|
+
lo,
|
|
431
|
+
hi
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
// (a run of points that lie on one line is that line)
|
|
435
|
+
const straight = pts => pts.filter((q, i) => {
|
|
436
|
+
if (i === 0 || i === pts.length - 1) return true;
|
|
437
|
+
const [a, b] = [pts[i - 1], pts[i + 1]];
|
|
438
|
+
const off = Math.abs((b[0] - a[0]) * (q[1] - a[1]) - (b[1] - a[1]) * (q[0] - a[0])) / Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
439
|
+
return off > 0.004;
|
|
440
|
+
});
|
|
441
|
+
const outline = line([...straight(rows.map(row => [row.lo, row.y])), ...straight(rows.map(row => [row.hi, row.y]).reverse())], true);
|
|
442
|
+
// a corner is seen unless it is turned to the far side (the camera looks from the corner at -45°);
|
|
443
|
+
// it is drawn where it lies within the outline (on the outline, the outline is its line)
|
|
444
|
+
const seen = (k, t) => {
|
|
445
|
+
const a = (angle(k, t) % 360 + 360) % 360;
|
|
446
|
+
return a < 90 || a > 180;
|
|
447
|
+
};
|
|
448
|
+
const within = ([x, y]) => {
|
|
449
|
+
const row = rows[Math.min(rows.length - 1, Math.max(0, Math.round((y - y0) / (y1 - y0) * ROWS)))];
|
|
450
|
+
return x > row.lo + 0.3 && x < row.hi - 0.3;
|
|
451
|
+
};
|
|
452
|
+
const STEPS = 40;
|
|
453
|
+
let screws = '';
|
|
454
|
+
for (let k = 0; k < 4; k++) {
|
|
455
|
+
let run = [];
|
|
456
|
+
for (let i = 0; i <= STEPS; i++) {
|
|
457
|
+
const q = corner(k, i / STEPS);
|
|
458
|
+
const drawn = seen(k, i / STEPS) && within(q);
|
|
459
|
+
// (a run starts and ends on the outline: the point before it and the point after it)
|
|
460
|
+
if (drawn && !run.length && i > 0 && seen(k, (i - 1) / STEPS)) run.push(corner(k, (i - 1) / STEPS));
|
|
461
|
+
if (drawn) run.push(q);
|
|
462
|
+
if (!drawn || i === STEPS) {
|
|
463
|
+
if (run.length && !drawn && seen(k, i / STEPS)) run.push(q);
|
|
464
|
+
// (a corner that only grazes the outline leaves a stub: it is not drawn)
|
|
465
|
+
if (run.length > 1 && Math.hypot(run[0][0] - run[run.length - 1][0], run[0][1] - run[run.length - 1][1]) > 2) screws += line(run);
|
|
466
|
+
run = [];
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return {
|
|
471
|
+
outline,
|
|
472
|
+
screws,
|
|
473
|
+
top: line(section(1), true)
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
const TWISTED = twisted(90, 4.6, 9.4);
|
|
477
|
+
|
|
478
|
+
// ---- the three axes from a corner, as the camera sees them: X down to the right, Y up to the right, Z up
|
|
479
|
+
const O$1 = [6.5, 11.5];
|
|
480
|
+
const tip = {
|
|
481
|
+
x: [15.6, 16.75],
|
|
482
|
+
y: [15.6, 6.25],
|
|
483
|
+
z: [6.5, 2.4]
|
|
484
|
+
};
|
|
485
|
+
const axis$1 = a => line([O$1, tip[a]]);
|
|
486
|
+
// a datum axis: the three in grey, the one that is meant in its own colour
|
|
487
|
+
const axisOf = a => [['sub', ['x', 'y', 'z'].filter(b => b !== a).map(axis$1).join('')], [a, arrowTo(O$1, tip[a], 3)]];
|
|
488
|
+
|
|
489
|
+
// ---- a datum plane: one sheet, the way it lies
|
|
490
|
+
const PLANE$2 = {
|
|
491
|
+
top: 'M2.4 10L10 5.6L17.6 10L10 14.4Z',
|
|
492
|
+
front: 'M4.5 3.6L15.5 9.95V16.95L4.5 10.6Z',
|
|
493
|
+
right: 'M15.5 3.6L4.5 9.95V16.95L15.5 10.6Z'
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
// ---- a body seen flat, for what is done to a whole body
|
|
497
|
+
const BODY$1 = rect(2.5, 8.5, 9, 9, 1.2);
|
|
498
|
+
const body$1 = toned(BODY$1);
|
|
499
|
+
|
|
500
|
+
// ---- the two shapes of a boolean: a square, and a circle over its corner
|
|
501
|
+
const SQ = {
|
|
502
|
+
x0: 2.5,
|
|
503
|
+
y0: 8,
|
|
504
|
+
x1: 12,
|
|
505
|
+
y1: 17.5
|
|
506
|
+
};
|
|
507
|
+
const CI = {
|
|
508
|
+
c: [12.5, 7.5],
|
|
509
|
+
r: 5.5
|
|
510
|
+
};
|
|
511
|
+
// where the circle crosses the square's top and its right side
|
|
512
|
+
const P$1 = [CI.c[0] - Math.sqrt(CI.r * CI.r - 0.25), SQ.y0];
|
|
513
|
+
const Q = [SQ.x1, CI.c[1] + Math.sqrt(CI.r * CI.r - 0.25)];
|
|
514
|
+
const A$1 = `A${CI.r} ${CI.r} 0`;
|
|
515
|
+
// the square's sides from P round to Q, and the circle's two ways between them: round the outside, through the square
|
|
516
|
+
const sides = `M${at$2(P$1)}H${SQ.x0}V${SQ.y1}H${SQ.x1}V${f$2(Q[1])}`;
|
|
517
|
+
const outside = `${A$1} 1 0 ${at$2(P$1)}`;
|
|
518
|
+
const through = `${A$1} 0 1 ${at$2(P$1)}`;
|
|
519
|
+
// what the two share: the corner of the square that lies in the circle
|
|
520
|
+
const shared = `M${at$2(P$1)}H${SQ.x1}V${f$2(Q[1])}${through}Z`;
|
|
521
|
+
|
|
522
|
+
// ---- a block with one corner worked: its other sides, and the corner's two ends
|
|
523
|
+
const CORNER = {
|
|
524
|
+
a: [10, 4.5],
|
|
525
|
+
b: [16.5, 11]
|
|
526
|
+
};
|
|
527
|
+
const worked = `M${at$2(CORNER.a)}H3.5V16.5H16.5V${CORNER.b[1]}`;
|
|
528
|
+
|
|
529
|
+
// ---- a part: a block with a step in it
|
|
530
|
+
const c$1 = cube.cam;
|
|
531
|
+
const step = {
|
|
532
|
+
outline: line([c$1([-0.5, -0.5, 0.5]), c$1([-0.5, 0.5, 0.5]), c$1([0, 0.5, 0.5]), c$1([0, 0.5, 0]), c$1([0.5, 0.5, 0]), c$1([0.5, 0.5, -0.5]), c$1([0.5, -0.5, -0.5]), c$1([-0.5, -0.5, -0.5])], true),
|
|
533
|
+
edges: line([c$1([-0.5, -0.5, 0.5]), c$1([0, -0.5, 0.5]), c$1([0, 0.5, 0.5])]) + line([c$1([0, -0.5, 0.5]), c$1([0, -0.5, 0]), c$1([0, 0.5, 0])]) + line([c$1([0, -0.5, 0]), c$1([0.5, -0.5, 0]), c$1([0.5, 0.5, 0])]) + line([c$1([0.5, -0.5, 0]), c$1([0.5, -0.5, -0.5])]),
|
|
534
|
+
tops: line([c$1([-0.5, -0.5, 0.5]), c$1([-0.5, 0.5, 0.5]), c$1([0, 0.5, 0.5]), c$1([0, -0.5, 0.5])], true) + line([c$1([0, -0.5, 0]), c$1([0, 0.5, 0]), c$1([0.5, 0.5, 0]), c$1([0.5, -0.5, 0])], true)
|
|
535
|
+
};
|
|
536
|
+
const features = sheet({
|
|
537
|
+
// ---- a sketch: a profile and its points
|
|
538
|
+
/** Sketch: a profile and its points. */
|
|
539
|
+
sketch: [['tone', 'M4 4H10V10H16V16H4Z'], ['', 'M4 4H10V10H16V16H4Z'], ['fill', dot$1([4, 4]) + dot$1([10, 10]) + dot$1([16, 16]) + dot$1([4, 16])]],
|
|
540
|
+
// ---- a profile made a body: raised, turned about an axis, raised with a twist
|
|
541
|
+
/** Extrusion: a profile raised into a body. */
|
|
542
|
+
extrusion: [['tone', raised.top], ['', raised.lines], ['', arrowTo(raisedTop, [10, 2.2], 3)]],
|
|
543
|
+
/** Revolve: a profile turned about an axis into a body. */
|
|
544
|
+
revolve: [['tone', 'M10 3A7.5 7.5 0 1 1 2.5 10.5H6.6A3.4 3.4 0 1 0 10 7.1Z'], ['', 'M10 3A7.5 7.5 0 1 1 2.5 10.5H6.6A3.4 3.4 0 1 0 10 7.1Z'], ['sub-fill', dot$1([10, 10.5], 1.2)]],
|
|
545
|
+
/** Twist: a profile raised with a twist. */
|
|
546
|
+
twist: [['tone', TWISTED.top], ['', TWISTED.outline + TWISTED.top + TWISTED.screws]],
|
|
547
|
+
// ---- bodies of their own
|
|
548
|
+
/** Box. */
|
|
549
|
+
box: [['tone', cube.top], ['', cube.lines]],
|
|
550
|
+
/** Cylinder. */
|
|
551
|
+
cylinder: [['tone', ellipse(10, 5.6, 6, 2.6)], ['', ellipse(10, 5.6, 6, 2.6) + 'M4 5.6V14.4' + 'M16 5.6V14.4' + arc(10, 14.4, 6, 2.6, 180, 0)]],
|
|
552
|
+
/** Cone. */
|
|
553
|
+
cone: [['tone', 'M10 2.8L3.75 14A6.4 2.7 0 0 0 16.25 14Z'], ['', 'M10 2.8L3.75 14A6.4 2.7 0 0 0 16.25 14Z']],
|
|
554
|
+
/** Sphere. */
|
|
555
|
+
sphere: [['tone', circle(10, 10, 7.2)], ['', circle(10, 10, 7.2) + arc(10, 10, 7.2, 2.7, 180, 0)]],
|
|
556
|
+
// ---- two bodies into one: joined, the one taken from the other, what they share
|
|
557
|
+
/** Union: two bodies joined into one. */
|
|
558
|
+
union: [['tone', sides + outside + 'Z'], ['', sides + outside + 'Z']],
|
|
559
|
+
/** Subtraction: the one body taken from the other. */
|
|
560
|
+
subtraction: [['sub-dash', `M${at$2(Q)}${outside}`], ['tone', sides + through + 'Z'], ['', sides + through + 'Z']],
|
|
561
|
+
/** Intersection: what two bodies share. */
|
|
562
|
+
intersection: [['sub', sides + outside], ['fill', shared], ['', shared]],
|
|
563
|
+
// ---- an edge worked: rounded, cut
|
|
564
|
+
/** Fillet: an edge rounded. */
|
|
565
|
+
fillet: [['sub', worked], ['', `M${at$2(CORNER.a)}A6.5 6.5 0 0 1 ${at$2(CORNER.b)}`]],
|
|
566
|
+
/** Chamfer: an edge cut. */
|
|
567
|
+
chamfer: [['sub', worked], ['', line([CORNER.a, CORNER.b])]],
|
|
568
|
+
// ---- a body cut in two: by a plane, by a sheet
|
|
569
|
+
/** Slice: a body cut in two by a plane. */
|
|
570
|
+
slice: [['tone', rect(4, 4, 12, 12, 1.2)], ['sub', rect(4, 4, 12, 12, 1.2)], ['', 'M1.8 13.4L18.2 6.6']],
|
|
571
|
+
/** Slice by sheet: a body cut in two by a sheet. */
|
|
572
|
+
sliceBySheet: [['tone', rect(4, 4, 12, 12, 1.2)], ['sub', rect(4, 4, 12, 12, 1.2)], ['', 'M1.8 12C6 12 6.5 7.5 10 10S14 12.5 18.2 8']],
|
|
573
|
+
// ---- a body repeated: in a mirror, along a line, about an axis
|
|
574
|
+
/** Mirror: a body repeated in a mirror. */
|
|
575
|
+
mirror: [['sub', 'M2 6.8L6 4.6V15.4L2 13.2Z'], ['axis', 'M10 2V18'], ['tone', 'M18 6.8L14 4.6V15.4L18 13.2Z'], ['', 'M18 6.8L14 4.6V15.4L18 13.2Z']],
|
|
576
|
+
/** Linear pattern: a body repeated along a line. */
|
|
577
|
+
linearPattern: [...copiesInRow(5.8), ['', arrowTo([1.6, 14.6], [18.4, 14.6], 3)]],
|
|
578
|
+
/** Circular pattern: a body repeated about an axis. */
|
|
579
|
+
circularPattern: copiesAround(),
|
|
580
|
+
// ---- a body moved: along a line, about an axis, from one coordinate system to another
|
|
581
|
+
/** Translate: a body moved along a line. */
|
|
582
|
+
translation: [...body$1, ['', arrowTo([12.6, 7.4], [17.6, 2.4], 3)]],
|
|
583
|
+
/** Rotate: a body turned about an axis. */
|
|
584
|
+
rotation: [...body$1, ['', turn([7, 13], 10.4, 10.4, -84, -8, 3)]],
|
|
585
|
+
/** Transform by coordinate systems: a body moved from one to another. */
|
|
586
|
+
transformByCsys: [...body$1, ['', 'M13 4.6V8H16' + head([13, 5], [13, 2.2], 2.4) + head([15.6, 8], [18.4, 8], 2.4)]],
|
|
587
|
+
// ---- what a part is measured from, made by hand
|
|
588
|
+
/** Work plane. */
|
|
589
|
+
workPlane: toned(PLANE$2.top),
|
|
590
|
+
/** Work axis. */
|
|
591
|
+
workAxis: [['', 'M3 17L7.6 12.4M12.4 7.6L17 3'], ['fill', dot$1([10, 10], 1.2)]],
|
|
592
|
+
/** Work point. */
|
|
593
|
+
workPoint: [['', 'M10 2.4V5.8M10 14.2V17.6M2.4 10H5.8M14.2 10H17.6'], ['fill', dot$1([10, 10], 2)]],
|
|
594
|
+
/** Work coordinate system. */
|
|
595
|
+
workCSys: [['', arrowTo(O$1, tip.x, 2.8) + arrowTo(O$1, tip.y, 2.8) + arrowTo(O$1, tip.z, 2.8)], ['fill', dot$1(O$1, 1.5)]],
|
|
596
|
+
// ---- what every part is measured from: its origin, its three axes, its three planes
|
|
597
|
+
/** The part's origin. */
|
|
598
|
+
origin: [['sub', axis$1('x') + axis$1('y') + axis$1('z')], ['fill', dot$1(O$1, 2.1)]],
|
|
599
|
+
/** The part's X axis. */
|
|
600
|
+
axisX: axisOf('x'),
|
|
601
|
+
/** The part's Y axis. */
|
|
602
|
+
axisY: axisOf('y'),
|
|
603
|
+
/** The part's Z axis. */
|
|
604
|
+
axisZ: axisOf('z'),
|
|
605
|
+
/** The part's top plane. */
|
|
606
|
+
planeTop: toned(PLANE$2.top),
|
|
607
|
+
/** The part's front plane. */
|
|
608
|
+
planeFront: toned(PLANE$2.front),
|
|
609
|
+
/** The part's right plane. */
|
|
610
|
+
planeRight: toned(PLANE$2.right),
|
|
611
|
+
// ---- a body, and a part
|
|
612
|
+
/** A body. */
|
|
613
|
+
solid: [['tone', cube.outline], ['tone', cube.top], ['', cube.lines]],
|
|
614
|
+
/** A part. */
|
|
615
|
+
part: [['tone', step.tops], ['', step.outline + step.edges]]
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// Signs for what no other sheet holds: a document that is an assembly, what is taken out of a
|
|
619
|
+
|
|
620
|
+
// (two bodies, small enough to stand apart: closer, they run into one)
|
|
621
|
+
const back = block(3.8, [5.3, 6.4]);
|
|
622
|
+
const front = block(3.8, [14.7, 13.6]);
|
|
623
|
+
const glyphs = sheet({
|
|
624
|
+
// ---- an assembly: more than one body
|
|
625
|
+
/** Two bodies: an assembly. */
|
|
626
|
+
assembly: [['sub', back.outline + back.top], ['tone', front.outline], ['tone', front.top], ['', front.outline + front.top]],
|
|
627
|
+
// ---- a body, or a face of one, taken out again
|
|
628
|
+
/** A cube, crossed out: a body or a face taken out of a part again. */
|
|
629
|
+
entityDeletion: [['sub', cube.outline], ['', 'M6.4 6.4l7.2 7.2M13.6 6.4l-7.2 7.2']],
|
|
630
|
+
// ---- several curves, taken as one
|
|
631
|
+
/** A curve through points: several curves taken as one. */
|
|
632
|
+
compositeCurve: [['', 'M3.4 14.6C4.8 9 7 6 9.8 6c2.3 0 2.3 4.6 4.5 4.6 1.2 0 2-1.5 2.5-4.3'], ['fill', dot$1([3.4, 14.6]) + dot$1([9.8, 6]) + dot$1([14.3, 10.6]) + dot$1([16.8, 6.3])]],
|
|
633
|
+
// ---- a region of a sketch: what its curves close
|
|
634
|
+
/** A rectangle with a hole, filled: a region of a sketch. */
|
|
635
|
+
region: [['tone', rect(3.6, 5, 12.8, 10, 1.2) + circle(10, 10, 2.2)], ['', rect(3.6, 5, 12.8, 10, 1.2)], ['sub', circle(10, 10, 2.2)]]
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
// What a number field of a feature's window sets: a length, an angle, a count, a state. Each is a
|
|
639
|
+
// an angle about `m`, from a0 to a1 at the radius `r`: its arc, and the wedge the arc closes
|
|
640
|
+
const angled = (m, r, a0, a1) => {
|
|
641
|
+
const bow = arc(m[0], m[1], r, r, a0, a1);
|
|
642
|
+
return [['tone', line([m, on$1(m, r, r, a0)]) + bow.slice(bow.indexOf('A')) + 'Z'], ['', bow]];
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
// ---- the cube, its edges sorted by the way they run (X down to the right, Y up to the right, Z up)
|
|
646
|
+
const [L, H] = [-0.5, 0.5];
|
|
647
|
+
const edge = (a, b) => line([cube.cam(a), cube.cam(b)]);
|
|
648
|
+
const EDGES = {
|
|
649
|
+
x: edge([L, L, L], [H, L, L]) + edge([L, L, H], [H, L, H]) + edge([L, H, H], [H, H, H]),
|
|
650
|
+
y: edge([H, L, L], [H, H, L]) + edge([H, L, H], [H, H, H]) + edge([L, L, H], [L, H, H]),
|
|
651
|
+
z: edge([L, L, L], [L, L, H]) + edge([H, L, L], [H, L, H]) + edge([H, H, L], [H, H, H])
|
|
652
|
+
};
|
|
653
|
+
// a measure of the box: the edges that run its way in its axis' colour, the others in grey
|
|
654
|
+
const measure$1 = way => [['sub', (way === 'x' ? '' : EDGES.x) + (way === 'y' ? '' : EDGES.y) + (way === 'z' ? '' : EDGES.z)], [way, EDGES[way]]];
|
|
655
|
+
|
|
656
|
+
// ---- the slab a twist is raised from, low on the sheet: the turn has room over it
|
|
657
|
+
const SLAB = block(6, [10, 15], [-0.5, -0.5, -0.2], [0.5, 0.5, 0.2]).lines;
|
|
658
|
+
|
|
659
|
+
// ---- a revolve seen along its axis: the turn, from the top round towards the left; a hand from the axis out
|
|
660
|
+
// to where the turn starts (its tail) or to where it ends (what its head points at)
|
|
661
|
+
const AXIS = [10, 10.4];
|
|
662
|
+
const hand = a => [['sub', turn(AXIS, 6.8, 6.8, -90, 150, 2.8)], ['', line([AXIS, on$1(AXIS, 8.2, 8.2, a)])], ['fill', dot$1(AXIS)]];
|
|
663
|
+
|
|
664
|
+
// ---- a cylinder and a cone's stump, standing; `SIDE` is where a height stands beside a body
|
|
665
|
+
const CYLINDER = ellipse(8, 5, 5.4, 2.3) + 'M2.6 5V14.6M13.4 5V14.6' + arc(8, 14.6, 5.4, 2.3, 180, 0);
|
|
666
|
+
const CONE_TOP = ellipse(8, 5.2, 3.4, 1.45);
|
|
667
|
+
const CONE_BASE = ellipse(8, 14.9, 5.8, 2.45);
|
|
668
|
+
const CONE_SIDES = 'M4.6 5.2L2.2 14.9M11.4 5.2L13.8 14.9';
|
|
669
|
+
const CONE = CONE_TOP + CONE_SIDES + arc(8, 14.9, 5.8, 2.45, 180, 0);
|
|
670
|
+
const SIDE = 17;
|
|
671
|
+
|
|
672
|
+
// ---- a corner cut off by a chamfer: one face, the cut from P down to the other face
|
|
673
|
+
const CHAMFERED = 'M1.6 6.6H4.4L13.8 16V18.4';
|
|
674
|
+
const P = [4.4, 6.6];
|
|
675
|
+
|
|
676
|
+
// ---- what a pattern repeats: two of them and how far apart; the one that was there, its copies,
|
|
677
|
+
// and the way they go
|
|
678
|
+
const apart = (a, b, pen, from, to) => [['sub-fill', tile$1(a, 5) + tile$1(b, 5)], [pen, spanTo(from, to)]];
|
|
679
|
+
// two planes, one above the other, flat enough to lie well apart
|
|
680
|
+
const sheetAt = y => line([[2, y], [7.4, y - 2.4], [12.8, y], [7.4, y + 2.4]], true);
|
|
681
|
+
// the angle from one copy to the next: two of them a quarter turn apart, the axis, and the turn between them
|
|
682
|
+
const PIVOT = [5, 15];
|
|
683
|
+
const between = pen => [['sub-fill', tile$1(on$1(PIVOT, 6.8, 6.8, -90)) + tile$1(on$1(PIVOT, 6.8, 6.8, 0)) + dot$1(PIVOT, 1.3)], [pen, turn(PIVOT, 11.6, 11.6, -80, -14, 2.8)]];
|
|
684
|
+
|
|
685
|
+
// ---- two bodies that overlap, seen flat: each, and the two as one
|
|
686
|
+
const A = rect(2.5, 2.5, 10, 10, 1.2);
|
|
687
|
+
const B = rect(7.5, 7.5, 10, 10, 1.2);
|
|
688
|
+
const R = 'a1.2 1.2 0 0 1';
|
|
689
|
+
const BOTH = `M3.7 2.5h7.6${R} 1.2 1.2V7.5h3.8${R} 1.2 1.2v7.6${R} -1.2 1.2h-7.6${R} -1.2 -1.2V12.5H3.7${R} -1.2 -1.2v-7.6${R} 1.2 -1.2Z`;
|
|
690
|
+
|
|
691
|
+
// ---- two wheels in mesh, as the gear's own sign has them (a little smaller: their turns stay on the sheet)
|
|
692
|
+
const BIG$1 = [8.2, 11.4];
|
|
693
|
+
const LITTLE$1 = [14.8, 8.5];
|
|
694
|
+
const wheel = (m, r, meant = false) => meant ? [...toned(circle(m[0], m[1], r)), ['fill', dot$1(m, 1.1)]] : [['sub', circle(m[0], m[1], r)], ['sub-fill', dot$1(m, 1.1)]];
|
|
695
|
+
|
|
696
|
+
// ---- a ball in its cup, as the spherical mate's own sign draws it
|
|
697
|
+
const BALL = [10, 11.6];
|
|
698
|
+
const JOINT = 'M2.4 11.6h1.6a6 6 0 0 0 12 0h1.6' + circle(BALL[0], BALL[1], 3.2);
|
|
699
|
+
const params = sheet({
|
|
700
|
+
// ---- a box's three measures, each along one of its axes: the cube, and the edges that run that way
|
|
701
|
+
/** A box's length: the edges along X. */
|
|
702
|
+
boxLength: measure$1('x'),
|
|
703
|
+
/** A box's width: the edges along Y. */
|
|
704
|
+
boxWidth: measure$1('y'),
|
|
705
|
+
/** A box's height: the edges along Z. */
|
|
706
|
+
boxHeight: measure$1('z'),
|
|
707
|
+
// ---- how far an extrusion goes from its sketch's plane (seen edge on): up, or down
|
|
708
|
+
/** How far an extrusion goes up from its sketch's plane. */
|
|
709
|
+
limitUp: [['sub', 'M2.5 12H17.5'], ['', arrowTo([10, 12], [10, 2.6], 3)]],
|
|
710
|
+
/** How far an extrusion goes down from its sketch's plane. */
|
|
711
|
+
limitDown: [['sub', 'M2.5 8H17.5'], ['', arrowTo([10, 8], [10, 17.4], 3)]],
|
|
712
|
+
// ---- solid or sheet: the body closed, with its mass; of the same body the two walls towards us alone
|
|
713
|
+
/** A closed body: make a solid. */
|
|
714
|
+
capSolid: [['tone', cube.outline], ['tone', cube.top], ['', cube.lines]],
|
|
715
|
+
/** The walls alone: make a sheet. */
|
|
716
|
+
capSheet: toned(cube.left + cube.right),
|
|
717
|
+
// ---- a twist's angle: the slab it is raised from, and over it the turn about the way it rises
|
|
718
|
+
/** A twist's angle: the turn about the way it rises. */
|
|
719
|
+
twistAngle: [['sub', SLAB], ['', turn([10, 6.2], 6.2, 2.5, -64, 212, 2.8)]],
|
|
720
|
+
// ---- an angle: two lines from a point, and what lies between them
|
|
721
|
+
/** An angle between two lines. */
|
|
722
|
+
angle: [['sub', line([on$1([3, 10], 14.6, 14.6, -30), [3, 10], on$1([3, 10], 14.6, 14.6, 30)])], ...angled([3, 10], 9, -30, 30)],
|
|
723
|
+
// ---- a revolve: the axis it turns about (seen from the side); where the turn starts, where it ends
|
|
724
|
+
/** The axis a revolve turns about. */
|
|
725
|
+
revolveAxis: [['sub', turn([10, 10], 6.4, 2.7, -64, 212, 2.8)], ['', 'M10 2V18']],
|
|
726
|
+
/** Where a revolve's turn starts. */
|
|
727
|
+
revolveStart: hand(-90),
|
|
728
|
+
/** Where a revolve's turn ends. */
|
|
729
|
+
revolveEnd: hand(180),
|
|
730
|
+
// ---- a cylinder's height, beside it; its diameter, across it as it is seen from above
|
|
731
|
+
/** A cylinder's height. */
|
|
732
|
+
cylinderHeight: [['sub', CYLINDER], ['', spanTo([SIDE, 3.2], [SIDE, 16.4], 2.8)]],
|
|
733
|
+
/** A diameter: across a circle. */
|
|
734
|
+
diameter: [['sub', circle(10, 10, 7.2)], ['', spanTo(on$1([10, 10], 7.2, 7.2, 135), on$1([10, 10], 7.2, 7.2, -45))]],
|
|
735
|
+
// ---- a cone's height, the diameter of its base, the diameter of its top
|
|
736
|
+
// (a diameter is too short for a span here: it is the rim itself that is in ink)
|
|
737
|
+
/** A cone's height. */
|
|
738
|
+
coneHeight: [['sub', CONE], ['', spanTo([SIDE, 3.8], [SIDE, 16.6], 2.8)]],
|
|
739
|
+
/** The diameter of a cone's base. */
|
|
740
|
+
coneBase: [['sub', CONE_TOP + CONE_SIDES], ...toned(CONE_BASE)],
|
|
741
|
+
/** The diameter of a cone's top. */
|
|
742
|
+
coneTop: [['sub', CONE_SIDES + arc(8, 14.9, 5.8, 2.45, 180, 0)], ...toned(CONE_TOP)],
|
|
743
|
+
// ---- a radius: a rounded corner, its centre, and the way from the centre to the round
|
|
744
|
+
/** A fillet's radius: from the centre to the round. */
|
|
745
|
+
filletRadius: [['sub', 'M2.6 3.8H6.8' + arc(6.8, 13.8, 10, 10, -90, 0) + 'M16.8 13.8V17.6'], ['', arrowTo([6.8, 13.8], on$1([6.8, 13.8], 10, 10, -45), 2.8)], ['fill', dot$1([6.8, 13.8])]],
|
|
746
|
+
// ---- a chamfer's measures: along the one face, along the other; the angle of the cut against the face
|
|
747
|
+
// (which runs on in grey over what was cut away)
|
|
748
|
+
/** A chamfer's measure along the one face. */
|
|
749
|
+
chamferOffset1: [['sub', CHAMFERED], ['', spanTo([4.4, 3], [13.8, 3], 2.6)]],
|
|
750
|
+
/** A chamfer's measure along the other face. */
|
|
751
|
+
chamferOffset2: [['sub', CHAMFERED], ['', spanTo([SIDE, 6.6], [SIDE, 16], 2.6)]],
|
|
752
|
+
/** A chamfer's angle against the face. */
|
|
753
|
+
chamferAngle: [['sub', CHAMFERED + 'M4.4 6.6H17.6'], ...angled(P, 8, 0, 45)],
|
|
754
|
+
// ---- a pattern's spacing: along its first axis, along its second, and up the axis it turns about
|
|
755
|
+
/** A pattern's spacing along its first axis. */
|
|
756
|
+
distanceX: apart([4.5, 6.2], [15.5, 6.2], 'x', [2.4, 14.6], [17.6, 14.6]),
|
|
757
|
+
/** A pattern's spacing along its second axis. */
|
|
758
|
+
distanceY: apart([13.8, 15.5], [13.8, 4.5], 'y', [5.4, 17.6], [5.4, 2.4]),
|
|
759
|
+
/** A pattern's spacing up the axis it turns about. */
|
|
760
|
+
distanceZ: [['sub', sheetAt(5) + sheetAt(15)], ['z', spanTo([16.6, 3.4], [16.6, 16.6])]],
|
|
761
|
+
// ---- a pattern's count: the copies along its first axis, along its second, about its axis
|
|
762
|
+
/** A pattern's count along its first axis. */
|
|
763
|
+
countX: [...copiesInRow(5.8), ['x', arrowTo([1.6, 14.6], [18.4, 14.6], 3)]],
|
|
764
|
+
/** A pattern's count along its second axis. */
|
|
765
|
+
countY: [...copiesInRow(14.2, ([x, y]) => [y, 20 - x]), ['y', arrowTo([5.4, 18.4], [5.4, 1.6], 3)]],
|
|
766
|
+
/** A pattern's count about its axis. */
|
|
767
|
+
countAngular: copiesAround(),
|
|
768
|
+
// ---- the angle from one copy to the next: about the axis that was picked, about a mate's Z
|
|
769
|
+
/** The angle from one copy to the next, about the axis that was picked. */
|
|
770
|
+
anglePattern: between(''),
|
|
771
|
+
/** The angle from one copy to the next, about a mate's Z. */
|
|
772
|
+
angleZ: between('z'),
|
|
773
|
+
// ---- how far a body is moved, how far it is turned: the feature's own sign, the body in grey
|
|
774
|
+
/** How far a body is moved. */
|
|
775
|
+
translationDistance: [['sub', rect(2.5, 11.5, 6, 6, 1.2)], ['', spanTo([9.8, 10.2], [17.6, 2.4])]],
|
|
776
|
+
/** How far a body is turned. */
|
|
777
|
+
rotationAngle: [['sub', rect(2.5, 8.5, 9, 9, 1.2)], ['', turn([7, 13], 10.4, 10.4, -84, -8, 3)]],
|
|
778
|
+
// ---- merge solids: two bodies made one, or left two
|
|
779
|
+
/** Two bodies made one: merge the solids. */
|
|
780
|
+
merged: toned(BOTH),
|
|
781
|
+
/** Two bodies left two: keep the solids apart. */
|
|
782
|
+
notMerged: [['tone', A], ['tone', B], ['', A + B]],
|
|
783
|
+
// ---- a gear: its first wheel, its second, and how the one turns against the other
|
|
784
|
+
/** A gear's first wheel. */
|
|
785
|
+
gearFirst: [...wheel(LITTLE$1, 3), ...wheel(BIG$1, 4.2, true)],
|
|
786
|
+
/** A gear's second wheel. */
|
|
787
|
+
gearSecond: [...wheel(BIG$1, 4.2), ...wheel(LITTLE$1, 3, true)],
|
|
788
|
+
/** How a gear's one wheel turns against the other: its ratio. */
|
|
789
|
+
gearRatio: [...wheel(BIG$1, 4.2), ...wheel(LITTLE$1, 3), ['', turn(BIG$1, 6.6, 6.6, 110, 195, 2.4) + turn(LITTLE$1, 5.4, 5.4, -80, -140, 2.4)]],
|
|
790
|
+
// ---- a ball joint's largest swing: how far it tilts to either side
|
|
791
|
+
/** A ball joint's largest swing to either side. */
|
|
792
|
+
sphericalMax: [['sub', JOINT], ['', turn(BALL, 8.4, 8.4, -132, -48, 2.6) + turn(BALL, 8.4, 8.4, -48, -132, 2.6)]]
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
// Quantities and switches that belong to one of the three axes. The axes are drawn as the camera
|
|
796
|
+
const AXES$1 = ['x', 'y', 'z'];
|
|
797
|
+
const f$1 = v => Math.round(v * 100) / 100;
|
|
798
|
+
const at$1 = p => `${f$1(p[0])} ${f$1(p[1])}`;
|
|
799
|
+
const rad = a => a * Math.PI / 180;
|
|
800
|
+
|
|
801
|
+
// ---- the camera's three directions on the sheet, a unit long
|
|
802
|
+
const COS = Math.sqrt(3) / 2;
|
|
803
|
+
const DIR = {
|
|
804
|
+
x: [COS, 0.5],
|
|
805
|
+
y: [COS, -0.5],
|
|
806
|
+
z: [0, -1]
|
|
807
|
+
};
|
|
808
|
+
// how far the sheet is turned (clockwise) to bring what is drawn about Z onto another axis
|
|
809
|
+
const TURNED = {
|
|
810
|
+
z: 0,
|
|
811
|
+
y: 60,
|
|
812
|
+
x: 120
|
|
813
|
+
};
|
|
814
|
+
// the point `d` along an axis from `o` (behind it when negative)
|
|
815
|
+
const along$1 = (o, a, d) => [o[0] + DIR[a][0] * d, o[1] + DIR[a][1] * d];
|
|
816
|
+
// the other two axes from `o`, each as far as `reach` says: what the coloured one is read against
|
|
817
|
+
const others = (o, a, reach) => AXES$1.filter(b => b !== a).map(b => line([o, along$1(o, b, reach(b))])).join('');
|
|
818
|
+
// a stop: a short bar through `p`, square to the axis `a`
|
|
819
|
+
const stop = (p, a, half = 2.2) => {
|
|
820
|
+
const d = [Math.cos(rad(TURNED[a])) * half, Math.sin(rad(TURNED[a])) * half];
|
|
821
|
+
return line([[p[0] - d[0], p[1] - d[1]], [p[0] + d[0], p[1] + d[1]]]);
|
|
822
|
+
};
|
|
823
|
+
const C = [10, 10];
|
|
824
|
+
|
|
825
|
+
// ---- an axis picked: the three from their corner, the one that is meant an arrow in its colour
|
|
826
|
+
const O = [6.5, 11.5];
|
|
827
|
+
const REACH = {
|
|
828
|
+
x: 10.5,
|
|
829
|
+
y: 10.5,
|
|
830
|
+
z: 9.1
|
|
831
|
+
};
|
|
832
|
+
const direction$1 = a => [['sub', others(O, a, b => REACH[b])], [a, arrowTo(O, along$1(O, a, REACH[a]), 3)]];
|
|
833
|
+
|
|
834
|
+
// ---- an offset along an axis: the axis through the corner of the other two, and a point moved
|
|
835
|
+
// along it. A limit is a stop across the axis, in its colour, with the point up against it: at the
|
|
836
|
+
// low end the least it may be, at the high end the most.
|
|
837
|
+
const M = [8.4, 11];
|
|
838
|
+
const RAIL = {
|
|
839
|
+
low: -5.6,
|
|
840
|
+
high: 9,
|
|
841
|
+
at: 4.2
|
|
842
|
+
};
|
|
843
|
+
const offset = (a, limit) => {
|
|
844
|
+
const end = limit === 'min' ? RAIL.low : RAIL.high;
|
|
845
|
+
const rail = line([along$1(M, a, RAIL.low), along$1(M, a, RAIL.high)]);
|
|
846
|
+
return [['sub', others(M, a, () => 7.5)], [a, rail + (limit ? stop(along$1(M, a, end), a) : '')], ['fill', dot$1(along$1(M, a, limit ? end - Math.sign(end) * 2.3 : RAIL.at), 1.6)]];
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
// ---- a turn about an axis: the axis, and a ring round it that comes from behind it, passes in
|
|
850
|
+
// front of it and ends, an arrow, where it is widest. A limit is a stop across the ring where it is
|
|
851
|
+
// widest, in the axis' colour, with a point on the ring up against it: on the side the turn comes
|
|
852
|
+
// from the least it may be, on the side it goes to the most.
|
|
853
|
+
const RING = {
|
|
854
|
+
rx: 5.8,
|
|
855
|
+
ry: 4.4,
|
|
856
|
+
up: 1.6,
|
|
857
|
+
behind: 55
|
|
858
|
+
};
|
|
859
|
+
// a point of the ring about `a`: an ellipse, its short side along the axis
|
|
860
|
+
const onRing = (a, deg) => {
|
|
861
|
+
const c = along$1(C, a, RING.up);
|
|
862
|
+
const [x, y] = [RING.rx * Math.cos(rad(deg)), RING.ry * Math.sin(rad(deg))];
|
|
863
|
+
const [cos, sin] = [Math.cos(rad(TURNED[a])), Math.sin(rad(TURNED[a]))];
|
|
864
|
+
return [c[0] + x * cos - y * sin, c[1] + x * sin + y * cos];
|
|
865
|
+
};
|
|
866
|
+
const rotation = (a, limit) => {
|
|
867
|
+
// where the ring passes in front of the axis, the axis gives way
|
|
868
|
+
const front = RING.up - RING.ry;
|
|
869
|
+
const axis = line([along$1(C, a, -7.8), along$1(C, a, front - 2)]) + line([along$1(C, a, front + 2), along$1(C, a, 7.8)]);
|
|
870
|
+
// the ring runs against the clock round the front, between its two widest points (at 180 and 0)
|
|
871
|
+
// or from behind the axis on the one side, or to behind it on the other
|
|
872
|
+
const [from, to] = limit === 'min' ? [180, -RING.behind] : [180 + RING.behind, 0];
|
|
873
|
+
const ring = `M${at$1(onRing(a, from))}A${RING.rx} ${RING.ry} ${TURNED[a]} 1 0 ${at$1(onRing(a, to))}`;
|
|
874
|
+
return [[a, axis + (limit ? stop(onRing(a, limit === 'min' ? 180 : 0), a) : '')], ['', ring + (limit ? '' : head(onRing(a, 16), onRing(a, 0), 3))], ...(limit ? [['fill', dot$1(onRing(a, limit === 'min' ? 142 : 38), 1.6)]] : [])];
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
// ---- which way an axis points: one arrow through the middle, and the same arrow turned round
|
|
878
|
+
const switched = (a, second) => {
|
|
879
|
+
const [p, q] = [along$1(C, a, -8), along$1(C, a, 8)];
|
|
880
|
+
return [[a, second ? arrowTo(q, p, 3) : arrowTo(p, q, 3)]];
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// ---- the main axis of a mate: from the mate's origin, the axis taken, one way or the other
|
|
884
|
+
const flip = (a, inverse = false) => {
|
|
885
|
+
const s = inverse ? -1 : 1;
|
|
886
|
+
const o = along$1(C, a, -7.2 * s);
|
|
887
|
+
return [[a, arrowTo(o, along$1(C, a, 7.6 * s), 3)], ['fill', dot$1(o, 1.9)]];
|
|
888
|
+
};
|
|
889
|
+
|
|
890
|
+
// ---- a mate turned about its main axis: a dial seen along the axis, a hand at nought, and the
|
|
891
|
+
// turn from it as far as the angle
|
|
892
|
+
const dial = deg => {
|
|
893
|
+
const end = on$1(C, 6.5, 6.5, -deg);
|
|
894
|
+
const swept = `H16.5A6.5 6.5 0 ${deg > 180 ? 1 : 0} 0 ${at$1(end)}`;
|
|
895
|
+
return [['sub', circle(10, 10, 6.5)], ...(deg ? [['tone', `M10 10${swept}Z`]] : []), ['', deg ? `M10 10${swept}` + head(on$1(C, 6.5, 6.5, 22 - deg), end, 2.6) : 'M10 10H16.5'], ['fill', dot$1(C, 1.5)]];
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
// ---- a frame turned in space: the frame a point is given in by its coordinates, seen flat (as
|
|
899
|
+
// the field beside it draws it), and a turn about its origin
|
|
900
|
+
const F = [3.9, 16.1];
|
|
901
|
+
const FRAME$1 = arrowTo(F, [F[0] + 13.6, F[1]], 2.6) + arrowTo(F, [F[0], F[1] - 13.6], 2.6);
|
|
902
|
+
|
|
903
|
+
// ---- a plane lying flat, for the normal that stands on it
|
|
904
|
+
const PLANE$1 = plate(C, 6.4);
|
|
905
|
+
const axes = sheet({
|
|
906
|
+
// ---- an offset along an axis, and its lower and upper limit
|
|
907
|
+
/** An offset along X. */
|
|
908
|
+
offsetX: offset('x'),
|
|
909
|
+
/** The lower limit of an offset along X. */
|
|
910
|
+
offsetXMin: offset('x', 'min'),
|
|
911
|
+
/** The upper limit of an offset along X. */
|
|
912
|
+
offsetXMax: offset('x', 'max'),
|
|
913
|
+
/** An offset along Y. */
|
|
914
|
+
offsetY: offset('y'),
|
|
915
|
+
/** The lower limit of an offset along Y. */
|
|
916
|
+
offsetYMin: offset('y', 'min'),
|
|
917
|
+
/** The upper limit of an offset along Y. */
|
|
918
|
+
offsetYMax: offset('y', 'max'),
|
|
919
|
+
/** An offset along Z. */
|
|
920
|
+
offsetZ: offset('z'),
|
|
921
|
+
/** The lower limit of an offset along Z. */
|
|
922
|
+
offsetZMin: offset('z', 'min'),
|
|
923
|
+
/** The upper limit of an offset along Z. */
|
|
924
|
+
offsetZMax: offset('z', 'max'),
|
|
925
|
+
// ---- an axis picked as a direction
|
|
926
|
+
/** The X axis picked as a direction. */
|
|
927
|
+
directionX: direction$1('x'),
|
|
928
|
+
/** The Y axis picked as a direction. */
|
|
929
|
+
directionY: direction$1('y'),
|
|
930
|
+
// ---- a turn about an axis, its lower and upper limit, and a turn in space
|
|
931
|
+
/** A turn about X. */
|
|
932
|
+
rotationX: rotation('x'),
|
|
933
|
+
/** A turn about Y. */
|
|
934
|
+
rotationY: rotation('y'),
|
|
935
|
+
/** A turn about Z. */
|
|
936
|
+
rotationZ: rotation('z'),
|
|
937
|
+
/** The lower limit of a turn about Z. */
|
|
938
|
+
rotationZMin: rotation('z', 'min'),
|
|
939
|
+
/** The upper limit of a turn about Z. */
|
|
940
|
+
rotationZMax: rotation('z', 'max'),
|
|
941
|
+
/** A turn in space. */
|
|
942
|
+
rotation3d: [['sub', FRAME$1], ['', turn(F, 9, 9, -78, -12, 3)]],
|
|
943
|
+
// ---- which way: the two states of a switch
|
|
944
|
+
/** A direction switch, the one way. */
|
|
945
|
+
switchDirection1: arrowTo([4.5, 15.5], [15.5, 4.5], 3),
|
|
946
|
+
/** A direction switch, the other way. */
|
|
947
|
+
switchDirection2: arrowTo([15.5, 4.5], [4.5, 15.5], 3),
|
|
948
|
+
/** A normal switch, the one way. */
|
|
949
|
+
switchNormal1: [['sub', PLANE$1], ['', arrowTo(C, [10, 2.4], 3)]],
|
|
950
|
+
/** A normal switch, the other way. */
|
|
951
|
+
switchNormal2: [['sub', PLANE$1], ['', arrowTo(C, [10, 17.6], 3)]],
|
|
952
|
+
/** A switch of X, the one way. */
|
|
953
|
+
switchX1: switched('x', false),
|
|
954
|
+
/** A switch of X, the other way. */
|
|
955
|
+
switchX2: switched('x', true),
|
|
956
|
+
/** A switch of Y, the one way. */
|
|
957
|
+
switchY1: switched('y', false),
|
|
958
|
+
/** A switch of Y, the other way. */
|
|
959
|
+
switchY2: switched('y', true),
|
|
960
|
+
// ---- how a mate lies: the axis that is its main one, and which way
|
|
961
|
+
/** A mate whose main axis is X. */
|
|
962
|
+
flipX: flip('x'),
|
|
963
|
+
/** A mate whose main axis is -X. */
|
|
964
|
+
flipXInv: flip('x', true),
|
|
965
|
+
/** A mate whose main axis is Y. */
|
|
966
|
+
flipY: flip('y'),
|
|
967
|
+
/** A mate whose main axis is -Y. */
|
|
968
|
+
flipYInv: flip('y', true),
|
|
969
|
+
/** A mate whose main axis is Z. */
|
|
970
|
+
flipZ: flip('z'),
|
|
971
|
+
/** A mate whose main axis is -Z. */
|
|
972
|
+
flipZInv: flip('z', true),
|
|
973
|
+
// ---- how a mate lies: turned about its main axis
|
|
974
|
+
/** A mate as it lies, not turned about its main axis. */
|
|
975
|
+
reorient0: dial(0),
|
|
976
|
+
/** A mate turned 90° about its main axis. */
|
|
977
|
+
reorient90: dial(90),
|
|
978
|
+
/** A mate turned 180° about its main axis. */
|
|
979
|
+
reorient180: dial(180),
|
|
980
|
+
/** A mate turned 270° about its main axis. */
|
|
981
|
+
reorient270: dial(270)
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
// The sketcher's signs: what it draws, what it holds a drawing by (constraints and dimensions),
|
|
985
|
+
// a point of the sketch: drawn with the 'point' pens, a ring with a light centre
|
|
986
|
+
const dot = (x, y, r = 1.45) => circle(x, y, r);
|
|
987
|
+
|
|
988
|
+
// a point a curve is led by but does not pass through: a small open square
|
|
989
|
+
const ctrl = (x, y, s = 2.6) => rect(x - s / 2, y - s / 2, s, s);
|
|
990
|
+
|
|
991
|
+
// the curve both splines draw, from one corner of the sheet towards the other
|
|
992
|
+
const curve = 'M4 16C4 14.23 4 12.12 6.12 11.06C8.24 10 12 10 14 9S16 6 16 4';
|
|
993
|
+
|
|
994
|
+
// a point on a circle about `c`, by its angle (degrees, clockwise on the sheet from its right)
|
|
995
|
+
const on = (c, r, a) => [c[0] + r * Math.cos(a * Math.PI / 180), c[1] + r * Math.sin(a * Math.PI / 180)];
|
|
996
|
+
|
|
997
|
+
// an arc about `c` from a0 to a1, with an arrow's head where it ends
|
|
998
|
+
const sweep = (c, r, a0, a1, size = 2.6) => {
|
|
999
|
+
const back = (a1 > a0 ? 1 : -1) * size * 0.6 * 180 / (Math.PI * r);
|
|
1000
|
+
return arc(c[0], c[1], r, r, a0, a1) + head(on(c, r, a1 - back), on(c, r, a1), size);
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
// the sheet's middle, and an axis of symmetry upright through it: the chain laid out evenly about it
|
|
1004
|
+
const mid = [10, 10];
|
|
1005
|
+
const axis = 'M10 2.5v2.3M10 6.2v.6M10 8.2v3.6M10 13.2v.6M10 15.2v2.3';
|
|
1006
|
+
|
|
1007
|
+
// which way a thing runs: along X as it is drawn, or up along Y (the sheet mirrored about its rising diagonal)
|
|
1008
|
+
|
|
1009
|
+
const alongX = p => p;
|
|
1010
|
+
const alongY = ([x, y]) => [20 - y, 20 - x];
|
|
1011
|
+
|
|
1012
|
+
// ---- taking an edge of the body into the sketch: the body in grey, and under it the line it gives
|
|
1013
|
+
const body = block(5, [10, 7.4]);
|
|
1014
|
+
const taken = [[3.3, 16.6], [16.7, 16.6]];
|
|
1015
|
+
const takeEdge = pen => [['sub', body.lines], [pen, line(taken)]];
|
|
1016
|
+
|
|
1017
|
+
// ---- a shape and its mirror image, either side of the axis
|
|
1018
|
+
const shape = 'M1.8 14.4h4.8V5.6Z';
|
|
1019
|
+
const image = 'M18.2 14.4h-4.8V5.6Z';
|
|
1020
|
+
|
|
1021
|
+
// ---- a line through `c`, rising to the right
|
|
1022
|
+
const slope = c => line([on(c, 6.6, 135), on(c, 6.6, -45)]);
|
|
1023
|
+
|
|
1024
|
+
// ---- a piece of the sheet's rising diagonal, from t0 to t1 along it
|
|
1025
|
+
const piece = (t0, t1) => line([on([2.6, 17.4], t0, -45), on([2.6, 17.4], t1, -45)]);
|
|
1026
|
+
|
|
1027
|
+
// ---- a dimension between a line's two points, along one way of the sheet
|
|
1028
|
+
const measure = way => [['sub', line([way([4.5, 15]), way([15.5, 11.5])])], ['sub-point', dot(...way([4.5, 15])) + dot(...way([15.5, 11.5]))], ['', spanTo(way([4.5, 5.5]), way([15.5, 5.5]), 2.6)]];
|
|
1029
|
+
// the aligned dimension's own frame: along the line and across it, turned 40° about the sheet's middle
|
|
1030
|
+
const slanted = ([u, v]) => [9.9 + u * 0.766 + v * 0.643, 9.95 - u * 0.643 + v * 0.766];
|
|
1031
|
+
|
|
1032
|
+
// how many: the row (the one that was there, and its copies), and the way it is counted along
|
|
1033
|
+
const count = way => [['sub', arrowTo(way([1.6, 14.6]), way([18.4, 14.6]), 3)], ...copiesInRow(5.8, way)];
|
|
1034
|
+
// how far apart: two of them, and the distance between their middles
|
|
1035
|
+
const spacing = way => [['sub-fill', tile$1(way([4.5, 6.2]), 5) + tile$1(way([15.5, 6.2]), 5)], ['', spanTo(way([2.4, 14.6]), way([17.6, 14.6]), 2.8)]];
|
|
1036
|
+
// which way: the sketch's two axes from their origin, the one that is meant as an arrow
|
|
1037
|
+
const direction = way => [['sub', line([way([4.2, 15.8]), way([4.2, 3.6])])], ['', arrowTo(way([4.2, 15.8]), way([16.8, 15.8]), 3)]];
|
|
1038
|
+
|
|
1039
|
+
// the corner an angle between two copies is measured at
|
|
1040
|
+
const hub = [4.1, 15.2];
|
|
1041
|
+
const sketch = sheet({
|
|
1042
|
+
// ---- drawing: the curve, and the points it is given
|
|
1043
|
+
/** A point. */
|
|
1044
|
+
point: [['sub', 'M10 2.6v14.8M2.6 10h14.8'], ['point', dot(10, 10, 2)]],
|
|
1045
|
+
/** A line between two points. */
|
|
1046
|
+
line: [['', 'M4.5 15.5 15.5 4.5'], ['point', dot(4.5, 15.5) + dot(15.5, 4.5)]],
|
|
1047
|
+
/** A rectangle by two corners. */
|
|
1048
|
+
rect2Points: [['tone', rect(4, 5.5, 12, 9)], ['', rect(4, 5.5, 12, 9)], ['point', dot(4, 14.5) + dot(16, 5.5)]],
|
|
1049
|
+
/** A rectangle by its centre and a corner. */
|
|
1050
|
+
rectCenter: [['tone', rect(4, 5.5, 12, 9)], ['', rect(4, 5.5, 12, 9)], ['point', dot(10, 10) + dot(16, 5.5)]],
|
|
1051
|
+
/** A circle by its centre and a point on it. */
|
|
1052
|
+
circleCenter: [['tone', circle(10, 10, 6.5)], ['sub', 'M10 10 15.63 6.75'], ['', circle(10, 10, 6.5)], ['point', dot(10, 10) + dot(15.63, 6.75)]],
|
|
1053
|
+
// an arc that leaves a line's end the way the line runs
|
|
1054
|
+
/** An arc that leaves a line's end the way the line runs. */
|
|
1055
|
+
arcTangent: [['sub', 'M3.25 15.5h7'], ['', arc(10.25, 9.5, 6, 6, 90, -45)], ['point', dot(10.25, 15.5) + dot(...on([10.25, 9.5], 6, -45))]],
|
|
1056
|
+
/** An arc by its centre and its ends. */
|
|
1057
|
+
arcCenter: [['sub', 'M3.5 9.75 10 13.5 16.5 9.75'], ['', arc(10, 13.5, 7.5, 7.5, -150, -30)], ['point', dot(10, 13.5) + dot(3.5, 9.75) + dot(16.5, 9.75)]],
|
|
1058
|
+
/** An arc through three points. */
|
|
1059
|
+
arc3Points: [['', arc(10, 13.25, 6.5, 6.5, -180, 0)], ['point', dot(3.5, 13.25) + dot(10, 6.75) + dot(16.5, 13.25)]],
|
|
1060
|
+
// ---- free curves: dots for the points on the curve, squares for those it is led by
|
|
1061
|
+
spline: [['sub', 'M4 16V7.2L16 12.8V4'], ['', curve], ['', ctrl(4, 7.2) + ctrl(16, 12.8)], ['point', dot(4, 16) + dot(16, 4)]],
|
|
1062
|
+
intSpline: [['', curve], ['point', dot(4, 16) + dot(10, 10) + dot(16, 4)]],
|
|
1063
|
+
bezier: [['sub', 'M4.9 15.3 2.1 9.5 7.4 5.5 15.2 5.8 17.8 11.1'], ['', 'M4.9 15.3C4.6 14 4.3 12.7 4.95 11.3C5.6 9.85 7 9 8.2 8.65C9.35 8.3 11.6 8.05 13.6 8.6C15.6 9.15 16.7 10.1 17.8 11.1'], ['', ctrl(2.1, 9.5) + ctrl(7.4, 5.5) + ctrl(15.2, 5.8)], ['point', dot(4.9, 15.3) + dot(17.8, 11.1)]],
|
|
1064
|
+
// ---- changing what is drawn: a corner rounded, a line cut back, a line cut in two
|
|
1065
|
+
/** A sketch's corner rounded. */
|
|
1066
|
+
sketchFillet: [['sub', 'M3.5 3.5H10M16.5 10v6.5'], ['', arc(10, 10, 6.5, 6.5, -90, 0)]],
|
|
1067
|
+
/** A line cut back. */
|
|
1068
|
+
trim: [['sub', 'M5.5 16.5 10 3.5M2.5 10h5'], ['sub-dash', 'M8.2 10h9.3'], ['', 'M11.2 7.2l5.6 5.6M16.8 7.2l-5.6 5.6']],
|
|
1069
|
+
/** A line cut in two. */
|
|
1070
|
+
split: [['', 'M3.5 16.5 7.6 12.4M12.4 7.6 16.5 3.5'], ['point', dot(10, 10, 1.7)]],
|
|
1071
|
+
// ---- an edge of the body, taken into the sketch: as a line of its own, or as a reference only
|
|
1072
|
+
/** An edge of the body taken into the sketch as a line of its own. */
|
|
1073
|
+
useGeometry: takeEdge(''),
|
|
1074
|
+
/** An edge of the body taken into the sketch as a reference only. */
|
|
1075
|
+
useReference: takeEdge('dash'),
|
|
1076
|
+
// ---- kinds of line
|
|
1077
|
+
/** A line of the profile. */
|
|
1078
|
+
solidLine: [['', 'M4.5 15.5 15.5 4.5'], ['point', dot(4.5, 15.5) + dot(15.5, 4.5)]],
|
|
1079
|
+
/** A construction line: dashed, not part of the profile. */
|
|
1080
|
+
constructionLine: [['dash', 'M4.5 15.5 15.5 4.5'], ['point', dot(4.5, 15.5) + dot(15.5, 4.5)]],
|
|
1081
|
+
/** The line a sketch is mirrored in. */
|
|
1082
|
+
mirrorLine: [['sub-fill', shape + image], ['', axis]],
|
|
1083
|
+
// ---- holding: what is held in grey, what holds it in ink
|
|
1084
|
+
/** Horizontal: a line held level. */
|
|
1085
|
+
horizontal: [['sub', 'M3.5 15h13'], ['', 'M8 4.5v6.5M12 4.5v6.5M8 7.75h4']],
|
|
1086
|
+
/** Vertical: a line held upright. */
|
|
1087
|
+
vertical: [['sub', 'M5 3.5v13'], ['', 'M10 6.75l2 6.5 2-6.5']],
|
|
1088
|
+
/** Coincident: two points held as one. */
|
|
1089
|
+
coincident: [['sub', 'M3.5 15.5 10 9M16.5 5.5 10 9'], ['', circle(10, 9, 3)], ['point', dot(10, 9, 1.2)]],
|
|
1090
|
+
// a point on the ground: the bar, and its hatching below
|
|
1091
|
+
/** Fixed: a point held where it is. */
|
|
1092
|
+
fixed: [['', 'M3.5 10.4h13M6.9 10.4l-2.2 4.4M11.1 10.4l-2.2 4.4M15.3 10.4l-2.2 4.4'], ['point', dot(10, 6.4, 2)]],
|
|
1093
|
+
/** Tangent: a curve that leaves another the way it runs. */
|
|
1094
|
+
tangent: [['sub', circle(12.38, 12.38, 4.6)], ['', 'M3 15.4 15.4 3'], ['point', dot(9.13, 9.13, 1.7)]],
|
|
1095
|
+
/** Equal curvature: two curves held as round as each other. */
|
|
1096
|
+
equalCurvature: [['sub', 'M3.5 2.2C3.5 4 6.5 4.4 10 5.1C13.5 5.8 15.9 6 16.5 7.2' + 'M3.5 12.8C3.5 14.6 6.5 15 10 15.7C13.5 16.4 15.9 16.6 16.5 17.8'], ['', 'M6.5 8.3h7M6.5 11.7h7']],
|
|
1097
|
+
/** Parallel: two lines held parallel. */
|
|
1098
|
+
parallelLines: [['', slope(on(mid, 2.6, -135)) + slope(on(mid, 2.6, 45))]],
|
|
1099
|
+
/** Perpendicular: two lines held at a right angle. */
|
|
1100
|
+
perpendicular: [['', 'M3 16.5h14M10 16.5V3.5'], ['sub', 'M14.5 16.5V12H10']],
|
|
1101
|
+
// two pieces of one line: the line they lie on runs through both
|
|
1102
|
+
/** Colinear: two lines held on one line. */
|
|
1103
|
+
colinear: [['sub-dash', piece(0.4, 20.5)], ['', piece(3.2, 7.9) + piece(13, 17.7)]],
|
|
1104
|
+
/** Concentric: circles held about one centre. */
|
|
1105
|
+
concentric: [['', circle(10, 10, 7.2) + circle(10, 10, 3.4)], ['point', dot(10, 10, 1.2)]],
|
|
1106
|
+
// the point in a line's middle
|
|
1107
|
+
/** Midpoint: a point held in a line's middle. */
|
|
1108
|
+
midpoint: [['sub', 'M4 16 16 4'], ['sub-point', dot(4, 16) + dot(16, 4)], ['point', dot(10, 10, 2)]],
|
|
1109
|
+
/** Symmetric: two points held either side of a line. */
|
|
1110
|
+
symmetric: [['axis', 'M10 2v16'], ['', 'M3.6 10h2.6M13.8 10h2.6'], ['point', dot(4.6, 10, 1.9) + dot(15.4, 10, 1.9)]],
|
|
1111
|
+
/** Equal: two lines held as long, or two circles as large, as each other. */
|
|
1112
|
+
equal: [['sub', 'M3.5 5 16.5 3M3.5 17 16.5 15'], ['', 'M6.5 8.3h7M6.5 11.7h7']],
|
|
1113
|
+
/** Equal radius: two circles or arcs held as large as each other. */
|
|
1114
|
+
equalRadius: [['sub', arc(10, 11.04, 8.54, 8.54, -139.6, -40.4) + arc(10, 8.96, 8.54, 8.54, 40.4, 139.6)], ['', 'M6.5 8.3h7M6.5 11.7h7']],
|
|
1115
|
+
// several points held as one: a group's frame around them, a handle at each corner
|
|
1116
|
+
/** Rigid set: several shapes held as one. */
|
|
1117
|
+
rigidSet: [['', ctrl(3, 3, 2.4) + ctrl(17, 3, 2.4) + ctrl(3, 17, 2.4) + ctrl(17, 17, 2.4) + 'M4.3 3H7.4M12.6 3h3.1M4.3 17H7.4M12.6 17h3.1' + 'M3 4.3V7.4M3 12.6v3.1M17 4.3V7.4M17 12.6v3.1'], ['point', dot(8, 12, 2) + dot(12, 8, 2)]],
|
|
1118
|
+
// ---- measuring: the thing in grey, its dimension in ink
|
|
1119
|
+
/** A horizontal dimension. */
|
|
1120
|
+
dimHorizontal: measure(alongX),
|
|
1121
|
+
/** A vertical dimension. */
|
|
1122
|
+
dimVertical: measure(alongY),
|
|
1123
|
+
/** A dimension along a line. */
|
|
1124
|
+
dimLinear: [['sub', line([slanted([-5.5, 3.4]), slanted([5.5, 3.4])])], ['sub-point', dot(...slanted([-5.5, 3.4])) + dot(...slanted([5.5, 3.4]))], ['', spanTo(slanted([-5.5, -2.4]), slanted([5.5, -2.4]), 2.6)]],
|
|
1125
|
+
/** A radius. */
|
|
1126
|
+
radius: [['sub', arc(4, 16, 12, 12, -90, 0)], ['', arrowTo([4, 16], on([4, 16], 11.2, -45), 3.6)], ['point', dot(4, 16)]],
|
|
1127
|
+
/** A diameter. */
|
|
1128
|
+
sketchDiameter: [['sub', circle(10, 10, 7)], ['', spanTo(on(mid, 5.6, 135), on(mid, 5.6, -45), 2.8)]],
|
|
1129
|
+
// a line's angle against the X axis
|
|
1130
|
+
/** A line's angle against the X axis. */
|
|
1131
|
+
angleOX: [['sub', 'M3.5 16h13.5' + line([[3.5, 16], on([3.5, 16], 14, -62)])], ['', sweep([3.5, 16], 10.5, -4, -52)]],
|
|
1132
|
+
// ---- repeating: the original in grey, its copies in ink
|
|
1133
|
+
/** Shapes of a sketch repeated along a line. */
|
|
1134
|
+
pattern2dLinear: copiesInRow(10),
|
|
1135
|
+
/** Shapes of a sketch repeated about a point. */
|
|
1136
|
+
pattern2dCircular: copiesAround(),
|
|
1137
|
+
/** Shapes of a sketch mirrored in a line. */
|
|
1138
|
+
pattern2dMirror: [['sub-fill', shape], ['axis', 'M10 2v16'], ['fill', image]],
|
|
1139
|
+
// ---- what a pattern is set by: how far apart, which way, how many, at what angle
|
|
1140
|
+
/** A sketch pattern's spacing along its first direction. */
|
|
1141
|
+
sketchDistanceX: spacing(alongX),
|
|
1142
|
+
/** A sketch pattern's spacing along its second direction. */
|
|
1143
|
+
sketchDistanceY: spacing(alongY),
|
|
1144
|
+
/** A sketch pattern's first direction. */
|
|
1145
|
+
sketchDirectionX: direction(alongX),
|
|
1146
|
+
/** A sketch pattern's second direction. */
|
|
1147
|
+
sketchDirectionY: direction(alongY),
|
|
1148
|
+
/** A sketch pattern's count along its first direction. */
|
|
1149
|
+
sketchCountX: count(alongX),
|
|
1150
|
+
/** A sketch pattern's count along its second direction. */
|
|
1151
|
+
sketchCountY: count(alongY),
|
|
1152
|
+
/** A sketch pattern's count about its centre. */
|
|
1153
|
+
sketchCountAngular: copiesAround(),
|
|
1154
|
+
/** A sketch pattern's angle. */
|
|
1155
|
+
sketchAngle: [['sub', line([on(hub, 13, 0), hub, on(hub, 13, -62)])], ['', sweep(hub, 9, -4, -52, 2.6)], ['point', dot(hub[0], hub[1], 1.45)]]
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
// What a pick field of a feature's window wants clicked on the model, or what the pick gives: an
|
|
1159
|
+
const f = v => Math.round(v * 100) / 100;
|
|
1160
|
+
const at = p => `${f(p[0])} ${f(p[1])}`;
|
|
1161
|
+
// a point that is picked or given: a larger dot than a shape's corner has, for here it is all a sign says
|
|
1162
|
+
const point = p => dot$1(p, 2);
|
|
1163
|
+
// the point `t` past `b` on the line from `a`
|
|
1164
|
+
const past = (a, b, t) => {
|
|
1165
|
+
const d = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
1166
|
+
return [b[0] + (b[0] - a[0]) * t / d, b[1] + (b[1] - a[1]) * t / d];
|
|
1167
|
+
};
|
|
1168
|
+
const MID = [10, 10];
|
|
1169
|
+
|
|
1170
|
+
// ---- a body: the cube every sign of a body starts from. The corners of its top (left, far,
|
|
1171
|
+
// right, near), and the upright edge at its near corner
|
|
1172
|
+
const c = cube.cam;
|
|
1173
|
+
const TOP = [[-0.5, -0.5, 0.5], [-0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [0.5, -0.5, 0.5]].map(c);
|
|
1174
|
+
const EDGE = [TOP[3], c([0.5, -0.5, -0.5])];
|
|
1175
|
+
// an end of an edge, where a chain of them is linked: smaller than a point that is picked
|
|
1176
|
+
const knot = p => dot$1(p, 1.6);
|
|
1177
|
+
|
|
1178
|
+
// ---- two bodies: small enough to stand apart, the second up and to the right of the first.
|
|
1179
|
+
// (So small, a cube keeps its outline and its top; the edge down its near corner would fill it.)
|
|
1180
|
+
const TWO = [block(3.8, [5.3, 13.6]), block(3.8, [14.7, 6.4])];
|
|
1181
|
+
|
|
1182
|
+
// ---- a sheet: a surface with no thickness, bent up along one side (its profile in XZ, swept along Y)
|
|
1183
|
+
const SHEET = (() => {
|
|
1184
|
+
const cam = iso(8.4, [2.72, 13.15]);
|
|
1185
|
+
const edge = y => [[0, y, 0.75], [0.06, y, 0.18], [0.4, y, 0], [1, y, 0]].map(cam);
|
|
1186
|
+
const [a, b] = [edge(0), edge(1).reverse()];
|
|
1187
|
+
return `M${at(a[0])}C${a.slice(1).map(at).join(' ')}L${at(b[0])}C${b.slice(1).map(at).join(' ')}Z`;
|
|
1188
|
+
})();
|
|
1189
|
+
|
|
1190
|
+
// ---- a frame, seen flat: two axes from its origin `o`, `a` long
|
|
1191
|
+
const frame = (o, a, size = 2.4) => arrowTo(o, [o[0] + a, o[1]], size) + arrowTo(o, [o[0], o[1] - a], size);
|
|
1192
|
+
// the first of two frames and the second: the second lies up and to the right of the first
|
|
1193
|
+
const FRAME = [frame([3.4, 16.2], 6.8), frame([11, 9.6], 6.8)];
|
|
1194
|
+
// the frame a point or a direction is given in by its coordinates: as large as the sheet takes
|
|
1195
|
+
const ORIGIN = [3.9, 16.1];
|
|
1196
|
+
const AXES = frame(ORIGIN, 13.6, 2.6);
|
|
1197
|
+
|
|
1198
|
+
// ---- the plane that is laid through a point, three points, a line: they lie on its rim
|
|
1199
|
+
const LAID = [10, 9.4];
|
|
1200
|
+
const PLANE = plate(LAID, 6.2);
|
|
1201
|
+
const rim = a => on$1(LAID, 6.2, 6.2 / Math.sqrt(3), a);
|
|
1202
|
+
|
|
1203
|
+
// ---- the line a direction lies on, the way it points: from 0 at its lower left to 1
|
|
1204
|
+
const along = t => [3 + 14 * t, 17 - 14 * t];
|
|
1205
|
+
|
|
1206
|
+
// ---- two planes that meet: a wall standing on a floor, both 7.4 wide. Where they meet runs along Y
|
|
1207
|
+
const CREASE = [[3.4, 13.4], [9.98, 9.6]];
|
|
1208
|
+
const up = p => [p[0], p[1] - 7.4];
|
|
1209
|
+
const out = p => [p[0] + 6.41, p[1] + 3.7];
|
|
1210
|
+
const WALL = line([CREASE[0], up(CREASE[0]), up(CREASE[1]), CREASE[1]]);
|
|
1211
|
+
const FLOOR = line([CREASE[0], out(CREASE[0]), out(CREASE[1]), CREASE[1]]);
|
|
1212
|
+
|
|
1213
|
+
// ---- a curve, and where the arrow leaves it, the way it runs there
|
|
1214
|
+
const LEAVE = [6.4, 12];
|
|
1215
|
+
const BEND = [LEAVE[0] + 6 * Math.SQRT1_2, LEAVE[1] + 6 * Math.SQRT1_2];
|
|
1216
|
+
|
|
1217
|
+
// ---- three lines, and the circle they hold
|
|
1218
|
+
const TRI = [[2, 17], [18, 17], [8, 2.4]];
|
|
1219
|
+
const INNER = (() => {
|
|
1220
|
+
const [a, b, d] = TRI;
|
|
1221
|
+
const len = (p, q) => Math.hypot(p[0] - q[0], p[1] - q[1]);
|
|
1222
|
+
const [la, lb, ld] = [len(b, d), len(a, d), len(a, b)];
|
|
1223
|
+
const sum = la + lb + ld;
|
|
1224
|
+
const area = Math.abs((b[0] - a[0]) * (d[1] - a[1]) - (d[0] - a[0]) * (b[1] - a[1])) / 2;
|
|
1225
|
+
const mid = [(la * a[0] + lb * b[0] + ld * d[0]) / sum, (la * a[1] + lb * b[1] + ld * d[1]) / sum];
|
|
1226
|
+
return {
|
|
1227
|
+
mid,
|
|
1228
|
+
r: 2 * area / sum
|
|
1229
|
+
};
|
|
1230
|
+
})();
|
|
1231
|
+
|
|
1232
|
+
// ---- two bodies side by side, seen flat as the mates draw them. A mate is the knob on the one
|
|
1233
|
+
// that is meant, on its side towards the other (and well clear of that other)
|
|
1234
|
+
const BODY = [rect(2, 5.5, 4.6, 9, 1.2), rect(13.4, 5.5, 4.6, 9, 1.2)];
|
|
1235
|
+
const mate = i => [['sub', BODY[1 - i]], ...toned(BODY[i]), ['fill', dot$1([8.3 + 3.4 * i, 10], 1.7)]];
|
|
1236
|
+
|
|
1237
|
+
// ---- a plane lying flat, low enough for two of them to lie well apart
|
|
1238
|
+
const flat$1 = y => line([[2, y], [7.4, y - 2.4], [12.8, y], [7.4, y + 2.4]], true);
|
|
1239
|
+
const refs = sheet({
|
|
1240
|
+
// ---- things on a body. The body is grey; what is picked on it is ink
|
|
1241
|
+
// an edge: one of the body's, from end to end
|
|
1242
|
+
/** An edge of a body, picked. */
|
|
1243
|
+
edges: [['sub', cube.lines], ['', line(EDGE)], ['fill', EDGE.map(knot).join('')]],
|
|
1244
|
+
// a face: the top, filled (the tone is laid three times: once does not show on so small a face)
|
|
1245
|
+
/** A face of a body, picked. */
|
|
1246
|
+
face: [['sub', cube.lines], ['tone', cube.top], ['tone', cube.top], ...toned(cube.top)],
|
|
1247
|
+
// a loop: the chain of edges round the top, link by link, and not the face in it
|
|
1248
|
+
/** A loop: the chain of edges around a face, picked. */
|
|
1249
|
+
loop: [['sub', cube.lines], ['', cube.top], ['fill', TOP.map(knot).join('')]],
|
|
1250
|
+
// ---- bodies
|
|
1251
|
+
// one body: the cube
|
|
1252
|
+
/** A body, picked. */
|
|
1253
|
+
instance: [['tone', cube.outline], ['tone', cube.top], ['', cube.lines]],
|
|
1254
|
+
// several: a second one beside the first
|
|
1255
|
+
/** Several bodies, picked. */
|
|
1256
|
+
instances: [['tone', TWO[0].outline + TWO[1].outline], ['tone', TWO[0].top + TWO[1].top], ['', TWO[0].outline + TWO[0].top + TWO[1].outline + TWO[1].top]],
|
|
1257
|
+
// several that are taken away (the other bodies of a cut): their outlines, with nothing in them
|
|
1258
|
+
/** Several bodies that are taken away (the other bodies of a cut). */
|
|
1259
|
+
instancesOpen: TWO[0].outline + TWO[1].outline,
|
|
1260
|
+
// a sheet: a surface with no thickness (`sheet` is the same, as a row of the geometry list)
|
|
1261
|
+
/** A sheet: a surface with no thickness, picked. */
|
|
1262
|
+
sheetBody: toned(SHEET),
|
|
1263
|
+
/** A sheet, as a row of the bodies' list. */
|
|
1264
|
+
sheet: toned(SHEET),
|
|
1265
|
+
// ---- two frames: the one to start from (the first in ink), the one to go to (the second)
|
|
1266
|
+
/** The coordinate system to start from. */
|
|
1267
|
+
csysFrom: [['sub', FRAME[1]], ['', FRAME[0]]],
|
|
1268
|
+
/** The coordinate system to go to. */
|
|
1269
|
+
csysTo: [['sub', FRAME[0]], ['', FRAME[1]]],
|
|
1270
|
+
// ---- given by coordinates: grey axes, and in them a point, or a direction from their origin
|
|
1271
|
+
/** A point given by its coordinates. */
|
|
1272
|
+
position: [['sub', AXES], ['fill', point([12.9, 7.1])]],
|
|
1273
|
+
/** A direction given by its coordinates. */
|
|
1274
|
+
direction3d: [['sub', AXES], ['', arrowTo(ORIGIN, [14.9, 5.1], 3)]],
|
|
1275
|
+
// ---- a direction: one ink arrow, and in grey what gives it
|
|
1276
|
+
// a line: the arrow lies on it
|
|
1277
|
+
/** A direction along a line. */
|
|
1278
|
+
direction: [['sub', line([along(-0.04), along(1.04)])], ['', arrowTo(along(0.08), along(0.84), 3)]],
|
|
1279
|
+
// two points: the arrow from the one to the other
|
|
1280
|
+
/** A direction from one point to another. */
|
|
1281
|
+
directionPoints: [['sub-fill', point(along(0.05)) + point(along(0.95))], ['', arrowTo(along(0.24), along(0.72), 3)]],
|
|
1282
|
+
// two planes: the arrow along where they meet
|
|
1283
|
+
/** A direction along where two planes meet. */
|
|
1284
|
+
directionPlanes: [['sub', WALL + FLOOR], ['', arrowTo(CREASE[0], past(CREASE[0], CREASE[1], 6.4), 3)]],
|
|
1285
|
+
// a curve: the arrow leaves it the way it runs
|
|
1286
|
+
/** A direction the way a curve runs. */
|
|
1287
|
+
directionCurve: [['sub', arc(BEND[0], BEND[1], 6, 6, 165, 325)], ['', arrowTo(LEAVE, [LEAVE[0] + 9.3, LEAVE[1] - 9.3], 3)]],
|
|
1288
|
+
// a plane: the arrow stands on it
|
|
1289
|
+
/** A direction that stands on a plane: its normal. */
|
|
1290
|
+
normal: [['sub', plate([10, 13.8], 7.2)], ['', arrowTo([10, 13.8], [10, 2.4], 3)]],
|
|
1291
|
+
// ---- a plane: how far it lies from the one it is taken from; what it is laid through
|
|
1292
|
+
/** A plane at an offset from another. */
|
|
1293
|
+
planeOffset: [['sub', flat$1(15)], ...toned(flat$1(5)), ['', spanTo([16.6, 3.4], [16.6, 16.6], 2.8)]],
|
|
1294
|
+
// one point: a dot on the rim
|
|
1295
|
+
/** A plane through a point. */
|
|
1296
|
+
pointOnPlane: [['sub', PLANE], ['fill', point(rim(90))]],
|
|
1297
|
+
// three points: a dot on three corners
|
|
1298
|
+
/** A plane through three points. */
|
|
1299
|
+
pointsOnPlane: [['sub', PLANE], ['fill', [180, 0, 90].map(a => point(rim(a))).join('')]],
|
|
1300
|
+
// a line: one side of the rim, running on past it
|
|
1301
|
+
/** A plane through a line. */
|
|
1302
|
+
lineOnPlane: [['sub', PLANE], ['', line([past(rim(90), rim(180), 2), past(rim(180), rim(90), 2)])]],
|
|
1303
|
+
// ---- a work point: the one ink dot, and in grey what it is the middle or the meeting of
|
|
1304
|
+
// the middle of a face of a body
|
|
1305
|
+
/** The middle of a body's face. */
|
|
1306
|
+
barycenter: [['sub', cube.lines], ['fill', point(c([0, 0, 0.5]))]],
|
|
1307
|
+
// the middle between two points
|
|
1308
|
+
/** The middle between two points. */
|
|
1309
|
+
midpointPoints: [['sub-fill', point([3.6, 16.4]) + point([16.4, 3.6])], ['fill', point(MID)]],
|
|
1310
|
+
// the middle of a line
|
|
1311
|
+
/** The middle of a line. */
|
|
1312
|
+
midpointLine: [['sub', 'M3.5 16.5L16.5 3.5'], ['fill', point(MID)]],
|
|
1313
|
+
// the middle of the circle three lines hold (a smaller dot: the circle is close around it)
|
|
1314
|
+
/** The centre of the circle three lines hold. */
|
|
1315
|
+
innerCircle: [['sub', line(TRI, true) + circle(INNER.mid[0], INNER.mid[1], INNER.r)], ['fill', dot$1(INNER.mid, 1.6)]],
|
|
1316
|
+
// where two lines cross
|
|
1317
|
+
/** Where two lines cross. */
|
|
1318
|
+
intersectionPoint: [['sub', 'M2.6 13.4L17.4 6.6M5.6 3L14.4 17'], ['fill', point(MID)]],
|
|
1319
|
+
// the centre of an arc
|
|
1320
|
+
/** The centre of an arc. */
|
|
1321
|
+
arc: [['sub', arc(10, 10, 7.2, 7.2, 40, 320)], ['fill', point(MID)]],
|
|
1322
|
+
// ---- two bodies to be joined: the mate on the first, the mate on the second
|
|
1323
|
+
/** The mate on the first of two instances to be joined. */
|
|
1324
|
+
mate1: mate(0),
|
|
1325
|
+
/** The mate on the second of two instances to be joined. */
|
|
1326
|
+
mate2: mate(1)
|
|
1327
|
+
});
|
|
1328
|
+
|
|
1329
|
+
// How two instances of an assembly are held to each other. Grey is the bodies. Ink is the one
|
|
1330
|
+
// ---- the ground, as a drawing shows what is fixed: a bar, and its hatching below
|
|
1331
|
+
const ground = 'M3 13.2h14M6.6 13.2l-2.2 4.2M10.8 13.2l-2.2 4.2M15 13.2l-2.2 4.2';
|
|
1332
|
+
|
|
1333
|
+
// ---- a pin upright through `x`, and a turn about it as it is seen from the side: the turn comes
|
|
1334
|
+
// round the pin's near side
|
|
1335
|
+
const pin = x => rect(x - 2.2, 2.4, 4.4, 15.2, 1.6);
|
|
1336
|
+
const about = (x, rx = 7) => turn([x, 10], rx, rx * 0.42, -55, 222, 2.8);
|
|
1337
|
+
|
|
1338
|
+
// ---- a plate lying flat, low enough for two of them to lie well apart
|
|
1339
|
+
const flat = y => line([[2, y], [7, y - 2.3], [12, y], [7, y + 2.3]], true);
|
|
1340
|
+
|
|
1341
|
+
// ---- two wheels that touch, the one driving the other
|
|
1342
|
+
const BIG = [7.2, 11];
|
|
1343
|
+
const LITTLE = [14.6, 8.2];
|
|
1344
|
+
const mates = sheet({
|
|
1345
|
+
// ---- nothing left free: held to the ground; held to one another, by a strap across where they touch
|
|
1346
|
+
/** Fastened origin: an instance held to the ground. */
|
|
1347
|
+
fastenedOrigin: [['sub', rect(5.5, 3.2, 9, 10, 1.2)], ['', ground]],
|
|
1348
|
+
/** Fastened: two instances held to one another. */
|
|
1349
|
+
fastened: [['sub', rect(2, 5.5, 6, 9, 1.2) + rect(12, 5.5, 6, 9, 1.2)], ['fill', rect(5.4, 8.4, 9.2, 3.2, 1.6)]],
|
|
1350
|
+
// ---- one way to slide: a block on its rail
|
|
1351
|
+
/** Slider: a block on its rail, free to slide one way. */
|
|
1352
|
+
slider: [['sub', 'M2.5 13.2H17.5' + rect(6, 10, 8, 6.4, 1.2)], ['', spanTo([3, 5.4], [17, 5.4], 2.8)]],
|
|
1353
|
+
// ---- a turn about an axis; and the same, free to slide along it too
|
|
1354
|
+
/** Revolute: a turn about an axis. */
|
|
1355
|
+
revolute: [['sub', pin(10)], ['', about(10)]],
|
|
1356
|
+
/** Cylindrical: a turn about an axis, free to slide along it too. */
|
|
1357
|
+
cylindrical: [['sub', pin(6.6)], ['', about(6.6, 4.4)], ['', spanTo([16.8, 3], [16.8, 17], 2.6)]],
|
|
1358
|
+
// ---- sliding on a plane: either way along both of its edges (the plate seen from above)
|
|
1359
|
+
/** Planar: free to slide on a plane. */
|
|
1360
|
+
planar: [['sub', rect(3, 3, 14, 14, 1.6)], ['', spanTo([10, 5.4], [10, 14.6], 2.4) + spanTo([5.4, 10], [14.6, 10], 2.4)]],
|
|
1361
|
+
// ---- two faces kept parallel: two plates, one above the other, and the sign for it
|
|
1362
|
+
/** Parallel: two faces kept parallel. */
|
|
1363
|
+
parallel: [['sub', flat(5.2) + flat(14.8)], ['', 'M14 13.4L15.4 6.6M17 13.4L18.4 6.6']],
|
|
1364
|
+
// ---- a turn about a point: a ball in its cup, and its swing
|
|
1365
|
+
/** Spherical: a ball in its cup, free to turn about a point. */
|
|
1366
|
+
spherical: [['sub', 'M2.4 11.6h1.6a6 6 0 0 0 12 0h1.6'], ['tone', circle(10, 11.6, 3.2)], ['', circle(10, 11.6, 3.2)], ['', turn([10, 11.6], 8.4, 8.4, -132, -48, 2.6) + turn([10, 11.6], 8.4, 8.4, -48, -132, 2.6)]],
|
|
1367
|
+
// ---- several instances, held as one: a frame around them
|
|
1368
|
+
/** Group: several instances held as one. */
|
|
1369
|
+
group: [['sub-fill', tile$1([6.8, 12.2]) + tile$1([13.2, 7.8])], ['dash', rect(2.4, 3, 15.2, 14, 3)]],
|
|
1370
|
+
// ---- an instance repeated: along a line, and about a point
|
|
1371
|
+
/** An instance repeated along a line (the assembly's linear pattern). */
|
|
1372
|
+
linearPatternConstraint: [...copiesInRow(5.8), ['', arrowTo([1.6, 14.6], [18.4, 14.6], 3)]],
|
|
1373
|
+
/** An instance repeated about a point (the assembly's circular pattern). */
|
|
1374
|
+
circularPatternConstraint: copiesAround(),
|
|
1375
|
+
// ---- two turns, the one driving the other
|
|
1376
|
+
/** Gear: two turns, the one driving the other. */
|
|
1377
|
+
gear: [['sub', circle(BIG[0], BIG[1], 4.6) + circle(LITTLE[0], LITTLE[1], 3.3)], ['sub-fill', dot$1(BIG, 1.1) + dot$1(LITTLE, 1.1)], ['', turn(BIG, 7.2, 7.2, 100, 185, 2.4) + turn(LITTLE, 5.8, 5.8, -80, -165, 2.4)]]
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1381
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1382
|
+
|
|
1383
|
+
// what stands in for a drawing that is not there: a dashed square. It is meant to be seen.
|
|
1384
|
+
const missing = sheet({
|
|
1385
|
+
/** A dashed square: what stands in for a name that has no drawing. */
|
|
1386
|
+
missing: [['sub-dash', 'M4 4h12v12H4Z']]
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Every drawing the app has, by name: what {@link Icon} draws.
|
|
1391
|
+
*
|
|
1392
|
+
* The sheets are the app's own signs (its bars, rows and menus), the features, the sketch's tools and constraints,
|
|
1393
|
+
* what a field sets (a length, a count, an angle, along an axis), what a field picks, the mates of an assembly, and a
|
|
1394
|
+
* few glyphs. `missing` is the dashed square that stands in for a name that has no drawing.
|
|
1395
|
+
*
|
|
1396
|
+
* @example
|
|
1397
|
+
* ```tsx
|
|
1398
|
+
* import { Icon, icons } from '@classcad/react-cad'
|
|
1399
|
+
* import type { IconName } from '@classcad/react-cad'
|
|
1400
|
+
*
|
|
1401
|
+
* // a sheet of every icon there is, each with its name
|
|
1402
|
+
* const Sheet = () => (
|
|
1403
|
+
* <div style={{ display: 'grid', gridTemplateColumns: 'repeat(8, 1fr)', gap: 12 }}>
|
|
1404
|
+
* {(Object.keys(icons) as IconName[]).map((name) => (
|
|
1405
|
+
* <figure key={name}>
|
|
1406
|
+
* <Icon name={name} size={32} title={name} />
|
|
1407
|
+
* <figcaption>{name}</figcaption>
|
|
1408
|
+
* </figure>
|
|
1409
|
+
* ))}
|
|
1410
|
+
* </div>
|
|
1411
|
+
* )
|
|
1412
|
+
* ```
|
|
1413
|
+
*
|
|
1414
|
+
* @category Icons
|
|
1415
|
+
*/
|
|
1416
|
+
const drawings = _objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1(_objectSpread$1({}, missing), ui), glyphs), mates), params), axes), sketch), refs), features);
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* The name of one of the app's drawings: a key of {@link icons}, such as `'extrusion'`.
|
|
1420
|
+
*
|
|
1421
|
+
* @category Icons
|
|
1422
|
+
*/
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* The drawing of a name, or the dashed square where there is none.
|
|
1426
|
+
*
|
|
1427
|
+
* @internal
|
|
1428
|
+
*/
|
|
1429
|
+
const drawingOf = name => {
|
|
1430
|
+
var _name;
|
|
1431
|
+
return (_name = drawings[name]) != null ? _name : drawings.missing;
|
|
1432
|
+
};
|
|
1433
|
+
|
|
1434
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1435
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1436
|
+
const PREFIX = 'rcad:';
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* An icon's reference: a string (`'rcad:extrusion'`) that goes wherever an image's url went before.
|
|
1440
|
+
*
|
|
1441
|
+
* It goes into a plugin description's `iconUrl` or a menu item's icon, say: {@link Icon} draws it from its `url`, and
|
|
1442
|
+
* shows anything else it is handed there as the image it is. {@link iconSvg} and {@link iconDataUrl} take it too.
|
|
1443
|
+
*
|
|
1444
|
+
* @param name - The drawing's name.
|
|
1445
|
+
* @example
|
|
1446
|
+
* ```tsx
|
|
1447
|
+
* import { Icon, iconRef } from '@classcad/react-cad'
|
|
1448
|
+
*
|
|
1449
|
+
* // what took an image's url takes the reference: it is drawn as the sign, in the theme's ink
|
|
1450
|
+
* const tools = [
|
|
1451
|
+
* { name: 'Extrude', iconUrl: iconRef('extrusion') },
|
|
1452
|
+
* { name: 'Logo', iconUrl: '/logo.svg' },
|
|
1453
|
+
* ]
|
|
1454
|
+
* const Tools = () => (
|
|
1455
|
+
* <>{tools.map((tool) => <Icon key={tool.name} url={tool.iconUrl} size={20} title={tool.name} />)}</>
|
|
1456
|
+
* )
|
|
1457
|
+
* ```
|
|
1458
|
+
*
|
|
1459
|
+
* @category Icons
|
|
1460
|
+
*/
|
|
1461
|
+
const iconRef = name => PREFIX + name;
|
|
1462
|
+
/**
|
|
1463
|
+
* Whether a string is an icon's reference ({@link iconRef}) rather than an image's url.
|
|
1464
|
+
*
|
|
1465
|
+
* @internal
|
|
1466
|
+
*/
|
|
1467
|
+
const isIconRef = url => typeof url === 'string' && url.startsWith(PREFIX);
|
|
1468
|
+
const layersOf = drawing => typeof drawing === 'string' ? [['', drawing]] : drawing;
|
|
1469
|
+
|
|
1470
|
+
// The circles of a drawing's points: what is cut away from its other layers, so their centres stay light.
|
|
1471
|
+
const holesOf = layers => layers.filter(([pen]) => isPointPen(pen)).map(([, d]) => d).join('');
|
|
1472
|
+
|
|
1473
|
+
// A line's weight is in px on screen, whatever the size the drawing is shown at.
|
|
1474
|
+
const weight = size => size <= 14 ? 1.3 : size <= 16 ? 1.4 : size <= 18 ? 1.45 : size <= 24 ? 1.5 : size <= 40 ? 1.75 : 2;
|
|
1475
|
+
// A point's ring, as a share of a line's weight, and how much ink its centre takes (as in rest.ts).
|
|
1476
|
+
const POINT_RING = 0.6;
|
|
1477
|
+
const POINT_CENTRE = 0.46;
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Props of {@link Icon}.
|
|
1481
|
+
*
|
|
1482
|
+
* @category Icons
|
|
1483
|
+
*/
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* Draws one of the app's icons: a sign on a 20 × 20 sheet, in two tones of the theme's ink.
|
|
1487
|
+
*
|
|
1488
|
+
* It is an inline `<svg>` that the stylesheet ({@link AppStyle}) inks: its lines are the theme's ink, what a sign
|
|
1489
|
+
* is done to is grey, and an axis is in its own colour. It is given the drawing's `name`, or a `url` that is a
|
|
1490
|
+
* reference ({@link iconRef}) or an image's url, which it shows as an `<img>`. A name that has no drawing shows a
|
|
1491
|
+
* dashed square. The drawings are {@link icons}. Its props: {@link IconProps}.
|
|
1492
|
+
*
|
|
1493
|
+
* @example
|
|
1494
|
+
* ```tsx
|
|
1495
|
+
* // on a page that only needs the icons: nothing but React
|
|
1496
|
+
* import { Icon, iconDataUrl, iconRef } from '@classcad/react-cad/icons'
|
|
1497
|
+
*
|
|
1498
|
+
* const ToolButton = ({ onClick }: { onClick: () => void }) => (
|
|
1499
|
+
* <button className="rcad-tool" onClick={onClick} title="Extrude">
|
|
1500
|
+
* <Icon name="extrusion" size={20} />
|
|
1501
|
+
* </button>
|
|
1502
|
+
* )
|
|
1503
|
+
* // a reference goes where an image's url went before; an image's url still shows as an <img>
|
|
1504
|
+
* const Fillet = () => <Icon url={iconRef('fillet')} size={16} title="Fillet" />
|
|
1505
|
+
* const Logo = () => <Icon url="/logo.svg" size={24} title="Our app" />
|
|
1506
|
+
* // where no stylesheet reaches: the same drawing in colours of its own
|
|
1507
|
+
* const Favicon = () => <link rel="icon" href={iconDataUrl('part', { ink: '#e7000b' }, 32)} />
|
|
1508
|
+
* ```
|
|
1509
|
+
*
|
|
1510
|
+
* @category Icons
|
|
1511
|
+
*/
|
|
1512
|
+
const Icon = /*#__PURE__*/React.memo(function Icon({
|
|
1513
|
+
name,
|
|
1514
|
+
url,
|
|
1515
|
+
size = 20,
|
|
1516
|
+
className,
|
|
1517
|
+
style,
|
|
1518
|
+
title,
|
|
1519
|
+
mono = false
|
|
1520
|
+
}) {
|
|
1521
|
+
const maskId = 'rcad-pts' + React.useId().replace(/[^\w-]/g, '');
|
|
1522
|
+
if (!name && url && !isIconRef(url)) {
|
|
1523
|
+
return /*#__PURE__*/React.createElement("img", {
|
|
1524
|
+
src: url,
|
|
1525
|
+
width: size,
|
|
1526
|
+
height: size,
|
|
1527
|
+
alt: title != null ? title : '',
|
|
1528
|
+
className: className,
|
|
1529
|
+
style: style,
|
|
1530
|
+
draggable: false
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
const key = name != null ? name : url ? url.slice(PREFIX.length) : 'missing';
|
|
1534
|
+
const layers = layersOf(drawingOf(key));
|
|
1535
|
+
const holes = holesOf(layers);
|
|
1536
|
+
const cut = holes ? `url(#${maskId})` : undefined;
|
|
1537
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
1538
|
+
className: ['rcad-icon', mono && 'rcad-mono', className].filter(Boolean).join(' '),
|
|
1539
|
+
viewBox: "0 0 20 20",
|
|
1540
|
+
width: size,
|
|
1541
|
+
height: size,
|
|
1542
|
+
style: _objectSpread({
|
|
1543
|
+
['--w']: weight(size) * 20 / size
|
|
1544
|
+
}, style),
|
|
1545
|
+
role: title ? 'img' : undefined,
|
|
1546
|
+
"aria-label": title,
|
|
1547
|
+
"aria-hidden": title ? undefined : true,
|
|
1548
|
+
focusable: "false"
|
|
1549
|
+
}, holes && /*#__PURE__*/React.createElement("mask", {
|
|
1550
|
+
id: maskId,
|
|
1551
|
+
maskUnits: "userSpaceOnUse",
|
|
1552
|
+
x: -5,
|
|
1553
|
+
y: -5,
|
|
1554
|
+
width: 30,
|
|
1555
|
+
height: 30
|
|
1556
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
1557
|
+
x: -5,
|
|
1558
|
+
y: -5,
|
|
1559
|
+
width: 30,
|
|
1560
|
+
height: 30,
|
|
1561
|
+
fill: "#fff",
|
|
1562
|
+
stroke: "none"
|
|
1563
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
1564
|
+
d: holes,
|
|
1565
|
+
fill: "#000",
|
|
1566
|
+
stroke: "none"
|
|
1567
|
+
})), layers.map(([pen, d], i) => {
|
|
1568
|
+
const mask = isPointPen(pen) ? undefined : cut;
|
|
1569
|
+
const {
|
|
1570
|
+
lines,
|
|
1571
|
+
solid
|
|
1572
|
+
} = partsOf(d);
|
|
1573
|
+
if (!solid) return /*#__PURE__*/React.createElement("path", {
|
|
1574
|
+
key: i,
|
|
1575
|
+
"data-t": pen || undefined,
|
|
1576
|
+
d: d,
|
|
1577
|
+
mask: mask
|
|
1578
|
+
});
|
|
1579
|
+
return /*#__PURE__*/React.createElement("g", {
|
|
1580
|
+
key: i,
|
|
1581
|
+
"data-t": pen || undefined,
|
|
1582
|
+
mask: mask
|
|
1583
|
+
}, lines && /*#__PURE__*/React.createElement("path", {
|
|
1584
|
+
d: lines
|
|
1585
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
1586
|
+
"data-solid": "",
|
|
1587
|
+
d: solid
|
|
1588
|
+
}));
|
|
1589
|
+
}));
|
|
1590
|
+
});
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* The colours an icon is drawn in, where no stylesheet gives them.
|
|
1594
|
+
*
|
|
1595
|
+
* @inline
|
|
1596
|
+
*/
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* An icon as a standalone svg, its colours written into it: for where no stylesheet reaches.
|
|
1600
|
+
*
|
|
1601
|
+
* That is a texture on the canvas, say, or an image's url ({@link iconDataUrl}). Its lines are weighed for the size it
|
|
1602
|
+
* is seen at, which a texture drawn large, to stay sharp, and shown small says apart from its size.
|
|
1603
|
+
*
|
|
1604
|
+
* @param name - The drawing's name, or its reference ({@link iconRef}).
|
|
1605
|
+
* @param inks - Its colours, such as `{ ink: '#0f1320' }`.
|
|
1606
|
+
* @param size - The svg's width and height in px. Default `20`.
|
|
1607
|
+
* @param seenAt - The size in px it is seen at, which its lines are weighed for. Default: `size`.
|
|
1608
|
+
* @returns The svg's markup.
|
|
1609
|
+
*
|
|
1610
|
+
* @example
|
|
1611
|
+
* ```tsx
|
|
1612
|
+
* import * as THREE from 'three'
|
|
1613
|
+
* import { getStage, iconSvg } from '@classcad/react-cad'
|
|
1614
|
+
*
|
|
1615
|
+
* // a sign as a texture on the stage: drawn at 96 px to stay sharp, its lines weighed for 16 px on screen
|
|
1616
|
+
* const stage = getStage()
|
|
1617
|
+
* const svg = iconSvg('workPlane', { ink: stage.datum }, 96, 16)
|
|
1618
|
+
* const texture = new THREE.TextureLoader().load('data:image/svg+xml;utf8,' + encodeURIComponent(svg))
|
|
1619
|
+
* const material = new THREE.SpriteMaterial({ map: texture, transparent: true })
|
|
1620
|
+
* ```
|
|
1621
|
+
*
|
|
1622
|
+
* @advanced
|
|
1623
|
+
* @category Icons
|
|
1624
|
+
*/
|
|
1625
|
+
function iconSvg(name, inks, size = 20, seenAt = size) {
|
|
1626
|
+
var _inks$x, _inks$y, _inks$z;
|
|
1627
|
+
const key = isIconRef(name) ? name.slice(PREFIX.length) : name;
|
|
1628
|
+
const w = weight(seenAt) * 20 / seenAt;
|
|
1629
|
+
const [x, y, z] = inks.mono ? [inks.ink, inks.ink, inks.ink] : [(_inks$x = inks.x) != null ? _inks$x : inks.ink, (_inks$y = inks.y) != null ? _inks$y : inks.ink, (_inks$z = inks.z) != null ? _inks$z : inks.ink];
|
|
1630
|
+
const grey = inks.mono ? undefined : 0.46;
|
|
1631
|
+
const DASH = '2.1 2.1';
|
|
1632
|
+
const pens = {
|
|
1633
|
+
'': {
|
|
1634
|
+
color: inks.ink
|
|
1635
|
+
},
|
|
1636
|
+
sub: {
|
|
1637
|
+
color: inks.ink,
|
|
1638
|
+
alpha: grey
|
|
1639
|
+
},
|
|
1640
|
+
dash: {
|
|
1641
|
+
color: inks.ink,
|
|
1642
|
+
dash: DASH
|
|
1643
|
+
},
|
|
1644
|
+
'sub-dash': {
|
|
1645
|
+
color: inks.ink,
|
|
1646
|
+
alpha: grey,
|
|
1647
|
+
dash: DASH
|
|
1648
|
+
},
|
|
1649
|
+
axis: {
|
|
1650
|
+
color: inks.ink,
|
|
1651
|
+
alpha: grey,
|
|
1652
|
+
dash: '3.4 1.7 0.5 1.7'
|
|
1653
|
+
},
|
|
1654
|
+
fill: {
|
|
1655
|
+
color: inks.ink,
|
|
1656
|
+
filled: true
|
|
1657
|
+
},
|
|
1658
|
+
'sub-fill': {
|
|
1659
|
+
color: inks.ink,
|
|
1660
|
+
alpha: grey,
|
|
1661
|
+
filled: true
|
|
1662
|
+
},
|
|
1663
|
+
point: {
|
|
1664
|
+
color: inks.ink,
|
|
1665
|
+
point: true
|
|
1666
|
+
},
|
|
1667
|
+
'sub-point': {
|
|
1668
|
+
color: inks.ink,
|
|
1669
|
+
alpha: grey,
|
|
1670
|
+
point: true
|
|
1671
|
+
},
|
|
1672
|
+
tone: {
|
|
1673
|
+
color: inks.ink,
|
|
1674
|
+
alpha: 0.14,
|
|
1675
|
+
filled: true
|
|
1676
|
+
},
|
|
1677
|
+
x: {
|
|
1678
|
+
color: x
|
|
1679
|
+
},
|
|
1680
|
+
y: {
|
|
1681
|
+
color: y
|
|
1682
|
+
},
|
|
1683
|
+
z: {
|
|
1684
|
+
color: z
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
const layers = layersOf(drawingOf(key));
|
|
1688
|
+
const holes = holesOf(layers);
|
|
1689
|
+
const cut = holes ? ' mask="url(#h)"' : '';
|
|
1690
|
+
const mask = holes ? '<mask id="h" maskUnits="userSpaceOnUse" x="-5" y="-5" width="30" height="30">' + `<rect x="-5" y="-5" width="30" height="30" fill="#fff"/><path fill="#000" d="${holes}"/></mask>` : '';
|
|
1691
|
+
const paths = layers.map(([pen, d]) => {
|
|
1692
|
+
const {
|
|
1693
|
+
color,
|
|
1694
|
+
alpha,
|
|
1695
|
+
dash,
|
|
1696
|
+
filled,
|
|
1697
|
+
point
|
|
1698
|
+
} = pens[pen];
|
|
1699
|
+
const faint = alpha ? ` opacity="${alpha}"` : '';
|
|
1700
|
+
if (point) {
|
|
1701
|
+
const ring = `stroke="${color}" stroke-width="${(w * POINT_RING).toFixed(3)}"`;
|
|
1702
|
+
return `<path fill="${color}" fill-opacity="${POINT_CENTRE}" ${ring}${faint} d="${d}"/>`;
|
|
1703
|
+
}
|
|
1704
|
+
if (filled) return `<path fill="${color}"${faint}${cut} d="${d}"/>`;
|
|
1705
|
+
const {
|
|
1706
|
+
lines,
|
|
1707
|
+
solid
|
|
1708
|
+
} = partsOf(d);
|
|
1709
|
+
const drawn = `stroke="${color}" stroke-width="${w.toFixed(3)}" stroke-linejoin="round"`;
|
|
1710
|
+
const ends = dash ? ` stroke-linecap="butt" stroke-dasharray="${dash}"` : ' stroke-linecap="round"';
|
|
1711
|
+
const line = lines ? `<path fill="none" ${drawn}${ends} d="${lines}"/>` : '';
|
|
1712
|
+
const body = solid ? `<path fill="${color}" ${drawn} d="${solid}"/>` : '';
|
|
1713
|
+
return `<g${faint}${cut}>${line}${body}</g>`;
|
|
1714
|
+
}).join('');
|
|
1715
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="${size}" height="${size}">${mask}${paths}</svg>`;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
/**
|
|
1719
|
+
* An icon as a `data:` url of its svg ({@link iconSvg}): for an `<img>`, a CSS background or a texture's loader.
|
|
1720
|
+
*
|
|
1721
|
+
* @param name - The drawing's name, or its reference ({@link iconRef}).
|
|
1722
|
+
* @param inks - Its colours, such as `{ ink: '#0f1320' }`.
|
|
1723
|
+
* @param size - The svg's width and height in px. Default `20`.
|
|
1724
|
+
* @param seenAt - The size in px it is seen at, which its lines are weighed for. Default: `size`.
|
|
1725
|
+
*
|
|
1726
|
+
* @example
|
|
1727
|
+
* ```tsx
|
|
1728
|
+
* import { iconDataUrl, useRCadTheme } from '@classcad/react-cad'
|
|
1729
|
+
*
|
|
1730
|
+
* // an icon as an <img>, in the theme's colours: the axes in their own
|
|
1731
|
+
* function AxisBadge() {
|
|
1732
|
+
* const colors = useRCadTheme()
|
|
1733
|
+
* const src = iconDataUrl('rotation3d', { ink: colors.ink, x: colors.axisX, y: colors.axisY, z: colors.axisZ }, 24)
|
|
1734
|
+
* return <img src={src} width={24} height={24} alt="Rotation" />
|
|
1735
|
+
* }
|
|
1736
|
+
* ```
|
|
1737
|
+
*
|
|
1738
|
+
* @category Icons
|
|
1739
|
+
*/
|
|
1740
|
+
const iconDataUrl = (name, inks, size = 20, seenAt = size) => 'data:image/svg+xml;utf8,' + encodeURIComponent(iconSvg(name, inks, size, seenAt));
|
|
1741
|
+
|
|
1742
|
+
export { Icon, drawings, iconDataUrl, iconRef, iconSvg, isIconRef };
|