Skip to content

Commit

Permalink
Update 0.11.0
Browse files Browse the repository at this point in the history
Add: arc_rain()现在支持enwiden的梯形范围和自定义矩形范围
Fix: arc_rain()在末尾会多生成一条Arc
  • Loading branch information
feightwywx committed Feb 6, 2024
1 parent 9103a2c commit 051e427
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module.exports = {
{ text: '快速上手', link: '/guide/' },
{ text: 'API', link: '/api/' },
{
text: 'v0.10', items: [
{ text: 'v0.10', link: '/' }
text: 'v0.11', items: [
{ text: 'v0.11', link: '/' }
]
},
{ text: 'AFF工具箱', link: 'https://aff.arcaea.icu/' }
Expand Down
9 changes: 6 additions & 3 deletions docs/api/aff-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,13 @@ aff片段生成函数。

|参数名|类型|说明|默认值|
|--|--|--|--|
|original_t|int|下雨起始时间|
|dest_t|int|下雨结束时间|
|step|float|雨点起始点之间的间隔|
|original_t|int|下雨起始时间||
|dest_t|int|下雨结束时间||
|step|float|雨点起始点之间的间隔||
|length|float|雨点的长度,`None`则表示充满间隔|None|
|mode|Literal['s', 'e', 'eb']|梯形限制的范围,'s'为标准,'e'为enwiden,'eb'为enwiden(byd)|s|
|x_limit|Union[List[float], None]|x坐标的范围,将会覆盖梯形的左右边限制|None|
|y_limit|Union[List[float], None]|y坐标的范围,将会覆盖梯形的上下边限制|None|

### 返回值

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="arcfutil",
version="0.10.2",
version="0.11.0",
author=".direwolf",
author_email="[email protected]",
description="A Python module designed for processing Arcaea related files(.aff chart, songlist, etc.)",
Expand Down
42 changes: 34 additions & 8 deletions src/arcfutil/aff/generator/arc_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,55 @@ def arc_crease_line(
return arclist


def arc_rain(original_t: int, dest_t: int, step: float, length: float = None):
def arc_rain(original_t: int, dest_t: int, step: float, length: Union[float, None] = None, mode: Literal['s', 'e', 'eb']='s',
x_limit: Union[List[float], None] = None, y_limit: Union[List[float], None] = None):
# 考虑生成边界的左下角是坐标原点,之后再偏移
# 怎么会有人用这种办法生成范围内随机数,可拓展性也太差了吧...被几年前的自己气死.jpg
x_offset = 0
# 如果给定了x_limit,则说明不需要预置的x偏移量
if x_limit is None:
if mode == 'e' or mode == 'eb':
x_offset = 100
else:
x_offset = 50

# 这位更是
def max_x(y: int) -> int:
return int(-0.5 * y + 200)
if mode == 'e':
# 右上顶点(1.25+1,1.61)
return int(-(75/161) * y + 300)
elif mode == 'eb':
# 右上顶点(1.63+1,1.61)
return int(-(27/161) * y + 300)
else:
return int(-0.5 * y + 200)

def min_x(y: int) -> int:
return int(0.5 * y)
if mode == 'e':
# 左上顶点(-0.25+1,1.61)
return int(75/161 * y)
elif mode == 'eb':
# 左上顶点(-0.63+1,1.61)
return int(27/161 * y)
else:
return int(0.5 * y)

destgroup = NoteGroup()
if length is None:
length = step
current_time = original_t
while current_time <= dest_t:
rand_y = randint(0, 100)
rand_x = randint(min_x(rand_y), max_x(rand_y))
while current_time < dest_t:
rand_y = randint(0, 100 if mode == 's' else 161) if y_limit is None else randint(int(y_limit[0] * 100), int(y_limit[1] * 100))
rand_x = randint(min_x(rand_y), max_x(rand_y)) if x_limit is None else randint(int(x_limit[0] * 100), int(x_limit[1] * 100))
if dest_t - current_time <= length: # 如果时间不足就截断
actual_dest_t = dest_t
else:
actual_dest_t = int(current_time + length)
destgroup.append(Arc(
current_time,
actual_dest_t,
(rand_x - 50) / 100,
(rand_x - 50) / 100,
(rand_x - x_offset) / 100,
(rand_x - x_offset) / 100,
's',
rand_y / 100,
rand_y / 100,
Expand Down

0 comments on commit 051e427

Please sign in to comment.