mirror of
https://github.com/scratchfoundation/scratch-render.git
synced 2025-08-01 17:09:26 -04:00
Implement color-touching-color
The `isTouchingColor` function now takes an optional mask parameter. If provided, only the parts of the Drawable which match the mask color will be used for the test. For example: ``` isTouchingColor(4, red, blue); ``` This means "are there any parts of Drawable #4 which are blue and are touching a red pixel on some other Drawable?"
This commit is contained in:
parent
6b0f3379bf
commit
9f59b42901
3 changed files with 77 additions and 22 deletions
src
|
@ -119,8 +119,20 @@ Drawable.EFFECTS = Object.keys(Drawable._effectConverter);
|
|||
* @enum {string}
|
||||
*/
|
||||
Drawable.DRAW_MODE = {
|
||||
/**
|
||||
* Draw normally.
|
||||
*/
|
||||
default: 'default',
|
||||
pick: 'pick'
|
||||
|
||||
/**
|
||||
* Draw the Drawable's silhouette using a particular color.
|
||||
*/
|
||||
silhouette: 'silhouette',
|
||||
|
||||
/**
|
||||
* Draw only the parts of the drawable which match a particular color.
|
||||
*/
|
||||
colorMask: 'colorMask'
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -238,7 +250,7 @@ Drawable.prototype._useSkin = function(
|
|||
/**
|
||||
* Fetch the shader for this Drawable's set of active effects.
|
||||
* Build the shader if necessary.
|
||||
* @param {Drawable.DRAW_MODE} drawMode Draw normally or for picking, etc.
|
||||
* @param {Drawable.DRAW_MODE} drawMode Draw normally, silhouette, etc.
|
||||
* @returns {module:twgl.ProgramInfo?} The shader's program info.
|
||||
*/
|
||||
Drawable.prototype.getShader = function (drawMode) {
|
||||
|
@ -255,7 +267,7 @@ Drawable.prototype.getShader = function (drawMode) {
|
|||
|
||||
/**
|
||||
* Build the shader for this Drawable's set of active effects.
|
||||
* @param {Drawable.DRAW_MODE} drawMode Draw normally or for picking, etc.
|
||||
* @param {Drawable.DRAW_MODE} drawMode Draw normally, silhouette, etc.
|
||||
* @returns {module:twgl.ProgramInfo?} The new shader's program info.
|
||||
* @private
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue