Skip to content

Commit

Permalink
Update v0.2.0-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
Feu-Secret committed Jul 24, 2020
1 parent 89fa7ff commit 11a830d
Show file tree
Hide file tree
Showing 23 changed files with 1,215 additions and 169 deletions.
Binary file modified .vs/Tokenmagic/v16/.suo
Binary file not shown.
3 changes: 2 additions & 1 deletion .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"\\tokenmagic",
"\\tokenmagic\\fx",
"\\tokenmagic\\fx\\filters",
"\\tokenmagic\\fx\\filters\\proto",
"\\tokenmagic\\fx\\glsl",
"\\tokenmagic\\fx\\glsl\\fragmentshaders",
"\\tokenmagic\\fx\\glsl\\vertexshaders",
"\\tokenmagic\\libs",
"\\tokenmagic\\module",
"\\tokenmagic\\updates"
],
"SelectedNode": "\\tokenmagic\\fx\\glsl\\fragmentshaders\\forcefield.js",
"SelectedNode": "\\tokenmagic\\fx\\glsl\\fragmentshaders\\glowoh.js",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,100 @@
# Token Magic FX - Update v0.2.0-alpha

*Added :*
- A copy of a token also copies the FX
- FX are now stored on prototype tokens (if you update your prototype with a FXified Token)
- An option panel is now available :
- You can desactivate additive padding in favor of max padding
- You can set a minimum padding for all applied FX

*New FX :*
- An advanced Ray filter (with better quality than cosmic ray filter)
- blending options
- Another liquid filter (complementary with the flood filter)
- blending options
- spectral property
- A gleaming glow filter
- two glow types
- adjustable FX scale
- adjustable thickness
- and lot more options to create magical glows.

The new filters have been added to the TokenMagic macro compendium.

*Fixed issues :*
- autoDestroy property did not work properly (the effect was restored when reloading the scene)
- Freezing when updating image, dimensions or tint of a token.
- Freezing when updating image of a tile.
- An effect without animated properties could not be updated normally.
- The global animated property could not be unset (can be unset now with `animated: null`)

## Filters handling

*Added new functions :*

To verify if a placeable has a filter with the specified `filterType` :
```javascript
TokenMagic.hasFilterType(<placeable>,<filterType>)

// Example
...
if (TokenMagic.hasFilterType(myToken,"glow")) {
console.log("myToken has a glow filter.");
}
...
```
To verify if a placeable has a filter with the specified `filterId` :
```javascript
TokenMagic.hasFilterId(<placeable>,<filterId>)

// Example
...
if (TokenMagic.hasFilterId(myToken,"mySuperShadow_01")) {
console.log("myToken has my customized super shadow 1 filter.");
}
...
```
Add or update filter(s) on a placeable. If a filter applied on an object has a filterType and a filterId identical to those found in the parameters, the values are updated with the new ones. Otherwise a new filter is created.
```javascript
(async) TokenMagic.addUpdateFilters(<placeable>, <array of creation/update params>)
```

## PlaceableObject TMFX prototypes

*Added new prototype functions in class PlaceableObject (Token, Tile, etc.), to facilitate coding :*

```javascript
(async) <PlaceableObject>.TMFXaddFilters(<params array>)
(async) <PlaceableObject>.TMFXupdateFilters(<params array>)
(async) <PlaceableObject>.TMFXaddUpdateFilters(<params array>)
(async) <PlaceableObject>.TMFXdeleteFilters(optional <filterId>)
<PlaceableObject>.TMFXhasFilterType(<filterType>)
<PlaceableObject>.TMFXhasFilterId(<filterId>)

// Example 1
let glowFunc = async function() {

const tokens = canvas.tokens.placeables;

for (const token of tokens){
if (token.TMFXhasFilterId("funnyAlternateGlow")) {
await token.TMFXdeleteFilters("funnyAlternateGlow");
} else {
let params =
[{
filterType: "glow",
filterId: "funnyAlternateGlow",
color: Math.floor(Math.random() * 16777215),
animated: null
}];
await token.TMFXaddUpdateFilters(params);
}
}
};

glowFunc();
```

# Token Magic FX - Update v0.1.3d-alpha

## FX
Expand Down
Binary file modified Tokenmagic.zip
Binary file not shown.
25 changes: 15 additions & 10 deletions tokenmagic/fx/Anime.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ export class Anime {

if (!(this.puppet == null)) {
if (this.puppet.hasOwnProperty("animated")
&& !(this.puppet.animated == null)
&& typeof this.puppet.animated === 'object'
&& Object.keys(this.puppet.animated).length > 0) {

this.initAnimatedInternals(this.puppet.animated);
this.animated = this.puppet.animated; // easy access to the puppet's animodes
Anime.addAnimation(self); // ready to tick
}
Anime.addAnimation(self); // ready to tick
}
}

