Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TS committed Jan 14, 2021
2 parents 9fa2539 + 5ad4ffa commit 7e68cdf
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 15 deletions.
5 changes: 4 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ <h1>Seamless texture generator</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/theme-monokai.min.js"
integrity="sha512-S4i/WUGRs22+8rjUVu4kBjfNuBNp8GVsgcK2lbaFdws4q6TF3Nd00LxqnHhuxS9iVDfNcUh0h6OxFUMP5DBD+g=="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r75/three.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r75/three.min.js"
integrity="sha512-0Um5jj8EXynt5279TxN98RDLAUBs8FgpBcDZSiatk1FeD5f0XszFdpb04AS110QyQTNa7Kj0zoeZCIhTmVikug=="
crossorigin="anonymous"></script>


<script src="../dist/tgen-with-presets.js"></script>
<script src="./js/index.js"></script>
Expand Down
8 changes: 5 additions & 3 deletions dist/tgen-with-presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var SeamlessTextureGenerator = (function() {

return {

version: '1.3.3',
version: '1.3.5',
defaults: {},
effects: {},
filters: [],
Expand Down Expand Up @@ -6053,7 +6053,9 @@ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
if (config.preset.seed) {

for (key in items) {
items[key][2].seed = config.preset.seed;
if (items[key][2]) {
items[key][2].seed = config.preset.seed;
}
}

}
Expand All @@ -6073,7 +6075,7 @@ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {

layerId = config.items[index][0];
effect = config.items[index][1];
values = config.items[index][2] ? config.items[index][2] : {};
values = config.items[index][2] !== undefined ? config.items[index][2] : {};

if (layerId === null) {
layerId = effect === 'copy' ? currentId + 1 : currentId;
Expand Down
4 changes: 2 additions & 2 deletions dist/tgen-with-presets.min.js

Large diffs are not rendered by default.

Binary file modified dist/tgen-with-presets.min.js.gz
Binary file not shown.
8 changes: 5 additions & 3 deletions dist/tgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var SeamlessTextureGenerator = (function() {

return {

version: '1.3.3',
version: '1.3.5',
defaults: {},
effects: {},
filters: [],
Expand Down Expand Up @@ -3449,7 +3449,9 @@ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
if (config.preset.seed) {

for (key in items) {
items[key][2].seed = config.preset.seed;
if (items[key][2]) {
items[key][2].seed = config.preset.seed;
}
}

}
Expand All @@ -3469,7 +3471,7 @@ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {

layerId = config.items[index][0];
effect = config.items[index][1];
values = config.items[index][2] ? config.items[index][2] : {};
values = config.items[index][2] !== undefined ? config.items[index][2] : {};

if (layerId === null) {
layerId = effect === 'copy' ? currentId + 1 : currentId;
Expand Down
4 changes: 2 additions & 2 deletions dist/tgen.min.js

Large diffs are not rendered by default.

Binary file modified dist/tgen.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seamless-texture-generator",
"version": "1.3.3",
"version": "1.3.5",
"description": "Seamless texture generator",
"homepage": "https://github.com/schalkt/tgen/",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/tgen-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var SeamlessTextureGenerator = (function() {

return {

version: '1.3.3',
version: '1.3.5',
defaults: {},
effects: {},
filters: [],
Expand Down
6 changes: 4 additions & 2 deletions src/tgen-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,9 @@
if (config.preset.seed) {

for (key in items) {
items[key][2].seed = config.preset.seed;
if (items[key][2]) {
items[key][2].seed = config.preset.seed;
}
}

}
Expand All @@ -1284,7 +1286,7 @@

layerId = config.items[index][0];
effect = config.items[index][1];
values = config.items[index][2] ? config.items[index][2] : {};
values = config.items[index][2] !== undefined ? config.items[index][2] : {};

if (layerId === null) {
layerId = effect === 'copy' ? currentId + 1 : currentId;
Expand Down
46 changes: 46 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,50 @@ describe('tgen', function () {

});

describe('copy-merge', function () {

it('overlay ok', function () {

var generator = tgen.init(size, size);

var texture = generator.render({
"items": [
[0, "spheres", {
"seed": 9481
}],
[1, "spheres", {
"seed": 3845
}],
[2, "copy", 0],
[2, "merge", {
"layer": 1,
"blend": "difference"
}]
]
});

savePNG(texture, 'copy-merge');

var params = texture.params();

assert.strictEqual(params.width, size);
assert.strictEqual(params.height, size);
assert.strictEqual(params.normalize, 'limitless');
assert.strictEqual(params.items[0][1], 'spheres');
assert.strictEqual(params.items[3][2].blend, 'difference');

assert.strictEqual(texture.texture.data[0], 173.28090000152588);
assert.strictEqual(texture.texture.data[1], 55.931830406188965);
assert.strictEqual(texture.texture.data[2], 168.4103558063507);
assert.strictEqual(texture.texture.data[3], 255);

assert.strictEqual(texture.texture.data[4], 135.27759742736816);
assert.strictEqual(texture.texture.data[5], 40.2001428604126);
assert.strictEqual(texture.texture.data[6], 136.52849769592285);
assert.strictEqual(texture.texture.data[7], 255);

});

});

});

0 comments on commit 7e68cdf

Please sign in to comment.