Skip to content

Commit

Permalink
Merge 5576cf2 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Sep 24, 2021
2 parents 4a0bae6 + 5576cf2 commit 2bc20e7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ The resulting tiles can be used as textures in games, compositing and 3D modelin
<details>
<summary>Sample images</summary>

⚠️ If images don't load, check out the [original of this document on GitHub](https://github.com/rtmigo/img2texture_py#readme).

*⚠️ If the images below are not displayed, check out the
[original of this document on GitHub](https://github.com/rtmigo/img2texture_py#readme).*

### Original image x4

Expand Down Expand Up @@ -65,19 +67,21 @@ Increasing the value makes the seam less visible. However, the image becomes sma
<details>
<summary>Sample images</summary>

⚠️ If images don't load, check out the [original of this document on GitHub](https://github.com/rtmigo/img2texture_py#readme).
*⚠️ If the images below are not displayed, check out the
[original of this document on GitHub](https://github.com/rtmigo/img2texture_py#readme).*


### --overlap 0.05

The 5% seam.
5% of the width and 5% of the height are used to mask the seam.

![--overlap 0.05](docs/3_orion_05_2x2.jpg)



### --overlap 0.4

The 40% seam.
40% of the width and 40% of the height are used to mask the seam.

![--overlap 40](docs/3_orion_40_2x2.jpg)

Expand Down
Binary file removed img.png
Binary file not shown.
4 changes: 2 additions & 2 deletions img2texture/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __init__(self):

self._parsed = parser.parse_args()

if not 0 <= self.overlap_pct <= 1.0:
parser.error("--overlap must be in range from 0 to 1")
if not 0 <= self.overlap_pct <= 0.5:
parser.error("--overlap must be in range from 0.0 to 0.5")

@property
def source(self) -> Path:
Expand Down
2 changes: 1 addition & 1 deletion img2texture/_constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.0.post1"
__version__ = "0.1.1"

__copyright__ = "(c) 2021 Artyom Galkin <github.com/rtmigo>"
__license__ = "MIT"
14 changes: 11 additions & 3 deletions img2texture/_texturizing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: (c) 2021 Artyom Galkin <github.com/rtmigo>
# SPDX-License-Identifier: MIT

from math import floor
from pathlib import Path
from typing import Tuple

Expand Down Expand Up @@ -44,6 +44,14 @@ def vertical_gradient_256_scaled(size: Tuple[int, int], reverse=True) -> Image:
return gradient.resize(size)


def stripe_size(full_size: int, pct: float) -> int:
if not 0 <= pct <= 0.5:
raise ValueError(pct)
result = floor(full_size * pct)
assert result * 2 <= full_size
return result


class Mixer:
def __init__(self, source: Image, pct=1.0 / 3):
self.source = source
Expand All @@ -59,11 +67,11 @@ def src_height(self) -> int:

@property
def horizontal_stripe_width(self) -> int:
return round(self.src_width * self.pct)
return stripe_size(self.src_width, self.pct)

@property
def vertical_stripe_height(self) -> int:
return round(self.src_height * self.pct)
return stripe_size(self.src_height, self.pct)

def _left_stripe_image(self):
return self.source.crop(
Expand Down

0 comments on commit 2bc20e7

Please sign in to comment.