Bookmark this: tool.io/anatomy/source-code
Human Anatomy Diagram Source Code
Browse the implementation files for Human Anatomy Diagram.tool.ts typescript
import Anatomy from './Anatomy.svelte';
import { anatomyBodyMap } from '$lib/components/anatomy/body-map';
const anatomyRegionOptions = anatomyBodyMap.layers
.map(({ id, label, role }) => ({
group: role.charAt(0).toUpperCase() + role.slice(1),
text: `${label} (${id})`,
value: id
}))
.sort((first, second) =>
first.text.localeCompare(second.text, 'en-US')
);
export const anatomy = (
preset: unknown,
selected: unknown
): { preset: string; selected: string[] } => ({
preset:
typeof preset === 'string' && preset.trim() !== ''
? preset
: 'human-front',
selected: Array.isArray(selected)
? selected.filter(
(item): item is string =>
typeof item === 'string' && item.trim() !== ''
)
: typeof selected === 'string'
? selected
.split(',')
.map((item) => item.trim())
.filter(Boolean)
: []
});
export const Tool: TypeTool = {
i: [
{
id: 'preset',
label: 'View',
options: [
{ text: 'Human body', value: 'human-front' },
{ text: 'BMI measurements', value: 'body-mass-index' }
],
placeholder: 'Choose an anatomy view',
type: 'select',
value: 'human-front'
},
{
id: 'selected',
label: 'Highlighted anatomy regions',
multiple: true,
options: anatomyRegionOptions,
placeholder: 'Choose anatomy regions',
type: 'select',
value: [],
valueType: {
format: 'anatomy-region-ids',
items: { type: 'string' },
type: 'list'
}
}
],
intro:
'Explore a reusable, source-attributed human anatomy diagram.',
name: 'Human Anatomy Diagram',
o: [
{
id: 'diagram',
label: 'Anatomy diagram',
placeholder: 'Human anatomy diagram',
render: 'custom',
renderas: Anatomy,
type: 'object',
valueType: {
format: 'anatomy-diagram',
type: 'object'
}
}
],
slug: 'anatomy',
tool: anatomy
};
export default Tool;
Description
Browse the implementation files for Human Anatomy Diagram.