Skip to content

Commit 26fa83a

Browse files
authored
Merge pull request #37 from korarei/fix/div-zero
Fix: Prevent division by zero when count is 1
2 parents 5f22ed9 + 0a9b9a6 commit 26fa83a

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ AviUtl ExEdit2で画像の見た目を変えるスクリプト群.
3737

3838
## 動作確認
3939

40-
- [AviUtl ExEdit2 beta7](https://spring-fragrance.mints.ne.jp/aviutl/)
40+
- [AviUtl ExEdit2 beta30a](https://spring-fragrance.mints.ne.jp/aviutl/)
4141

4242

4343
## 導入・削除・更新
@@ -931,6 +931,9 @@ LICENSEファイルに記載.
931931

932932
## Change Log
933933

934+
- **v1.2.1**
935+
- `Tile``Repeat``Count`が1のとき表示されない問題の解決.
936+
934937
- **v1.2.0**
935938
- `Mosaic``Posterize(RGBA)``ASCII``Repeat`スクリプトを追加.
936939
- 全スクリプトに`PI` (パラメータインジェクション) 項目を追加.

scripts/@Stylize_K_template.anm2

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ local half_res = {
733733
-- Arithmetic Progression
734734
-- Offset
735735
local o = {
736-
x = offset.x * res.x / count.y,
737-
y = offset.y * res.y / count.x
736+
x = offset.x * res.x / math.max(count.y, 1),
737+
y = offset.y * res.y / math.max(count.x, 1)
738738
}
739739

740740
-- Common Difference
@@ -846,13 +846,15 @@ local a_st = math.max(tonumber(_0.st_a) or _10, 0.0) * 0.01 _10 = nil
846846
local a_ed = math.max(tonumber(_0.ed_a) or _11, 0.0) * 0.01 _11 = nil
847847
_0 = nil
848848

849-
local a_grad = a_ed - a_st
850-
local last_idx = n - 1
851-
local st, ed, step = 0, last_idx, 1
849+
local range = n - 1
850+
local st, ed, step = 0, range, 1
852851
if (composite == 0) then
853852
st, ed, step = ed, st, -1
854853
end
855854

855+
local a_grad = a_ed - a_st
856+
local a_scale = math.max(range, 1)
857+
856858
if (sync) then
857859
local s = obj.zoom * obj.getvalue("zoom") * 0.01
858860
local a, oa = obj.getvalue("aspect"), obj.aspect
@@ -868,7 +870,7 @@ end
868870

869871
obj.effect()
870872
for i = st, ed, step do
871-
local t = i / last_idx
873+
local t = i / a_scale
872874
local alpha = a_st + a_grad * t
873875
i = i + offset
874876
obj.draw(x * i, y * i, z * i, math.pow(scale, i), alpha, rx * i, ry * i, rz * i)

0 commit comments

Comments
 (0)