Skip to content

Commit

Permalink
fix(custom text effect): update color documentation/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
seleb committed Nov 17, 2021
1 parent df0f9f1 commit ca02add
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/custom text effect.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ The key is the text you'll write inside {} in bitsy to trigger the effect
The first argument is `char`, an individual character, which has the following properties:
offset: offset from actual position in pixels. starts at {x:0, y:0}
color: color of rendered text in [0-255]. starts at {r:255, g:255, b:255, a:255}
color: palette index of rendered text. use `tileColorStartIndex`/`rainbowColorStartIndex`
to modify this, e.g. `tileColorStartIndex + 2` is the sprite colour
bitmap: character bitmap as array of pixels
row: vertical position in rows (doesn't affect rendering)
col: horizontal position in characters (doesn't affect rendering)
Expand All @@ -51,14 +52,15 @@ The second argument is `time`, which is the time in milliseconds
A number of example effects are included
*/
import bitsy from 'bitsy';
import { inject } from './helpers/kitsy-script-toolkit';

export var hackOptions = {
'my-effect': function () {
// a horizontal wavy effect with a blue tint
// a horizontal wavy effect using the blue rbw colour
this.DoEffect = function (char, time) {
char.offset.x += 5 * Math.sin(time / 100 + char.col / 3);
char.color.r = 255 * Math.cos(time / 100 + char.col / 3);
char.color = bitsy.rainbowColorStartIndex + 4;
};
},
droop: function () {
Expand All @@ -69,13 +71,6 @@ export var hackOptions = {
char.offset.y += ((time - char.start) / 100) * Math.abs(Math.sin(char.col));
};
},
fadeout: function () {
// fades text to invisible after appearing
this.DoEffect = function (char, time) {
char.start = char.start || time;
char.color.a = Math.max(0, 255 - (time - char.start) / 2);
};
},
noise: function () {
// renders noise on top of text
// note that it's making a copy with `.slice()` since it's a dynamic bitmap change
Expand Down

0 comments on commit ca02add

Please sign in to comment.