Loading files
ded5ca94eThis file is pinned to the selected release. Download the original to open it in your design tool.
Files from this revision, including CAD and LFS contents. Git history is not included.
Or in GitHub Desktop, choose File → Clone repository → URL and paste this address.
Public repositories can be cloned without signing in. For pushing, use your ThingAtlas username and a Git access token as the password.
git lfs install git clone https://thingatlas.com/git/-unclaimed/stack-chan-374381865.git
Includes Git history, branches, and Git LFS files. Clones the repository’s default branch, regardless of the version shown here.
ded5ca94eThis file is pinned to the selected release. Download the original to open it in your design tool.
import type { FaceContext } from 'face-context'
import { type Skin as PiuSkin, Skin } from 'piu/MC'
export type FaceSkinPalette = {
primary: PiuSkin
secondary: PiuSkin
mixed: PiuSkin
palette: PiuSkin
primaryState: number
secondaryState: number
primaryColor: string
secondaryColor: string
}
export function createFaceSkinPalette(primary: string, secondary: string): FaceSkinPalette {
return {
primary: new Skin({ fill: primary, stroke: primary }),
secondary: new Skin({ fill: secondary, stroke: secondary }),
mixed: new Skin({ fill: secondary, stroke: primary }),
palette: new Skin({ fill: [secondary, primary], stroke: [secondary, primary] }),
primaryState: 1,
secondaryState: 0,
primaryColor: primary,
secondaryColor: secondary,
}
}
export function updateFaceSkinPalette(prev: FaceSkinPalette | null, face: Readonly<FaceContext>): FaceSkinPalette {
const primary = face.theme.primary
const secondary = face.theme.secondary
if (prev && prev.primaryColor === primary && prev.secondaryColor === secondary) return prev
return createFaceSkinPalette(primary, secondary)
}