Skip to content

Commit

Permalink
Update v0.1.3-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
Feu-Secret committed Jul 14, 2020
1 parent 9125eea commit 823b559
Show file tree
Hide file tree
Showing 20 changed files with 1,168 additions and 156 deletions.
Binary file modified .vs/Tokenmagic/v16/.suo
Binary file not shown.
5 changes: 3 additions & 2 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"\\tokenmagic\\fx\\glsl\\fragmentshaders",
"\\tokenmagic\\fx\\glsl\\vertexshaders",
"\\tokenmagic\\libs",
"\\tokenmagic\\module"
"\\tokenmagic\\module",
"\\tokenmagic\\updates"
],
"SelectedNode": "\\tokenmagic\\module\\tokenmagic.js",
"SelectedNode": "\\tokenmagic\\fx\\glsl\\fragmentshaders\\mirrorimages.js",
"PreviewInSolutionExplorer": false
}
Binary file modified .vs/slnx.sqlite
Binary file not shown.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# Token Magic FX - Update v0.1.3-alpha

## FX

*Added :*
- Force Field/Aura/Shield Filters
- Ultra customizable (intensity, blend modes, lights, color, grid padding, etc.)
- 12 filter types + 1 simple aura.
- Usables by both Scifi, fantasy and modern universes.
- The simple aura can be used to "bind" other filters
- Mirror image Filter
- A simple 4 pass mirroring, with moving images.

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

*Fixed issues :*
- The padding property value is now multiplied by the zoom factor.
- Some internal improvements and refactoring.

# Token Magic FX - Update v0.1.2-alpha

