Module: changeImg

Change Image module

Source:

Requires

  • module:interactables.js

Members

(static) color :string|null

Remembers the color in which the shirt was dyed.

Type:
  • string | null
Source:

Methods

(static) cut(shirt)

Converts the shirt into a crop top by updating its src attribute
based on the current color of the shirt stored in the color variable.

Parameters:
Name Type Description
shirt HTMLElement

The shirt element to be transformed into a crop top.

Source:
Example
// Change the shirt to a green crop top if it's currently green:cut(shirtElement);

(static) dye(bucket, shirt)

This function modifies the src of the shirt element to reflect the selected dye color.
Additionally, it updates the color variable (defined above) to store the current color
of the shirt.

Parameters:
Name Type Description
bucket HTMLElement

The bucket element used to dye the shirt.

shirt HTMLElement

The shirt element whose color is being changed.

Source:
Example
// Dye the shirt green using the green bucket:dye(interactables.greenBucket, shirtElement);

(static) stich(thread, patch)

Depending on the color of the thread (blackNeedle or whiteNeedle),
this function updates the src of the given patch (heartPatch, starPatch, or smileyPatch)
to reflect the appropriate stitched thread color.

Parameters:
Name Type Description
thread HTMLElement

The needle element used to stitch the patch, containing either black or white thread.

patch HTMLElement

The patch element to apply the stitched thread lines.

Source:
Example
// Using a black thread to stitch a heart patch:stich(interactables.blackNeedle, interactables.heartPatch);// Using a white thread to stitch a smiley patch:stich(interactables.whiteNeedle, interactables.smileyPatch);