$$include '../../meta/macros.ptl'

import [mix linreg clamp fallback] from "@iosevka/util"
import [Box] from "@iosevka/geometry/box"
import [Transform] from "@iosevka/geometry/transform"

glyph-module

glyph-block Symbol-Pictograph-Game-Sprite : for-width-kinds WideWidth4
	glyph-block-import CommonShapes
	glyph-block-import Common-Derivatives
	glyph-block-import Shared-Symbol-Shapes : TriangleShape
	glyph-block-import Symbol-Pictograph-Stick-Figure : StickFigureKit WithD4Transform D4Transform
	glyph-block-import Symbol-Geometric-Shared : GeometricDim

	define top     fontMetrics.os2.sTypoAscender
	define bottom  fontMetrics.os2.sTypoDescender
	define left    0
	define right   MosaicWidth

	define midX : mix left right 0.5
	define midY : mix top bottom 0.5

	define uiTop : mix ParenBot ParenTop 0.95
	define uiBot : mix ParenBot ParenTop 0.05
	define uiLeft  : left + SB
	define uiRight : right - SB

	define Geom : GeometricDim MosaicUnitWidth MosaicWidth
	define graphicSw : AdviceStroke 3.5
	define smallGraphicSw : AdviceStroke 3.5 : Math.sqrt (MosaicWidthScalar / 2)
	define heavyGraphicSw : Math.max (graphicSw * 2) (Width * 0.15)

	define squareBox : new Box Geom.Top Geom.Bot Geom.Left Geom.Right
	define [SidewaysBox box _left2 _right2] : begin
		local left2  : fallback _left2  box.left
		local right2 : fallback _right2 box.right
		local newHeight : (box.right - box.left) * (right2 - left2) / (box.top - box.bottom)
		local midX : mix left2 right2 0.5
		local midY box.yMid

		return : new Box
			midY + (right2 - midX)
			midY + (left2  - midX)
			midX - newHeight / 2
			midX + newHeight / 2

	define uiBox : new Box uiTop uiBot uiLeft uiRight
	define uiHBox : SidewaysBox uiBox

	define sb : SB * (0.5 * MosaicWidthScalar)
	define smallHBox : new Box
		mix SymbolMid PlusTop (0.5 * MosaicWidthScalar)
		mix SymbolMid PlusBot (0.5 * MosaicWidthScalar)
		* sb
		MosaicWidth - sb

	define vScalar : Math.sqrt (2 * MosaicWidthScalar)
	define smallVBox : new Box
		mix SymbolMid PlusTop (0.5 * vScalar)
		mix SymbolMid PlusBot (0.5 * vScalar)
		sb + 0.5 * (MosaicWidth - Width * vScalar)
		(Width * vScalar - sb) + 0.5 * (MosaicWidth - Width * vScalar)


	do "Top-down Vehicles"
		define scaffold : object
		set scaffold.xWheelFront : 1.5 / 9
		set scaffold.xWheel      : 1 / 9
		set scaffold.xWheelRear  : 0.5 / 9
		set scaffold.wheelDiam   : 3 / 9
		set scaffold.yAxle  : scaffold.wheelDiam / 2

		define [Car box fJut fWindow fSymmetric rot bodyWidth _sw] : glyph-proc
			local yBody : if fJut 0 scaffold.yAxle
			local xFront : if fSymmetric scaffold.xWheel scaffold.xWheelFront
			local xRear  : if fSymmetric scaffold.xWheel scaffold.xWheelRear

			local sw : fallback _sw smallGraphicSw
			local tfm : D4Transform midX rot 0
			local Kit : StickFigureKit box tfm sw
			local Kit2 : if [not fSymmetric] Kit : StickFigureKit box tfm (sw * 2)

			local shape : union
				Kit2.RoundSeg xFront 1 xFront (1 - scaffold.wheelDiam)
				Kit.RoundSeg xFront (1 - scaffold.yAxle) (1 - xFront) (1 - scaffold.yAxle)
				Kit2.RoundSeg (1 - xFront) 1 (1 - xFront) (1 - scaffold.wheelDiam)
				Kit2.RoundSeg xRear scaffold.wheelDiam xRear 0
				Kit.RoundSeg xRear (scaffold.yAxle) (1 - xRear) (scaffold.yAxle)
				Kit2.RoundSeg (1 - xRear) scaffold.wheelDiam (1 - xRear) 0
				if (bodyWidth <= 0)
					Kit.RoundSeg (1 / 2) (1 - yBody) (1 / 2) (yBody)
					Kit.Box (1 / 2 - bodyWidth / 2) (1 - yBody) (1 / 2 + bodyWidth / 2) (yBody)

			if fWindow
				include : difference shape
					Kit.Box (1 / 2 - bodyWidth / 6) (1 - yBody - 1 / 9) (1 / 2 + bodyWidth / 6) (1 - yBody - 3 / 9)
				include shape

		create-glyph [MangleName 'goKartUp']     [MangleUnicode 0x1CC00] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 0 0 0 0 0
		create-glyph [MangleName 'goKartRight']  [MangleUnicode 0x1CC01] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 0 0 0 3 0
		create-glyph [MangleName 'raceCarLeft']  [MangleUnicode 0x1CC97] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 1 1 1 1 (3 / 9)
		create-glyph [MangleName 'raceCarUp']    [MangleUnicode 0x1CC98] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 1 1 1 0 (3 / 9)
		create-glyph [MangleName 'raceCarRight'] [MangleUnicode 0x1CC99] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 1 1 1 3 (3 / 9)
		create-glyph [MangleName 'raceCarDown']  [MangleUnicode 0x1CC9A] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 1 1 1 2 (3 / 9)
		create-glyph [MangleName 'raceCarHori']  [MangleUnicode 0x1CC9B] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 1 0 1 1 (3 / 9)
		create-glyph [MangleName 'raceCarVert']  [MangleUnicode 0x1CC9C] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 1 0 1 0 (3 / 9)
		create-glyph [MangleName 'goKartVert']   [MangleUnicode 0x1CC9D] : glyph-proc
			set-width MosaicWidth
			include : Car squareBox 0 0 1 0 (3 / 9)


	do "Stick Man"
		define [StickManScaffold box _sw] : begin
			local baseHeight : uiTop - uiBot
			local height : box.top - box.bottom
			local scale : height / baseHeight

			local scaffold : object
				top box.top
				bot box.bottom
				left box.left
				right box.right
				stroke : fallback _sw graphicSw
				xMiddle box.xMid
				yMiddle box.yMid
				armRaiseK 0.4
				headSize : height / 2.5
				legSize  : (Width - SB * 2) * scale
				armSize  : (Width - SB) * scale

			set scaffold.yPelvis    : scaffold.bot + scaffold.legSize / 2
			set scaffold.xLeftFoot  : scaffold.xMiddle - scaffold.legSize / 2
			set scaffold.xRightFoot : scaffold.xMiddle + scaffold.legSize / 2
			set scaffold.yNeck      : scaffold.top - scaffold.headSize
			set scaffold.xLeftHead  : scaffold.xMiddle - scaffold.headSize / 2
			set scaffold.xRightHead : scaffold.xMiddle + scaffold.headSize / 2
			set scaffold.xLeftArm   : scaffold.xMiddle - scaffold.armSize / 2
			set scaffold.xRightArm  : scaffold.xMiddle + scaffold.armSize / 2
			set scaffold.yShoulder : lambda [p] : mix scaffold.yPelvis scaffold.yNeck p

			return scaffold

		define [StickManHead scaffold] : OShape (scaffold.top - O) (scaffold.yNeck + O) (scaffold.xLeftHead + O) (scaffold.xRightHead - O) scaffold.stroke
		define [StickManArms scaffold p kl kr] : union
			dispiro
				widths.center scaffold.stroke
				corner scaffold.xMiddle [scaffold.yShoulder p]
				corner scaffold.xLeftArm ([scaffold.yShoulder p] + scaffold.armSize / 2 * kl)
			dispiro
				widths.center scaffold.stroke
				corner scaffold.xMiddle [scaffold.yShoulder p]
				corner scaffold.xRightArm ([scaffold.yShoulder p] + scaffold.armSize / 2 * kr)
		define [StickManBody scaffold kl kr] : glyph-proc
			include : StickManHead scaffold
			include : VBar.m scaffold.xMiddle scaffold.yPelvis scaffold.yNeck scaffold.stroke
			include : dispiro
				widths.center scaffold.stroke
				corner scaffold.xMiddle scaffold.yPelvis
				corner scaffold.xLeftFoot scaffold.bot
			include : dispiro
				widths.center scaffold.stroke
				corner scaffold.xMiddle scaffold.yPelvis
				corner scaffold.xRightFoot scaffold.bot
			include : StickManArms scaffold 0.6 kl kr
		define [StickManDressBody scaffold kl kr] : glyph-proc
			include : StickManHead scaffold
			define p 0.7
			define dressBottom : [mix scaffold.bot scaffold.yNeck 0.25] - scaffold.stroke / 2
			define dressLeft : scaffold.xLeftFoot - scaffold.stroke / 2
			define dressRight : scaffold.xRightFoot + scaffold.stroke / 2
			include : StickManArms scaffold p kl kr
			include : VBar.m scaffold.xMiddle [scaffold.yShoulder p] scaffold.yNeck
			include : TriangleShape scaffold.xMiddle ([scaffold.yShoulder p] + scaffold.stroke) dressRight dressBottom dressLeft dressBottom scaffold.stroke
			include : VBar.m [mix dressLeft dressRight 0.3] scaffold.bot (dressBottom - O) scaffold.stroke
			include : VBar.m [mix dressLeft dressRight 0.7] scaffold.bot (dressBottom - O) scaffold.stroke


		define scaffold : StickManScaffold uiBox
		define hScaffold : StickManScaffold uiHBox smallGraphicSw

		create-glyph [MangleName 'stickMan'] [MangleUnicode 0x1FBC5] : glyph-proc
			set-width MosaicWidth
			include : StickManBody scaffold 0 0
		create-glyph [MangleName 'stickManLeft'] [MangleUnicode 0x1CC02] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 1 0 : lambda [] : StickManBody hScaffold 0 0
		create-glyph [MangleName 'stickManRight'] [MangleUnicode 0x1CC03] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 3 0 : lambda [] : StickManBody hScaffold 0 0
		create-glyph [MangleName 'stickManDown'] [MangleUnicode 0x1CC04] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 2 0 : lambda [] : StickManBody scaffold 0 0
		create-glyph [MangleName 'stickManArmsRaised'] [MangleUnicode 0x1FBC6] : glyph-proc
			set-width MosaicWidth
			include : StickManBody scaffold scaffold.armRaiseK scaffold.armRaiseK
		create-glyph [MangleName 'stickManLeaningLeft'] [MangleUnicode 0x1FBC7] : glyph-proc
			set-width MosaicWidth
			include : StickManBody scaffold (-scaffold.armRaiseK) scaffold.armRaiseK
		create-glyph [MangleName 'stickManLeaningRight'] [MangleUnicode 0x1FBC8] : glyph-proc
			set-width MosaicWidth
			include : StickManBody scaffold scaffold.armRaiseK (-scaffold.armRaiseK)
		create-glyph [MangleName 'stickManWithDress'] [MangleUnicode 0x1FBC9] : glyph-proc
			set-width MosaicWidth
			include : StickManDressBody scaffold 0 0


	do "Snake Head"
		define eyeSize : Geom.Size / 8
		define mouthWidth : Geom.Size / 3
		define eyeOffset mouthWidth

		define [SnakeHead facing fMouth] : glyph-proc
			set-width MosaicWidth
			include : ForceUpright

			local eyeX : match facing
				0 : midX + eyeSize
				1 : midX - eyeSize - eyeOffset
				2 : midX - eyeSize
				3 : midX + eyeSize + eyeOffset
			local eyeY : match facing
				0 : midY + eyeSize + eyeOffset
				1 : midY + eyeSize
				2 : midY + eyeSize + eyeOffset
				3 : midY - eyeSize

			include : difference
				union
					refer-glyph : MangleName : match facing
						0 'uni2578'
						1 'uni257B'
						2 'uni257A'
						3 'uni2579'
					refer-glyph : MangleName 'blackCircle'
				DotAt eyeX eyeY eyeSize
				if fMouth
					spiro-outline
						corner midX midY
						match facing
							0 : corner Geom.Right (midY - mouthWidth)
							1 : corner (midX + mouthWidth) Geom.Top
							2 : corner Geom.Left (midY + mouthWidth)
							3 : corner (midX - mouthWidth) Geom.Bot
						match facing
							0 : corner Geom.Right (midY + mouthWidth)
							1 : corner (midX - mouthWidth) Geom.Top
							2 : corner Geom.Left (midY - mouthWidth)
							3 : corner (midX + mouthWidth) Geom.Bot
					glyph-proc

		create-glyph [MangleName "snakeHeadLeftOpen"] [MangleUnicode 0x1CC70] : glyph-proc
			include : SnakeHead 2 1
		create-glyph [MangleName "snakeHeadUpOpen"] [MangleUnicode 0x1CC71] : glyph-proc
			include : SnakeHead 1 1
		create-glyph [MangleName "snakeHeadRightOpen"] [MangleUnicode 0x1CC72] : glyph-proc
			include : SnakeHead 0 1
		create-glyph [MangleName "snakeHeadDownOpen"] [MangleUnicode 0x1CC73] : glyph-proc
			include : SnakeHead 3 1
		create-glyph [MangleName "snakeHeadLeftClosed"] [MangleUnicode 0x1CC74] : glyph-proc
			include : SnakeHead 2 0
		create-glyph [MangleName "snakeHeadUpClosed"] [MangleUnicode 0x1CC75] : glyph-proc
			include : SnakeHead 1 0
		create-glyph [MangleName "snakeHeadRightClosed"] [MangleUnicode 0x1CC76] : glyph-proc
			include : SnakeHead 0 0
		create-glyph [MangleName "snakeHeadDownClosed"] [MangleUnicode 0x1CC77] : glyph-proc
			include : SnakeHead 3 0


	do "Energy Waves"
		define [LeftEnergyWave top bottom left right] : glyph-proc
			local midX : mix left right 0.5
			local midY : mix top bottom 0.5

			include : difference
				spiro-outline
					corner right top
					corner (midX + TINY) top
					flat midX top
					archv.superness 2
					g4 left midY
					arcvh.superness 2
					curl midX bottom
					corner (midX + TINY) bottom
					corner right bottom
				spiro-outline
					corner right [mix top bottom 0.1]
					flat [mix left right 0.9] [mix top bottom 0.1]
					archv.superness 2
					g4 midX midY
					arcvh.superness 2
					curl [mix left right 0.9] [mix top bottom 0.9]
					corner right [mix top bottom 0.9]

		create-glyph [MangleName "energyWaveLeft"] [MangleUnicode 0x1CC78] : glyph-proc
			set-width MosaicWidth
			include : LeftEnergyWave Geom.Top Geom.Bot Geom.Left Geom.Right
		create-glyph [MangleName "energyWaveUp"] [MangleUnicode 0x1CC79] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 3 0 : lambda [] : LeftEnergyWave Geom.Top Geom.Bot Geom.Left Geom.Right
		create-glyph [MangleName "energyWaveRight"] [MangleUnicode 0x1CC7A] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 2 0 : lambda [] : LeftEnergyWave Geom.Top Geom.Bot Geom.Left Geom.Right
		create-glyph [MangleName "energyWaveDown"] [MangleUnicode 0x1CC7B] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 1 0 : lambda [] : LeftEnergyWave Geom.Top Geom.Bot Geom.Left Geom.Right


	do "Rifle"
		define scaffold : object
		set scaffold.postLength : 1 / 6
		set scaffold.postOffset : 1 / 9
		set scaffold.triggerRad : 1 / 8

		define [RightRifle box] : glyph-proc
			include : union
				HBar.t box.left box.right [box.mixY : 1 - scaffold.postLength] smallGraphicSw
				VBar.r [box.mixX : 1 - scaffold.postOffset] [box.mixY : 1 - scaffold.postLength] box.top smallGraphicSw
				VBar.l box.left box.bottom [box.mixY : 1 - scaffold.postLength] (2 * smallGraphicSw)

			local triggerStartX : box.left + [HSwToV : 2 * smallGraphicSw]
			local triggerEndY : [box.mixY : 1 - scaffold.postLength] - smallGraphicSw
			local triggerRad : (box.right - box.left) * scaffold.triggerRad
			include : dispiro
				widths.center smallGraphicSw
				flat triggerStartX (triggerEndY - triggerRad) [heading Rightward]
				archv
				curl (triggerStartX + triggerRad) triggerEndY [heading Upward]

		create-glyph [MangleName 'rifleLeft'] [MangleUnicode 0x1CC65] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 0 1 : lambda [] : RightRifle smallHBox
		create-glyph [MangleName 'rifleUp'] [MangleUnicode 0x1CC66] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 1 0 : lambda [] : RightRifle smallVBox
		create-glyph [MangleName 'rifleRight'] [MangleUnicode 0x1CC67] : glyph-proc
			set-width MosaicWidth
			include : RightRifle smallHBox
		create-glyph [MangleName 'rifleDown'] [MangleUnicode 0x1CC68] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 3 0 : lambda [] : RightRifle smallVBox


	do "Rocket"
		define scaffold : object
		set scaffold.width : 1 / 2
		set scaffold.baseHeight : 1 / 4
		set scaffold.tipHeight : 1 / 4

		define [RightRocket box] : glyph-proc
			local rocketLeft  : box.mixY (0.5 + scaffold.width / 2)
			local rocketRight : box.mixY (0.5 - scaffold.width / 2)
			local rocketBase : box.mixX scaffold.baseHeight
			local rocketTip  : box.mixX (1 - scaffold.tipHeight)

			include : union
				spiro-outline
					corner box.left   box.yMid
					corner rocketBase rocketRight
					corner rocketTip  rocketRight
					corner box.right  box.yMid
					corner rocketTip  rocketLeft
					corner rocketBase rocketLeft
				intersection [MaskAbove box.yMid] : dispiro
					widths.center smallGraphicSw
					corner box.left box.top
					corner [box.mixX : 2 * scaffold.baseHeight] [box.mixY scaffold.width]
				intersection [MaskBelow box.yMid] : dispiro
					widths.center smallGraphicSw
					corner box.left box.bottom
					corner [box.mixX : 2 * scaffold.baseHeight] [box.mixY : 1 - scaffold.width]

		create-glyph [MangleName 'rocketLeft'] [MangleUnicode 0x1CC56] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 0 1 : lambda [] : RightRocket smallHBox
		create-glyph [MangleName 'rocketUp'] [MangleUnicode 0x1CC57] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 1 0 : lambda [] : RightRocket smallVBox
		create-glyph [MangleName 'rocketRight'] [MangleUnicode 0x1CC58] : glyph-proc
			set-width MosaicWidth
			include : RightRocket smallHBox
		create-glyph [MangleName 'rocketDown'] [MangleUnicode 0x1CC59] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 3 0 : lambda [] : RightRocket smallVBox


	do "Bomb"
		define scaffold : object
		set scaffold.tailX 0.3
		set scaffold.bodyX 0.15

		define [RightBomb box] : glyph-proc
			local bombLeft : box.mixX scaffold.bodyX
			local radius : (box.top - box.bottom) / 2

			include : union
				spiro-outline
					corner box.left box.top
					corner box.left box.bottom
					corner (box.left + graphicSw) box.bottom
					corner [box.mixX scaffold.tailX] box.yMid
					corner (box.left + graphicSw) box.top
				spiro-outline
					curl (bombLeft + radius)  box.top
					archv
					g4 bombLeft box.yMid
					arcvh
					flat (bombLeft + radius)  box.bottom
					curl (box.right - radius) box.bottom
					archv
					g4 box.right box.yMid
					arcvh
					flat (box.right - radius) box.top
				# Ellipse.Outline.AtDimens box.top box.bottom [box.mixX scaffold.bodyX] box.right

		create-glyph [MangleName 'bombLeft'] [MangleUnicode 0x1CC60] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 2 0 : lambda [] : RightBomb smallHBox
		create-glyph [MangleName 'bombUp'] [MangleUnicode 0x1CC61] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 1 0 : lambda [] : RightBomb smallVBox
		create-glyph [MangleName 'bombRight'] [MangleUnicode 0x1CC62] : glyph-proc
			set-width MosaicWidth
			include : RightBomb smallHBox
		create-glyph [MangleName 'bombDown'] [MangleUnicode 0x1CC63] : glyph-proc
			set-width MosaicWidth
			include : WithD4Transform midX 3 0 : lambda [] : RightBomb smallVBox


	do "Frog"
		define scaffold : object
		set scaffold.bodyX  1
		set scaffold.bodyY  0.9
		set scaffold.legY   0.7
		set scaffold.legY2  0.6
		set scaffold.legX   0.2
		set scaffold.legX2  0.4
		set scaffold.sw graphicSw

		define [UpFrog box tfm] : glyph-proc
			local Kit : StickFigureKit box tfm heavyGraphicSw

			include : difference
				union
					Ellipse.Outline.AtDimens
						box.mixY scaffold.bodyY
						box.mixY (1 - scaffold.bodyY)
						box.mixX (1 - scaffold.bodyX)
						box.mixX scaffold.bodyX
					Kit.RoundSeg 0.5 0.5 0.5 1 0 1
					Kit.RoundSeg 0.5 scaffold.legY2 0 scaffold.legY 0 1
					Kit.RoundSeg 0.5 scaffold.legY2 1 scaffold.legY 0 1
					Kit.RoundSeg      scaffold.legX2  0.5      scaffold.legX  0 0 1
					Kit.RoundSeg (1 - scaffold.legX2) 0.5 (1 - scaffold.legX) 0 0 1
				Ellipse.Outline.AtDimens
					[box.mixY scaffold.bodyY] - scaffold.sw
					[box.mixY : 1 - scaffold.bodyY] + scaffold.sw
					[box.mixX : 1 - scaffold.bodyX] + scaffold.sw
					[box.mixX scaffold.bodyX] - scaffold.sw

		create-glyph [MangleName 'frogUp'] [MangleUnicode 0x1CDFB] : glyph-proc
			set-width MosaicWidth
			include : UpFrog squareBox : D4Transform midX 0 0
		create-glyph [MangleName 'frogDown'] [MangleUnicode 0x1CDFC] : glyph-proc
			set-width MosaicWidth
			include : UpFrog squareBox : D4Transform midX 2 0


	do "Moon Lander"
		define scaffold : object
		set scaffold.tipSize     0.2
		set scaffold.headWidth   0.8
		set scaffold.headHeight  (3 / 8)
		set scaffold.bodyWidth   0.4
		set scaffold.slantHeight (3 / 8)
		set scaffold.baseWidth   0.2
		set scaffold.windowWidth     0.2
		set scaffold.windowTopWidth  0.12
		set scaffold.windowArchDepth 0.1
		set scaffold.windowBot       (3 / 8)
		set scaffold.windowTop       (6 / 8)
		set scaffold.footLen      0.25
		set scaffold.legHeight    0.4
		set scaffold.legTopHeight 0.5

		define [Moonlander top bottom left right sw] : glyph-proc
			local midX : mix left right 0.5
			local y1 : mix top bottom scaffold.headHeight
			local y2 : mix bottom top scaffold.slantHeight
			local bodyLeft  : mix left right (0.5 - scaffold.bodyWidth / 2)
			local bodyRight : mix left right (0.5 + scaffold.bodyWidth / 2)

			local windowTop : mix bottom top scaffold.windowTop
			local windowBot : mix bottom top scaffold.windowBot
			local windowY3  : mix bottom top (scaffold.windowTop - scaffold.windowArchDepth)
			local windowLeft  : mix left right (0.5 - scaffold.windowWidth / 2)
			local windowRight : mix left right (0.5 + scaffold.windowWidth / 2)

			local legY2 : mix bottom top scaffold.legHeight
			local legY3 : mix bottom top scaffold.legTopHeight
			include : difference
				union
					spiro-outline
						corner [mix left right (0.5 + scaffold.headWidth / 2)] y1
						corner [mix left right (0.5 + scaffold.tipSize / 2)] top
						corner [mix left right (0.5 - scaffold.tipSize / 2)] top
						corner [mix left right (0.5 - scaffold.headWidth / 2)] y1
						corner bodyLeft y1
						corner bodyLeft y2
						corner [mix left right (0.5 - scaffold.baseWidth / 2)] bottom
						corner [mix left right (0.5 + scaffold.baseWidth / 2)] bottom
						corner bodyRight y2
						corner bodyRight y1
					HBar.b left  [mix left right scaffold.footLen] bottom sw
					HBar.b right [mix right left scaffold.footLen] bottom sw
					VBar.l left  bottom legY2 sw
					VBar.r right bottom legY2 sw
					dispiro [widths.rhs sw] [flat left  legY2] [curl midX legY3]
					dispiro [widths.lhs sw] [flat right legY2] [curl midX legY3]
				spiro-outline
					corner windowLeft windowY3
					corner windowLeft windowBot
					corner windowRight windowBot
					corner windowRight windowY3
					corner [mix left right (0.5 + scaffold.windowTopWidth / 2)] windowTop
					corner [mix left right (0.5 - scaffold.windowTopWidth / 2)] windowTop

		create-glyph [MangleName "moonLander"] [MangleUnicode 0x1CDF5] : glyph-proc
			set-width MosaicWidth
			include : Moonlander top bottom left right graphicSw