## FX
Expand Down
Binary file modified Tokenmagic.zip
Binary file not shown.
25 changes: 1 addition & 24 deletions tokenmagic/fx/filters/FilterBulgePinch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,21 @@ import "./proto/FilterProto.js";
export class FilterBulgePinch extends PIXI.filters.BulgePinchFilter {
constructor(params) {
super();
this.enabled = false;

this.strength = 0;
this.radiusPercent = 100;
this.padding = 0;

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

this.placeableImg = null;
this.preComputation = this.handleTransform;

// Anchor point
this.center = [0.5, 0.5];

// Get placeable to compute center
if (!(params == null) || !params.hasOwnProperty("placeableId")) {
if (params.placeableType === "Token") {
let parent = canvas.tokens.placeables.find(n => n.id === params.placeableId);
if (!(parent == null)) {
this.placeableImg = parent.icon;
}
} else {
let parent = canvas.tiles.placeables.find(n => n.id === params.placeableId);
if (!(parent == null)) {
this.placeableImg = parent.tile.img;
}
}
this.handleTransform();
}
}

handleTransform() {
if (this.hasOwnProperty("zIndex")) {
this.placeableImg.parent.zIndex = this.zIndex;
}

this.radius = (Math.max(this.placeableImg.width, this.placeableImg.height)
* this.placeableImg.parent.worldTransform.a
* this.radiusPercent) / 200;
Expand Down
22 changes: 3 additions & 19 deletions tokenmagic/fx/filters/FilterDistortion.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,9 @@ export class FilterDistortion extends PIXI.filters.DisplacementFilter {
this.sprite.anchor.set(this.anchorSet);
this.sprite.texture.baseTexture.wrapMode = this.wrapMode;

// Attaching the sprite
if (!(params == null) || !params.hasOwnProperty("placeableId")) {
var placeable = null;
if (params.placeableType === "Token") {
placeable = canvas.tokens.placeables.find(n => n.id === params.placeableId);
if (!(placeable == null)) {
placeable.icon.addChild(this.sprite);
this.sprite.x = placeable.icon.width / 2;
this.sprite.y = placeable.icon.height / 2;
}
} else if (params.placeableType === "Tile") {
placeable = canvas.tiles.placeables.find(n => n.id === params.placeableId);
if (!(placeable == null)) {
placeable.tile.img.addChild(this.sprite);
this.sprite.x = placeable.tile.img.width / 2;
this.sprite.y = placeable.tile.img.height / 2;
}
}
}
this.placeableImg.addChild(this.sprite);
this.sprite.x = this.placeableImg.width / 2;
this.sprite.y = this.placeableImg.height / 2;
}

set maskSpriteX(value) {
Expand Down
166 changes: 166 additions & 0 deletions tokenmagic/fx/filters/FilterForceField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import { forceField } from '../glsl/fragmentshaders/forcefield.js';
import { customVertex2D } from '../glsl/vertexshaders/customvertex2D.js';
import { Anime } from "../Anime.js";
import "./proto/FilterProto.js";

export class FilterForceField extends PIXI.Filter {
constructor(params) {
let {
time,
color,
lightAlpha,
blend,
shieldType,
posLightX,
posLightY,
lightSize,
scale,
intensity,
radius,
chromatic
} = Object.assign({}, FilterForceField.defaults, params);

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

this.uniforms.color = new Float32Array([1.0, 1.0, 1.0]);
this.uniforms.posLight = new Float32Array([1.0, 1.0]);

Object.assign(this, {
time,
color,
lightAlpha,
blend,
shieldType,
posLightX,
posLightY,
lightSize,
scale,
intensity,
radius,
chromatic
});

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 color() {
return PIXI.utils.rgb2hex(this.uniforms.color);
}

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

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

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

get lightAlpha() {
return this.uniforms.lightColorAlpha;
}

set lightAlpha(value) {
this.uniforms.lightColorAlpha = value;
}

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

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

get posLightX() {
return this.uniforms.posLight[0];
}

set posLightX(value) {
this.uniforms.posLight[0] = value;
}

get posLightY() {
return this.uniforms.posLight[1];
}

set posLightY(value) {
this.uniforms.posLight[1] = value;
}

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

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

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

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

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

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

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

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

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

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

FilterForceField.defaults = {
time: 0,
color: 0xBBBBBB,
lightAlpha: 1.0,
blend: 2,
shieldType: 1,
posLightX: 0.65,
posLightY: 0.25,
lightSize: 0.4830,
scale: 1,
intensity: 1,
radius: 1,
chromatic: false,
};




2 changes: 0 additions & 2 deletions tokenmagic/fx/filters/FilterGlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ export class FilterGlow extends PIXI.filters.GlowFilter {
this.distance = 10;
this.anime = new Anime(this);
this.normalizeTMParams();


}
}
64 changes: 64 additions & 0 deletions tokenmagic/fx/filters/FilterMirrorImages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { mirrorImages } from '../glsl/fragmentshaders/mirrorimages.js';
import { customVertex2D } from '../glsl/vertexshaders/customvertex2D.js';
import { Anime } from "../Anime.js";
import "./proto/FilterProto.js";

export class FilterMirrorImages extends PIXI.Filter {

constructor(params) {
let {
time,
blend,
alpha,
} = Object.assign({}, FilterMirrorImages.defaults, params);

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

//this.uniforms.color = new Float32Array([1.0, 1.0, 1.0]);
//this.uniforms.scale = new Float32Array([1.0, 1.0]);

Object.assign(this, {
time, blend, alpha
});

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 alpha() {
return this.uniforms.alpha;
}

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

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

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

FilterMirrorImages.defaults = {
time: 0,
blend: 2,
alpha: 0.5,
};




37 changes: 8 additions & 29 deletions tokenmagic/fx/filters/FilterShockWave.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,16 @@ export class FilterShockwave extends PIXI.filters.ShockwaveFilter {
this.setTMParams(params);
this.anime = new Anime(this);
this.normalizeTMParams();

this.placeableImg = null;
this.preComputation = this.handleTransform;

// Get placeable to compute center
if (!(params == null) || !params.hasOwnProperty("placeableId")) {
if (params.placeableType === "Token") {
let parent = canvas.tokens.placeables.find(n => n.id === params.placeableId);
if (!(parent == null)) {
this.placeableImg = parent.icon;
}
} else {
let parent = canvas.tiles.placeables.find(n => n.id === params.placeableId);
if (!(parent == null)) {
this.placeableImg = parent.tile.img;
}
}
this.handleTransform();
}
}

play() {
this.enabled = true;
}

stop() {
this.enabled = false;
}

handleTransform() {
this.center[0] = this.placeableImg.localTransform.tx * this.placeableImg.parent.worldTransform.a;
this.center[1] = this.placeableImg.localTransform.ty * this.placeableImg.parent.worldTransform.a;
this.center[0] = (this.placeableImg.localTransform.tx
* this.placeableImg.parent.worldTransform.a
* this.placeableImg.parent.data.scale)
+ this.padding;
this.center[1] = (this.placeableImg.localTransform.ty
* this.placeableImg.parent.worldTransform.a
* this.placeableImg.parent.data.scale)
+ this.padding;
}
}
Loading

0 comments on commit 823b559

Please sign in to comment.