Expand Down Expand Up @@ -56,7 +57,6 @@ export class Anime {
this.elapsedTime[effect] += frameTime;
}
});

this.autoDisableCheck();
}

Expand Down Expand Up @@ -89,18 +89,21 @@ export class Anime {
if (!(this.puppet.filterOwner === game.data.userId
&& (this.puppet.autoDisable || this.puppet.autoDestroy))) { return; }

if (this.puppet.enabled === false) { return; }
if (this.puppet.enabled === false && !this.puppet.autoDestroy) { return; }

if (Object.values(this.animated).every(animeEffect => animeEffect.active === false)) {

let params = {};
params.filterId = this.puppet.filterId;
this.puppet.autoDestroy ? params.destroy = true : params.enabled = false;

var placeable = this.puppet.getPlaceable();

// updating the filter trigger an update{placeable} for everyone
await window.TokenMagic.updateFilterByPlaceable(params, placeable);
if (this.puppet.autoDestroy) {
await window.TokenMagic.deleteFilters(placeable, this.puppet.filterId);
} else {
let params = {};
params.filterId = this.puppet.filterId;
params.enabled = false;

await window.TokenMagic.updateFilterByPlaceable(params, placeable);
}
}
}

Expand Down Expand Up @@ -387,7 +390,9 @@ export class Anime {
if (anime.puppet.hasOwnProperty("preComputation")) {
anime.puppet.preComputation();
}
anime.animate(Anime._frameTime);
if (anime.puppet.hasOwnProperty("animated") && !(anime.puppet.animated == null)) {
anime.animate(Anime._frameTime);
}
});
Anime._prevTime = Anime._lastTime;
}
Expand Down
125 changes: 125 additions & 0 deletions tokenmagic/fx/filters/FilterGleamingGlow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { magicGlow } from '../glsl/fragmentshaders/magicglow.js';
import { customVertex2D } from '../glsl/vertexshaders/customvertex2D.js';
import { Anime } from "../Anime.js";
import "./proto/FilterProto.js";

export class FilterGleamingGlow extends PIXI.Filter {

constructor(params) {

let {
time,
color,
thickness,
scale,
auraIntensity,
subAuraIntensity,
discard,
threshold,
auraType
} = Object.assign({}, FilterGleamingGlow.defaults, params);

// using specific vertex shader and fragment shader
super(customVertex2D, magicGlow);

this.uniforms.color = new Float32Array([1.0, 0.4, 0.1, 1.0]);
this.uniforms.thickness = new Float32Array([0.01, 0.01]);

Object.assign(this, {
time, color, thickness, scale, auraIntensity, subAuraIntensity, discard, threshold, auraType
});

this.animated = {};
this.setTMParams(params);
this.anime = new Anime(this);
this.normalizeTMParams();
}

get time() {
return this.uniforms.time;
}

set time(value) {
this.uniforms.time = value;
}

get scale() {
return this.uniforms.scale;
}

set scale(value) {
this.uniforms.scale = value;
}

get auraIntensity() {
return this.uniforms.auraIntensity;
}

set auraIntensity(value) {
this.uniforms.auraIntensity = value;
}

get subAuraIntensity() {
return this.uniforms.subAuraIntensity;
}

set subAuraIntensity(value) {
this.uniforms.subAuraIntensity = value;
}

get threshold() {
return this.uniforms.threshold;
}

set threshold(value) {
this.uniforms.threshold = value;
}

get color() {
return PIXI.utils.rgb2hex(this.uniforms.color);
}

set color(value) {
PIXI.utils.hex2rgb(value, this.uniforms.color);
}

get discard() {
return this.uniforms.holes;
}

set discard(value) {
if (!(value == null) && typeof value === "boolean") {
this.uniforms.holes = value;
}
}

get auraType() {
return this.uniforms.auraType;
}

set auraType(value) {
this.uniforms.auraType = Math.floor(value);
}

apply(filterManager, input, output, clear) {
this.uniforms.thickness[0] = (this.thickness * this.placeableImg.parent.worldTransform.a) / input._frame.width;
this.uniforms.thickness[1] = (this.thickness * this.placeableImg.parent.worldTransform.a) / input._frame.height;
filterManager.applyFilter(this, input, output, clear);
}
}

FilterGleamingGlow.defaults = {
time: 0,
color: 0xFF8010,
thickness: 5,
scale: 1,
auraIntensity: 1,
subAuraIntensity: 1,
discard: false,
threshold: 0.5,
auraType: 1,
};




Loading

0 comments on commit 11a830d

Please sign in to comment.