garment_fit_view 
One view of a garment being fitted: its frame, the pixels read from it, and the pixels the fitting writes over them.
Pixels are addressed as the templates give them, from the top left from 0. A pixel is a colour as GetPixel() returns it ("#rrggbb", or "#rrggbbaa" when partly transparent), or 0 where it's clear.
Vars | |
| colour_counts | Colour (without alpha) -> how many of the view's pixels have it. Counted when a ramp first needs every colour (ramp()), and kept up to date from then on. |
|---|---|
| frame | One direction of the garment's state, which the fitted pixels are drawn on. |
| frame_colours | The frame's own colour counts, known without reading its pixels (garment_sheet_metadata()), or null. |
| original | The frame's own pixels, by FIT_INDEX(), wherever read: what the fitted pixels are compared with to draw them. |
| pending | While a pass runs (begin_pass()), its writes as x, y, pixel triples, made as it ends: a pass reads the view as it began. |
| pixels | The view's pixels as the fitting has them so far, by FIT_INDEX(): a pixel, or null where the frame isn't read yet. |
| sizes | Template limb -> its muscle size, as /datum/garment_fit has them. |
| view | The view's key in the templates: "S", "N", "E" or "W". |
| written_indexes | The FIT_INDEX() of each pixel the fitting has written, once each. |
Procs | |
| apply_bands | One pass of the fitting over the templates' bands. Solid: each row the garment covers at the old edge and the pixel inside it moves its edge pixel out to the new edge and fills the gap with that inside pixel. Pattern: each new pixel copies the pixel 2 further in, wherever the garment covers any of the 3 pixels from the old edge in. |
| bare_near_forearm | Side views, for a garment that leaves the near forearm bare below its sleeve, like the polo shirts (/datum/sprite_accessory/clothing/proc/bares_near_forearm()): the forearm shows at the bigger arm's own width. |
| begin_pass | Starts a pass: until end_pass(), writes wait, and reads see the view as it was when the pass began. |
| close_hem | Side views, under a sleeve: the sleeve covers the arm down to where today's arm begins, so each of the bigger arm's pixels in those rows the garment leaves bare takes the colour of the nearest garment pixel in its row, the one nearer the left first. Works on the view in place, one pixel after another, so a filled pixel counts for the next. Never for a pattern, whose gaps are its own. |
| copy | Returns a copy of the view as fitted so far, on a copy of its frame, which fits on from where this one is and leaves it as it is: a top over flexing pecs fits each view to its limbs once, and each frame of the flex to the pecs over a copy. |
| covers | Whether the garment covers at least half of some of a limb's baseline pixels. |
| darken_moved_edges | Shaded sleeves, second step: the pixel at each fitted arm row's new edge goes one step darker in the garment's ramp, to the next darker colour that's the sleeve's own (sleeve_colours()) and kin to the pixel's (garment_colours_kin()), or stays as it is when none is. |
| draw | Draws the pixels the fitting changed onto frame. |
| end_pass | Ends the pass begin_pass() started, making its writes in order: a later write to a pixel wins. |
| fill_colour | Returns the view's fill: its brightest colour covering at least 3 pixels, or its brightest colour when none does. |
| first_pixel | Returns the x of the first pixel that isn't clear in row y, walking from first_x to last_x by step, or null. |
| fit | Fits the view to its limbs in mode (fit_limbs()), then to pecs drawn under it, still (fit_pecs()), and draws what changed
onto frame. |
| fit_limbs | Fits the view to its limbs in mode: the arms, the legs and a male chest's glutes, then the mode's own shading, then, in a
side view, a sleeve's hem down the bigger arm (close_hem()) and, for a garment that leaves the near forearm bare, that
forearm at its own width (bare_near_forearm()). |
| fit_pecs | Fits the view, after its limbs, to pecs drawn under the garment. |
| is_one_of | Whether pixel isn't clear and its colour is colour or other_colour. |
| knit_sleeves | Ribbed knit sleeves: each sleeve's ribs laid again from its outer edge, in columns anchored to its widest row, its shadow against the body thinned to one mid pixel, and its first cuff row ribbed light. Works on the view in place, row by row. |
| limb_templates | Returns the fitted ones of limbs for this view, in order: template limb -> its template. |
| move_panel_edges | Moves a solid or knit top's chest panel edges out over the pecs, by the bands of pec_panel_bands(): each edge pixel and its own detail, up to the first pixel of the fill and 2 pixels in all, keep their order at the new edge, and the gap behind them takes the pixel after the detail, or on a knit the pixel a whole number of 2 pixel rib periods further in. |
| pec_panel_bands | Returns the bands a front or back view's chest panel moves out by over pecs drawn under it: y, step back into the body, new edge, old edge, distance, and FALSE for a row that isn't a cap, as apply_bands() takes them. |
| pixel | Returns the view's pixel at x, y as the fitting has it so far, reading the frame the first time. |
| ramp | Returns the view's colours, without alpha, brightest first: the garment's own ramp. Counts them the first time: from the frame's own counts and what has been written over them, when they're known, otherwise by reading the whole view. |
| recolour | Returns pixel with its colour swapped for colour, keeping its alpha. |
| shade_arm_form | Shaded sleeves, first step: the garment's brightest colour over an arm takes the arm's muscle tone, mapped into the garment's own ramp (skin tones 0-5 to ramp steps 0, 0, 1, 1, 2, 2). A step whose colour isn't the sleeve's own (sleeve_colours()) or kin to that brightest colour (garment_colours_kin()) takes the next darker one that is, and a pixel with none is left as it is. |
| shade_pec_smile | Shades the pecs' lower curve, a "smile" one row above their crease, one shade down in a front view, wherever the top is lit there: brighter than 3/4 of its fill, so never a seam. A top with its own centre line, like a shirt's placket, keeps it off the pixels either side of that line. |
| shade_step | Returns the garment's colour one shade below a pixel: of its darker colours, the one whose brightness is nearest 86% of the pixel's, the brighter of two as near. A fixed drop, so a top of many close greys still shades visibly. Null when no colour is darker. |
| sleeve_colours | Returns each fitted arm's sleeve's own colours, the only ones shaded sleeves step through: fitted arm -> its colours, each colour -> TRUE. Read once, after the limbs are fitted and before the sleeves are shaded, so both steps of the shading take the same colours. The garment's whole ramp would give a sleeve its skirt's, belt's or boots' colours. |
| sleeve_steps | Returns the colour a pixel of colour source takes at each step of the view's ramp: the step's own colour where it's the
sleeve's own and kin to source (garment_colours_kin()), otherwise the next darker one that is, or null when none is. One
step longer than the ramp, its last null, so the step past the darkest can be asked for. |
| template_for | Returns the template of limb at its muscle size for this view, or null when the limb isn't fitted. |
| write | Writes a pixel, or queues it while a pass runs. |
Var Details
colour_counts 
Colour (without alpha) -> how many of the view's pixels have it. Counted when a ramp first needs every colour (ramp()), and kept up to date from then on.
frame 
One direction of the garment's state, which the fitted pixels are drawn on.
frame_colours 
The frame's own colour counts, known without reading its pixels (garment_sheet_metadata()), or null.
original 
The frame's own pixels, by FIT_INDEX(), wherever read: what the fitted pixels are compared with to draw them.
pending 
While a pass runs (begin_pass()), its writes as x, y, pixel triples, made as it ends: a pass reads the view as it began.
pixels 
The view's pixels as the fitting has them so far, by FIT_INDEX(): a pixel, or null where the frame isn't read yet.
sizes 
Template limb -> its muscle size, as /datum/garment_fit has them.
view 
The view's key in the templates: "S", "N", "E" or "W".
written_indexes 
The FIT_INDEX() of each pixel the fitting has written, once each.
Proc Details
apply_bands
One pass of the fitting over the templates' bands. Solid: each row the garment covers at the old edge and the pixel inside it moves its edge pixel out to the new edge and fills the gap with that inside pixel. Pattern: each new pixel copies the pixel 2 further in, wherever the garment covers any of the 3 pixels from the old edge in.
A row a limb grew into above its old top is fitted only under a sleeve, so straps over the shoulder stay put. Under a
sleeve, a solid row is also fitted where the garment covers its old edge alone, a hem a pixel thick against the arm's edge,
and its gap takes the edge pixel when the one inside it is bare. An arm's sleeve is judged from the garment's front view
(sleeves), anything else's from the upper third of its own baseline pixels in this view; a template without them, like a
pec's, never has one.
Arguments:
- templates: The templates, fitted in order: template limb -> its template, or a part of the body by any name -> its template in the same form.
- pattern: Whether to fit as pattern rather than solid.
- sleeves: Template limb -> whether the garment has a sleeve over it, from garment_front_sleeves(), or null.
bare_near_forearm
Side views, for a garment that leaves the near forearm bare below its sleeve, like the polo shirts (/datum/sprite_accessory/clothing/proc/bares_near_forearm()): the forearm shows at the bigger arm's own width.
A forearm row is one where the garment as drawn leaves some of today's near arm bare. In each, the garment is cleared over the whole near arm of the fitted size. That also takes away the strip a polo edges its cut-out with, which apply_bands() moves out across the bigger arm as it would a sleeve's one-pixel hem. Rows where the garment covers all of today's arm, its sleeve, are left as fitted. The near arm is the right one facing east and the left one facing west; one at the Normal size has no template, and nothing changes.
begin_pass
Starts a pass: until end_pass(), writes wait, and reads see the view as it was when the pass began.
close_hem
Side views, under a sleeve: the sleeve covers the arm down to where today's arm begins, so each of the bigger arm's pixels in those rows the garment leaves bare takes the colour of the nearest garment pixel in its row, the one nearer the left first. Works on the view in place, one pixel after another, so a filled pixel counts for the next. Never for a pattern, whose gaps are its own.
Arguments:
- sleeves: Fitted arm -> whether the garment has a sleeve over it, from garment_front_sleeves().
copy
Returns a copy of the view as fitted so far, on a copy of its frame, which fits on from where this one is and leaves it as it is: a top over flexing pecs fits each view to its limbs once, and each frame of the flex to the pecs over a copy.
covers
Whether the garment covers at least half of some of a limb's baseline pixels.
Arguments:
- core: The pixels, as x, y pairs; none covers nothing.
darken_moved_edges
Shaded sleeves, second step: the pixel at each fitted arm row's new edge goes one step darker in the garment's ramp, to the next darker colour that's the sleeve's own (sleeve_colours()) and kin to the pixel's (garment_colours_kin()), or stays as it is when none is.
Arguments:
- colours: Each fitted arm's sleeve's own colours, from sleeve_colours().
draw
Draws the pixels the fitting changed onto frame.
Returns:
- TRUE: The frame changed.
- FALSE: Nothing changed, and the frame is the state's own.
end_pass
Ends the pass begin_pass() started, making its writes in order: a later write to a pixel wins.
fill_colour
Returns the view's fill: its brightest colour covering at least 3 pixels, or its brightest colour when none does.
Arguments:
- brightness: The view's colours -> their brightness, brightest first, from ramp().
first_pixel
Returns the x of the first pixel that isn't clear in row y, walking from first_x to last_x by step, or null.
Arguments:
- y: The row.
- first_x, last_x: Where the walk starts and ends, both included.
- step: 1 or -1.
fit
Fits the view to its limbs in mode (fit_limbs()), then to pecs drawn under it, still (fit_pecs()), and draws what changed
onto frame.
Arguments:
- mode: A GARMENT_FIT_* define.
- pec_shape: The shape of pecs drawn under the garment, as /datum/garment_fit has it, or null.
- pec_nipples: Whether those pecs draw nipples.
- sleeves: Fitted arm -> whether the garment has a sleeve over it, from garment_front_sleeves(), or null.
- straight: Whether the garment hangs straight over those pecs (fit_pecs()).
- bare: Whether the garment leaves the near forearm bare in its side views at the arm's own width (fit_limbs()).
Returns:
- TRUE: The frame changed.
- FALSE: Nothing in this view changed, and the frame is the state's own.
fit_limbs
Fits the view to its limbs in mode: the arms, the legs and a male chest's glutes, then the mode's own shading, then, in a
side view, a sleeve's hem down the bigger arm (close_hem()) and, for a garment that leaves the near forearm bare, that
forearm at its own width (bare_near_forearm()).
Arguments:
- mode: A GARMENT_FIT_* define.
- sleeves: Fitted arm -> whether the garment has a sleeve over it, from garment_front_sleeves(), or null.
- bare: Whether the garment leaves the near forearm bare in its side views (/datum/sprite_accessory/clothing/proc/bares_near_forearm()).
fit_pecs
Fits the view, after its limbs, to pecs drawn under the garment.
Front and back views: where a pec reaches the chest's own side, the garment's chest panel moves out over it (pec_panel_bands()), unless the garment hangs straight over the pecs, then the front view shades the pecs' lower curve, in the modes the GARMENT_FIT_PEC_SMILE_* defines pick (shade_pec_smile()). Side views: the pec's bulge past the body's front is fitted as a limb's bands are.
Arguments:
- templates: The pecs' templates by view: their shape's still ones, or its ones on one frame of a flex (garment_pec_flex()).
- nipples: Whether the pecs draw nipples, which picks the smile's pixels.
- mode: A GARMENT_FIT_* define.
- straight: Whether the garment hangs straight over the pecs, its chest panel left as drawn and the pecs peeking out past it at the armholes.
is_one_of
Whether pixel isn't clear and its colour is colour or other_colour.
Arguments:
- pixel: A pixel.
- colour, other_colour: Colours without alpha.
knit_sleeves
Ribbed knit sleeves: each sleeve's ribs laid again from its outer edge, in columns anchored to its widest row, its shadow against the body thinned to one mid pixel, and its first cuff row ribbed light. Works on the view in place, row by row.
The ramp's four brightest colours are the knit's: rib, groove, mid and dark. A garment with fewer isn't a knit.
limb_templates
Returns the fitted ones of limbs for this view, in order: template limb -> its template.
Arguments:
- limbs: Template limbs, as /datum/garment_fit names them.
move_panel_edges
Moves a solid or knit top's chest panel edges out over the pecs, by the bands of pec_panel_bands(): each edge pixel and its own detail, up to the first pixel of the fill and 2 pixels in all, keep their order at the new edge, and the gap behind them takes the pixel after the detail, or on a knit the pixel a whole number of 2 pixel rib periods further in.
Arguments:
- bands: From pec_panel_bands().
- fill: The view's fill colour, from fill_colour().
- knit: Whether the top is a ribbed knit.
pec_panel_bands
Returns the bands a front or back view's chest panel moves out by over pecs drawn under it: y, step back into the body, new edge, old edge, distance, and FALSE for a row that isn't a cap, as apply_bands() takes them.
Each row the pec spans moves on each side where the pec's outermost pixel reaches the chest's own side; rows where it stays inside, like the collar's, never move. Over a bare pec pixel, the garment's outline moves out: from its first pixel inward, when it also holds the next two. Under the garment, like a sleeve over it, the panel's own edge moves: its armhole seam, the first pixel walking out from the centre that is no brighter than 3/4 of the fill. Either moves at most PEC_PANEL_MAX_MOVE pixels, every one of them over the pec.
Arguments:
- template: The pecs' template for this view.
- brightness: The view's colours -> their brightness, from ramp().
pixel
Returns the view's pixel at x, y as the fitting has it so far, reading the frame the first time.
Arguments:
- x, y: From the view's top left, from 0. Off the view, the pixel is clear.
ramp
Returns the view's colours, without alpha, brightest first: the garment's own ramp. Counts them the first time: from the frame's own counts and what has been written over them, when they're known, otherwise by reading the whole view.
Brightness is 299 R + 587 G + 114 B, Rec. 601 luma in whole numbers. Colours as bright as each other keep the order they were counted in, which only a read gives, so garment_metadata.json leaves out the views that have any.
recolour
Returns pixel with its colour swapped for colour, keeping its alpha.
Arguments:
- colour: A colour without alpha, from ramp().
- pixel: A pixel that isn't clear.
shade_arm_form
Shaded sleeves, first step: the garment's brightest colour over an arm takes the arm's muscle tone, mapped into the garment's own ramp (skin tones 0-5 to ramp steps 0, 0, 1, 1, 2, 2). A step whose colour isn't the sleeve's own (sleeve_colours()) or kin to that brightest colour (garment_colours_kin()) takes the next darker one that is, and a pixel with none is left as it is.
Arguments:
- colours: Each fitted arm's sleeve's own colours, from sleeve_colours().
shade_pec_smile
Shades the pecs' lower curve, a "smile" one row above their crease, one shade down in a front view, wherever the top is lit there: brighter than 3/4 of its fill, so never a seam. A top with its own centre line, like a shirt's placket, keeps it off the pixels either side of that line.
Arguments:
- points: The smile's pixels, as x, y pairs.
shade_step
Returns the garment's colour one shade below a pixel: of its darker colours, the one whose brightness is nearest 86% of the pixel's, the brighter of two as near. A fixed drop, so a top of many close greys still shades visibly. Null when no colour is darker.
Arguments:
- pixel_brightness: The pixel's brightness.
- brightness: The view's colours -> their brightness, brightest first, from ramp().
sleeve_colours
Returns each fitted arm's sleeve's own colours, the only ones shaded sleeves step through: fitted arm -> its colours, each colour -> TRUE. Read once, after the limbs are fitted and before the sleeves are shaded, so both steps of the shading take the same colours. The garment's whole ramp would give a sleeve its skirt's, belt's or boots' colours.
A sleeve's own colours are those the view has over the arm, and the view's other colours of the same family, so a garment of one material keeps its whole ramp. A lit colour is of the family when it's a grey and a lit colour over the arm is too, or its hue is within SLEEVE_MAX_HUE_SPREAD degrees of every lit hue there, which keeps the sleeve one hue, as garment_sleeve_mode() judges plain sleeves. A dark one, an outline's or a shadow's, whose hue tells less, when it's a grey and a colour over the arm is too, or its hue is within the spread of any hue there.
sleeve_steps
Returns the colour a pixel of colour source takes at each step of the view's ramp: the step's own colour where it's the
sleeve's own and kin to source (garment_colours_kin()), otherwise the next darker one that is, or null when none is. One
step longer than the ramp, its last null, so the step past the darkest can be asked for.
Arguments:
- ramp: The view's colours, brightest first, from ramp().
- colours: The sleeve's own colours, from sleeve_colours().
- source: The stepped pixel's colour, without alpha.
template_for
Returns the template of limb at its muscle size for this view, or null when the limb isn't fitted.
Arguments:
- limb: A template limb, as /datum/garment_fit names it.
write
Writes a pixel, or queues it while a pass runs.
Arguments:
- x, y: From the view's top left, from 0.
- pixel: The pixel to write.