Skip to content

Commit 79b8d8f

Browse files
committed
WarpByScalar
Signed-off-by: martinRenou <[email protected]>
1 parent ae8d0f3 commit 79b8d8f

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

ipygany/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
PolyMesh, TetraMesh, PointCloud,
99
Scene,
1010
Data, Component,
11-
Alpha, RGB, IsoColor, Threshold, IsoSurface, Warp,
11+
Alpha, RGB, IsoColor, Threshold, IsoSurface,
12+
Warp, WarpByScalar,
1213
Water, UnderWater
1314
)
1415
from ._version import __version__, version_info # noqa

ipygany/ipygany.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,19 @@ def input_dim(self):
529529
return 3
530530

531531

532+
class WarpByScalar(Effect):
533+
"""A warp-by-scalar effect to another block."""
534+
535+
_model_name = Unicode('WarpByScalarModel').tag(sync=True)
536+
537+
factor = CFloat(1.).tag(sync=True)
538+
539+
@property
540+
def input_dim(self):
541+
"""Input dimension."""
542+
return 1
543+
544+
532545
class Alpha(Effect):
533546
"""An transparency effect to another block."""
534547

src/widget.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
Data, Component,
2828
Block, Effect,
2929
PolyMesh, TetraMesh, PointCloud,
30-
Warp, Alpha, RGB, IsoColor, IsoSurface, Threshold,
30+
Warp, WarpByScalar, Alpha, RGB, IsoColor, IsoSurface, Threshold,
3131
Water, UnderWater,
3232
} from 'ganyjs';
3333

@@ -409,6 +409,40 @@ class WarpModel extends EffectModel {
409409
}
410410

411411

412+
export
413+
class WarpByScalarModel extends EffectModel {
414+
415+
defaults() {
416+
return {...super.defaults(),
417+
_model_name: WarpByScalarModel.model_name,
418+
};
419+
}
420+
421+
get input () {
422+
return this.get('input');
423+
}
424+
425+
get factor () {
426+
return this.get('factor');
427+
}
428+
429+
createBlock () {
430+
return new WarpByScalar(this.parent.block, this.input, this.factor);
431+
}
432+
433+
initEventListeners () : void {
434+
super.initEventListeners();
435+
436+
this.on('change:factor', () => { this.block.factor = this.factor; });
437+
}
438+
439+
block: WarpByScalar;
440+
441+
static model_name = 'WarpByScalarModel';
442+
443+
}
444+
445+
412446
export
413447
class AlphaModel extends EffectModel {
414448

0 commit comments

Comments
 (0)