Skip to content

Conversation

@comradeshook
Copy link
Contributor

  • Added Lua-accessible bitmap manipulation functions to MOSprites:

     GetSpritePixelIndex(int x, int y, int whichFrame) - Returns the color index of the pixel at the given coordinate on the given frame of the sprite ((0, 0) is the upper left corner!)
    
     SetSpritePixelIndex(int x, int y, int whichFrame, int colorIndex, int ignoreIndex, bool invert) - Sets the color of the pixel at the given coordinate on the given frame of the sprite, skipping if the pixel has same color index as given in "ignoreIndex". If "invert" is set to true, only pixels of that color index are set.
    
     GetAllSpritePixelPositions(const Vector& origin, float angle, bool hflipped, int whichFrame, int ignoreIndex, bool invert, bool includeChildren) - Returns a list of vectors pointing to the absolute positions of all pixels in the given frame of the sprite, rotated to match "angle", flipped to match "hflipped" and positioned around "origin", providing a full silhouette of the MOSprite. "IgnoreIndex" and "invert" are like above, "includeChildren" denotes whether or not to include all children of the MOSprite (no effect if not at least an MOSRotating).
    
     GetAllVisibleSpritePixelPositions(bool includeChildren) - Simplified version of the above, returning a list of absolute positions of the visible pixels of the current frame of the sprite as it is currently drawn.
    
     SetAllSpritePixelIndexes(int whichFrame, int colorIndex, int ignoreIndex, bool invert) - Sets all pixels in the given frame of the sprite to the given color index, ignoring and inverting as above.
    
     SetAllVisibleSpritePixelIndexes(int colorIndex) - Simplified version of the above, sets all visible pixels of the currently visible sprite to the given color index.
    
  • Added Material Lua function GetColorIndex(), which returns the color index of the calling material.

  • Fixed MOSprite:UnRotateOffset() giving the wrong results on HFLipped sprites.

Allows modification of MOSprite bitmaps on the fly, which can give neat effects like discolouring and deformation. Surprisingly, doing this DOES modify how MOSR's get hit without any further modifications.

…r sprites have been modified so the extras can be deleted on Destroy

Added documentation in MOSprite.h
Implemented MOSprite:SetPixelIndex()
Implemented MOSprite:GetAllVisiblePixelPositions()
Fixed GetAllPixelPositions not accounting for sprite offset properly
Exposed to Lua as necessary
Changed GetAllPixelPositions to have an ignoreIndex and invert bool instead of an ignoreTransparency bool
…itmap manipulation functions sorry i can't remember all the the changes but they're good i promise
…r sprites have been modified so the extras can be deleted on Destroy

Added documentation in MOSprite.h
Implemented MOSprite:SetPixelIndex()
Implemented MOSprite:GetAllVisiblePixelPositions()
Fixed GetAllPixelPositions not accounting for sprite offset properly
Exposed to Lua as necessary
Changed GetAllPixelPositions to have an ignoreIndex and invert bool instead of an ignoreTransparency bool
…itmap manipulation functions sorry i can't remember all the the changes but they're good i promise
…plementation (not yet applied to anything vanilla)
…plementation (not yet applied to anything vanilla)
Copy link
Contributor

@Causeless Causeless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Causeless Causeless added this pull request to the merge queue Jan 12, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jan 12, 2025
@Causeless Causeless added this pull request to the merge queue Jan 12, 2025
Merged via the queue into development with commit f9483a2 Jan 12, 2025
4 checks passed
@Causeless Causeless deleted the getpixelshenanigans branch January 12, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants