AI: text
This commit is contained in:
@@ -243,7 +243,8 @@ func3:
|
||||
| HSV_TO_RGB LPAREN expr (COMMA expr COMMA expr)? (COMMA expr)? RPAREN # HsvToRgbFunc
|
||||
| WHERE LPAREN expr COMMA expr COMMA expr RPAREN # WhereFunc
|
||||
| OKLAB_TO_RGB LPAREN expr (COMMA expr COMMA expr)? RPAREN # OklabToRgbFunc
|
||||
| CIELAB_TO_RGB LPAREN expr (COMMA expr COMMA expr)? RPAREN # CielabToRgbFunc;
|
||||
| CIELAB_TO_RGB LPAREN expr (COMMA expr COMMA expr)? RPAREN # CielabToRgbFunc
|
||||
| TEXT_IMAGE LPAREN expr COMMA expr COMMA expr (COMMA expr)? (COMMA expr)? (COMMA expr)? (COMMA expr)? (COMMA expr)? (COMMA expr)? RPAREN # TextImageFunc;
|
||||
|
||||
func4:
|
||||
SWAP LPAREN expr COMMA expr COMMA expr COMMA expr RPAREN # SwapFunc
|
||||
@@ -431,6 +432,7 @@ RGB_TO_INT: 'rgb_to_int';
|
||||
INTERPOLATE_LINEAR: 'interpolate_linear';
|
||||
INTERPOLATE_AREA: 'interpolate_area';
|
||||
INTERPOLATE_NEAREST: 'interpolate_nearest' | 'interpolate_nearest_exact';
|
||||
TEXT_IMAGE: 'text_image';
|
||||
|
||||
IF: 'if';
|
||||
ELSE: 'else';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import time
|
||||
import sys
|
||||
import numpy as np
|
||||
import torch
|
||||
import math
|
||||
import inspect
|
||||
@@ -2034,6 +2034,223 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
|
||||
raise ValueError(f"{ctx.start.line}:{ctx.start.column}: Unknown function or variable: {func_name}")
|
||||
|
||||
def visitTextImageFunc(self, ctx):
|
||||
"""text_image(text, font, size, [max_width], [weight], [angle], [spacing], [italic], [underline])
|
||||
|
||||
Renders text to a normalised float32 2D tensor [H, W] using Pillow.
|
||||
|
||||
Args:
|
||||
text (str) : Text to render (newlines supported).
|
||||
font (str) : Font family name or absolute path to a .ttf/.otf file.
|
||||
size (int) : Font size in points.
|
||||
max_width (int) : Optional. Max canvas width in pixels; text wraps to fit.
|
||||
0 = no limit. Default: 0.
|
||||
weight (int) : Optional. Font weight integer (e.g., 100-900). Default: 400.
|
||||
angle (float) : Optional. Counter-clockwise rotation in degrees.
|
||||
Default: 0.0.
|
||||
spacing (float) : Optional. Line height multiplier (1.0 = normal).
|
||||
Default: 1.0.
|
||||
italic (bool) : Optional. Look up an italic file or variant axis.
|
||||
Default: False.
|
||||
underline (bool) : Optional. Render a clean baseline underline decoration.
|
||||
Default: False.
|
||||
|
||||
Returns:
|
||||
torch.Tensor [H, W] float32, values in where 1.0 = full ink.
|
||||
"""
|
||||
try:
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
f"{ctx.start.line}:{ctx.start.column}: "
|
||||
"text_image() requires the 'Pillow' package. "
|
||||
"Install it with: pip install Pillow"
|
||||
)
|
||||
|
||||
# --- Evaluate arguments ---
|
||||
def _to_str(v):
|
||||
if isinstance(v, str):
|
||||
return v
|
||||
if self._is_tensor(v):
|
||||
return str(v.item())
|
||||
return str(v)
|
||||
|
||||
def _to_float(v):
|
||||
if self._is_tensor(v):
|
||||
return float(v.item())
|
||||
return float(v)
|
||||
|
||||
def _to_int(v):
|
||||
if self._is_tensor(v):
|
||||
return int(v.item())
|
||||
return int(v)
|
||||
|
||||
def _to_bool(v):
|
||||
if isinstance(v, bool):
|
||||
return v
|
||||
if self._is_tensor(v):
|
||||
v = v.item()
|
||||
if isinstance(v, str):
|
||||
return v.lower() in ("true", "1", "yes")
|
||||
return bool(v)
|
||||
|
||||
text = _to_str((yield ctx.expr(0)))
|
||||
font_name = _to_str((yield ctx.expr(1)))
|
||||
size = max(1, _to_int((yield ctx.expr(2))))
|
||||
max_width = _to_int((yield ctx.expr(3))) if len(ctx.expr()) > 3 else 0
|
||||
weight_val = _to_int((yield ctx.expr(4))) if len(ctx.expr()) > 4 else 400
|
||||
angle = _to_float((yield ctx.expr(5))) if len(ctx.expr()) > 5 else 0.0
|
||||
spacing = max(0.1, _to_float((yield ctx.expr(6)))) if len(ctx.expr()) > 6 else 1.0
|
||||
is_italic = _to_bool((yield ctx.expr(7))) if len(ctx.expr()) > 7 else False
|
||||
has_ul = _to_bool((yield ctx.expr(8))) if len(ctx.expr()) > 8 else False
|
||||
|
||||
# --- Sub-bucket style mapping for fallback on static files ---
|
||||
if weight_val <= 250:
|
||||
weight_tier = "light"
|
||||
elif weight_val <= 550:
|
||||
weight_tier = "regular"
|
||||
elif weight_val <= 750:
|
||||
weight_tier = "bold"
|
||||
else:
|
||||
weight_tier = "black"
|
||||
|
||||
style_key = f"bold_italic" if (weight_tier == "bold" and is_italic) else (
|
||||
"italic" if is_italic else weight_tier)
|
||||
|
||||
# --- Load font ---
|
||||
def _load_font(name, sz, target_style, exact_weight):
|
||||
import os
|
||||
if os.path.exists(name):
|
||||
try:
|
||||
fnt = ImageFont.truetype(name, sz)
|
||||
if hasattr(fnt, "set_variation_by_axes"):
|
||||
try:
|
||||
fnt.set_variation_by_axes({"wght": exact_weight})
|
||||
except Exception:
|
||||
pass
|
||||
return fnt
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
style_suffixes = {
|
||||
"light": ["Light", "light", "-Light", "L"],
|
||||
"regular": ["", "Regular", "-Regular", "Normal", "normal"],
|
||||
"bold": ["Bold", "bold", "-Bold", "B"],
|
||||
"black": ["Black", "black", "-Black", "Heavy", "heavy"],
|
||||
"italic": ["Italic", "italic", "-Italic", "I"],
|
||||
"bold_italic": ["BoldItalic", "bolditalic", "-BoldItalic", "BI", "Bold Italic"],
|
||||
}.get(target_style, [""])
|
||||
|
||||
search_dirs = []
|
||||
import platform
|
||||
sys_platform = platform.system()
|
||||
if sys_platform == "Windows":
|
||||
search_dirs = [os.path.join(os.environ.get("WINDIR", "C:\\Windows"), "Fonts")]
|
||||
elif sys_platform == "Darwin":
|
||||
search_dirs = ["/Library/Fonts", "/System/Library/Fonts", os.path.expanduser("~/Library/Fonts")]
|
||||
else:
|
||||
search_dirs = ["/usr/share/fonts", "/usr/local/share/fonts", os.path.expanduser("~/.fonts")]
|
||||
|
||||
for directory in search_dirs:
|
||||
if not os.path.isdir(directory):
|
||||
continue
|
||||
for root, _, files in os.walk(directory):
|
||||
for fname in files:
|
||||
if not fname.lower().endswith((".ttf", ".otf")):
|
||||
continue
|
||||
base = os.path.splitext(fname)[0] # Fixed: Added [0] index
|
||||
for suf in style_suffixes:
|
||||
if base.lower() == (name.lower() + suf.lower()) or base.lower() == name.lower():
|
||||
try:
|
||||
fnt = ImageFont.truetype(os.path.join(root, fname), sz)
|
||||
if hasattr(fnt, "set_variation_by_axes"):
|
||||
try:
|
||||
fnt.set_variation_by_axes({"wght": exact_weight})
|
||||
except Exception:
|
||||
pass
|
||||
return fnt
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
raise FileNotFoundError(
|
||||
f"Could not resolve font package matching name: '{name}' "
|
||||
f"under style spectrum '{target_style}'."
|
||||
)
|
||||
font = _load_font(font_name, size, style_key, weight_val)
|
||||
|
||||
# --- Word-wrap if max_width is set ---
|
||||
def _wrap_text(text_in, fnt, max_w):
|
||||
if max_w <= 0:
|
||||
return text_in.splitlines()
|
||||
lines = []
|
||||
for paragraph in text_in.splitlines():
|
||||
words = paragraph.split(" ")
|
||||
current = ""
|
||||
for word in words:
|
||||
test = (current + " " + word).strip()
|
||||
bbox = fnt.getbbox(test)
|
||||
w = bbox[2] - bbox[0] # Fixed: Restored index positions
|
||||
if w <= max_w or not current:
|
||||
current = test
|
||||
else:
|
||||
lines.append(current)
|
||||
current = word
|
||||
lines.append(current)
|
||||
return lines
|
||||
|
||||
lines = _wrap_text(text, font, max_width)
|
||||
|
||||
# --- Measure canvas size ---
|
||||
line_heights = []
|
||||
line_widths = []
|
||||
for line in lines:
|
||||
bbox = font.getbbox(line if line else " ")
|
||||
line_widths.append(bbox[2] - bbox[0]) # Fixed: Restored index positions
|
||||
line_heights.append(bbox[3] - bbox[1]) # Fixed: Restored index positions
|
||||
|
||||
line_h = max(line_heights) if line_heights else size
|
||||
line_stride = max(1, int(line_h * spacing))
|
||||
canvas_w = max(line_widths) if line_widths else size
|
||||
canvas_h = line_stride * len(lines)
|
||||
|
||||
canvas_w = max(canvas_w, 1)
|
||||
canvas_h = max(canvas_h, 1)
|
||||
|
||||
# --- Render text ---
|
||||
img = Image.new("L", (canvas_w, canvas_h), color=0)
|
||||
draw = ImageDraw.Draw(img)
|
||||
y = 0
|
||||
|
||||
ul_thickness = max(1, int(size * 0.06))
|
||||
ul_offset = max(1, int(size * 0.08))
|
||||
|
||||
for line in lines:
|
||||
if not line:
|
||||
y += line_stride
|
||||
continue
|
||||
bbox = font.getbbox(line)
|
||||
text_w = bbox[2] - bbox[0] # Fixed: Restored index positions
|
||||
text_h = bbox[3] - bbox[1] # Fixed: Restored index positions
|
||||
|
||||
draw.text((0, y - bbox[1]), line, fill=255, font=font) # Fixed: Restored index positions
|
||||
|
||||
if has_ul:
|
||||
ul_top = y + text_h + ul_offset
|
||||
draw.rectangle(
|
||||
[0, ul_top, text_w, ul_top + ul_thickness],
|
||||
fill=255
|
||||
)
|
||||
y += line_stride
|
||||
|
||||
# --- Rotate if requested ---
|
||||
if angle != 0.0:
|
||||
img = img.rotate(angle, expand=True, fillcolor=0)
|
||||
|
||||
# --- Convert to tensor on self.device ---
|
||||
import numpy as np
|
||||
arr = np.array(img, dtype=np.float32) / 255.0
|
||||
return torch.from_numpy(arr).to(device=self.device)
|
||||
|
||||
def visitNoiseFunc(self,ctx):
|
||||
seed_val = yield ctx.expr(0)
|
||||
shape_arg = self.shape;
|
||||
@@ -4056,23 +4273,23 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
"""ridged(seed, scale, [octaves], [offset], [shape])"""
|
||||
seed_val = yield ctx.expr(0)
|
||||
seed = int(seed_val.item()) if self._is_tensor(seed_val) else int(seed_val)
|
||||
|
||||
|
||||
scale_val = yield ctx.expr(1)
|
||||
scale = float(scale_val.item()) if self._is_tensor(scale_val) else float(scale_val)
|
||||
|
||||
|
||||
octaves = 4
|
||||
expr_idx = 2
|
||||
if len(ctx.expr()) > expr_idx:
|
||||
oct_val = yield ctx.expr(expr_idx)
|
||||
octaves = int(oct_val.item()) if self._is_tensor(oct_val) else int(oct_val)
|
||||
expr_idx += 1
|
||||
|
||||
|
||||
offset = None
|
||||
if len(ctx.expr()) > expr_idx:
|
||||
offset_val = yield ctx.expr(expr_idx)
|
||||
offset = offset_val
|
||||
expr_idx += 1
|
||||
|
||||
|
||||
shape = self.shape
|
||||
if len(ctx.expr()) > expr_idx:
|
||||
shape_arg = (yield ctx.expr(expr_idx))
|
||||
@@ -4082,10 +4299,10 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
shape = tuple(int(x) for x in shape_arg)
|
||||
else:
|
||||
shape = (int(shape_arg),)
|
||||
|
||||
|
||||
if len(shape) == 0:
|
||||
return torch.tensor(0.0, device=self.device)
|
||||
|
||||
|
||||
offset_list = None
|
||||
if offset is not None:
|
||||
if self._is_tensor(offset):
|
||||
@@ -4094,7 +4311,7 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
offset_list = [float(x) for x in offset]
|
||||
else:
|
||||
offset_list = [float(offset)]
|
||||
|
||||
|
||||
# Build 1D ranges with offsets and avoid full meshgrid when some dims == 1
|
||||
ranges = [
|
||||
torch.arange(s, dtype=torch.float32, device=self.device)
|
||||
@@ -4122,41 +4339,41 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
noise = NoiseUtils.ridged_noise_nd(grids_optimized, scale, seed, self.device, octaves=octaves)
|
||||
target_shape = tuple(int(x) for x in shape)
|
||||
return noise.view(target_shape)
|
||||
|
||||
|
||||
def visitDomainWarpFunc(self, ctx):
|
||||
"""domain_warp(seed, scale, warp_scale, warp_strength, [octaves], [warp_octaves], [offset], [shape])"""
|
||||
seed_val = yield ctx.expr(0)
|
||||
seed = int(seed_val.item()) if self._is_tensor(seed_val) else int(seed_val)
|
||||
|
||||
|
||||
scale_val = yield ctx.expr(1)
|
||||
scale = float(scale_val.item()) if self._is_tensor(scale_val) else float(scale_val)
|
||||
|
||||
|
||||
warp_scale_val = yield ctx.expr(2)
|
||||
warp_scale = float(warp_scale_val.item()) if self._is_tensor(warp_scale_val) else float(warp_scale_val)
|
||||
|
||||
|
||||
warp_strength_val = yield ctx.expr(3)
|
||||
warp_strength = float(warp_strength_val.item()) if self._is_tensor(warp_strength_val) else float(warp_strength_val)
|
||||
|
||||
|
||||
octaves = 4
|
||||
warp_octaves = 2
|
||||
expr_idx = 4
|
||||
|
||||
|
||||
if len(ctx.expr()) > expr_idx:
|
||||
oct_val = yield ctx.expr(expr_idx)
|
||||
octaves = int(oct_val.item()) if self._is_tensor(oct_val) else int(oct_val)
|
||||
expr_idx += 1
|
||||
|
||||
|
||||
if len(ctx.expr()) > expr_idx:
|
||||
warp_oct_val = yield ctx.expr(expr_idx)
|
||||
warp_octaves = int(warp_oct_val.item()) if self._is_tensor(warp_oct_val) else int(warp_oct_val)
|
||||
expr_idx += 1
|
||||
|
||||
|
||||
offset = None
|
||||
if len(ctx.expr()) > expr_idx:
|
||||
offset_val = yield ctx.expr(expr_idx)
|
||||
offset = offset_val
|
||||
expr_idx += 1
|
||||
|
||||
|
||||
shape = self.shape
|
||||
if len(ctx.expr()) > expr_idx:
|
||||
shape_arg = (yield ctx.expr(expr_idx))
|
||||
@@ -4166,10 +4383,10 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
shape = tuple(int(x) for x in shape_arg)
|
||||
else:
|
||||
shape = (int(shape_arg),)
|
||||
|
||||
|
||||
if len(shape) == 0:
|
||||
return torch.tensor(0.0, device=self.device)
|
||||
|
||||
|
||||
offset_list = None
|
||||
if offset is not None:
|
||||
if self._is_tensor(offset):
|
||||
@@ -4178,7 +4395,7 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
offset_list = [float(x) for x in offset]
|
||||
else:
|
||||
offset_list = [float(offset)]
|
||||
|
||||
|
||||
# Build 1D ranges with offsets and avoid full meshgrid when some dims == 1
|
||||
ranges = [
|
||||
torch.arange(s, dtype=torch.float32, device=self.device)
|
||||
@@ -4202,7 +4419,7 @@ class UnifiedMathVisitor(MathExprVisitor):
|
||||
ranges_filtered = [ranges[i] for i in valid_indices]
|
||||
grids_filtered = torch.meshgrid(*ranges_filtered, indexing='ij')
|
||||
grids_optimized = tuple(grids_filtered)
|
||||
|
||||
|
||||
noise = NoiseUtils.domain_warp_noise_nd(
|
||||
grids_optimized,
|
||||
scale=scale,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -139,87 +139,88 @@ RGB_TO_INT=138
|
||||
INTERPOLATE_LINEAR=139
|
||||
INTERPOLATE_AREA=140
|
||||
INTERPOLATE_NEAREST=141
|
||||
IF=142
|
||||
ELSE=143
|
||||
WHILE=144
|
||||
FOR=145
|
||||
IN=146
|
||||
BREAK=147
|
||||
CONTINUE=148
|
||||
RETURN=149
|
||||
TIMESTAMP=150
|
||||
SORT=151
|
||||
ARGSORT=152
|
||||
ARGMIN=153
|
||||
ARGMAX=154
|
||||
SOFTMAX=155
|
||||
SOFTMIN=156
|
||||
UNIQUE=157
|
||||
FLIP=158
|
||||
ROLL=159
|
||||
COV=160
|
||||
CORR=161
|
||||
ENTROPY=162
|
||||
CROP=163
|
||||
NONE=164
|
||||
NOISE=165
|
||||
RAND=166
|
||||
CAUCHY=167
|
||||
EXPONENTIAL=168
|
||||
LOGNORMAL=169
|
||||
BERNOULLI=170
|
||||
POISSON=171
|
||||
GAMMADIST=172
|
||||
BETADIST=173
|
||||
LAPLACEDIST=174
|
||||
GUMBELDIST=175
|
||||
WEIBULLDIST=176
|
||||
CHI2DIST=177
|
||||
STUDENTTDIST=178
|
||||
PERLIN=179
|
||||
CELLULAR=180
|
||||
PLASMA=181
|
||||
RIDGED=182
|
||||
DOMAIN_WARP=183
|
||||
PLUS=184
|
||||
MINUS=185
|
||||
MULT=186
|
||||
DIV=187
|
||||
MOD=188
|
||||
POW=189
|
||||
LSHIFT=190
|
||||
RSHIFT=191
|
||||
GE=192
|
||||
GT=193
|
||||
LE=194
|
||||
LT=195
|
||||
EQ=196
|
||||
EQUEALS=197
|
||||
PLUS_EQ=198
|
||||
MINUS_EQ=199
|
||||
MULT_EQ=200
|
||||
DIV_EQ=201
|
||||
MOD_EQ=202
|
||||
NE=203
|
||||
PIPE=204
|
||||
LPAREN=205
|
||||
RPAREN=206
|
||||
COMMA=207
|
||||
SEMICOLON=208
|
||||
ARROW=209
|
||||
LBRACKET=210
|
||||
RBRACKET=211
|
||||
QUESTION=212
|
||||
COLON=213
|
||||
LBRACE=214
|
||||
RBRACE=215
|
||||
NUMBER=216
|
||||
CONSTANT=217
|
||||
STRING=218
|
||||
VARIABLE=219
|
||||
SL_COMMENT=220
|
||||
ML_COMMENT=221
|
||||
WS=222
|
||||
TEXT_IMAGE=142
|
||||
IF=143
|
||||
ELSE=144
|
||||
WHILE=145
|
||||
FOR=146
|
||||
IN=147
|
||||
BREAK=148
|
||||
CONTINUE=149
|
||||
RETURN=150
|
||||
TIMESTAMP=151
|
||||
SORT=152
|
||||
ARGSORT=153
|
||||
ARGMIN=154
|
||||
ARGMAX=155
|
||||
SOFTMAX=156
|
||||
SOFTMIN=157
|
||||
UNIQUE=158
|
||||
FLIP=159
|
||||
ROLL=160
|
||||
COV=161
|
||||
CORR=162
|
||||
ENTROPY=163
|
||||
CROP=164
|
||||
NONE=165
|
||||
NOISE=166
|
||||
RAND=167
|
||||
CAUCHY=168
|
||||
EXPONENTIAL=169
|
||||
LOGNORMAL=170
|
||||
BERNOULLI=171
|
||||
POISSON=172
|
||||
GAMMADIST=173
|
||||
BETADIST=174
|
||||
LAPLACEDIST=175
|
||||
GUMBELDIST=176
|
||||
WEIBULLDIST=177
|
||||
CHI2DIST=178
|
||||
STUDENTTDIST=179
|
||||
PERLIN=180
|
||||
CELLULAR=181
|
||||
PLASMA=182
|
||||
RIDGED=183
|
||||
DOMAIN_WARP=184
|
||||
PLUS=185
|
||||
MINUS=186
|
||||
MULT=187
|
||||
DIV=188
|
||||
MOD=189
|
||||
POW=190
|
||||
LSHIFT=191
|
||||
RSHIFT=192
|
||||
GE=193
|
||||
GT=194
|
||||
LE=195
|
||||
LT=196
|
||||
EQ=197
|
||||
EQUEALS=198
|
||||
PLUS_EQ=199
|
||||
MINUS_EQ=200
|
||||
MULT_EQ=201
|
||||
DIV_EQ=202
|
||||
MOD_EQ=203
|
||||
NE=204
|
||||
PIPE=205
|
||||
LPAREN=206
|
||||
RPAREN=207
|
||||
COMMA=208
|
||||
SEMICOLON=209
|
||||
ARROW=210
|
||||
LBRACKET=211
|
||||
RBRACKET=212
|
||||
QUESTION=213
|
||||
COLON=214
|
||||
LBRACE=215
|
||||
RBRACE=216
|
||||
NUMBER=217
|
||||
CONSTANT=218
|
||||
STRING=219
|
||||
VARIABLE=220
|
||||
SL_COMMENT=221
|
||||
ML_COMMENT=222
|
||||
WS=223
|
||||
'sin'=1
|
||||
'cos'=2
|
||||
'tan'=3
|
||||
@@ -333,55 +334,56 @@ WS=222
|
||||
'rgb_to_int'=138
|
||||
'interpolate_linear'=139
|
||||
'interpolate_area'=140
|
||||
'if'=142
|
||||
'else'=143
|
||||
'while'=144
|
||||
'for'=145
|
||||
'in'=146
|
||||
'break'=147
|
||||
'continue'=148
|
||||
'return'=149
|
||||
'sort'=151
|
||||
'argsort'=152
|
||||
'argmin'=153
|
||||
'argmax'=154
|
||||
'softmax'=155
|
||||
'softmin'=156
|
||||
'unique'=157
|
||||
'flip'=158
|
||||
'roll'=159
|
||||
'cov'=160
|
||||
'entropy'=162
|
||||
'crop'=163
|
||||
'+'=184
|
||||
'-'=185
|
||||
'*'=186
|
||||
'/'=187
|
||||
'%'=188
|
||||
'^'=189
|
||||
'<<'=190
|
||||
'>>'=191
|
||||
'>='=192
|
||||
'>'=193
|
||||
'<='=194
|
||||
'<'=195
|
||||
'=='=196
|
||||
'='=197
|
||||
'+='=198
|
||||
'-='=199
|
||||
'*='=200
|
||||
'/='=201
|
||||
'%='=202
|
||||
'!='=203
|
||||
'|'=204
|
||||
'('=205
|
||||
')'=206
|
||||
','=207
|
||||
';'=208
|
||||
'->'=209
|
||||
'['=210
|
||||
']'=211
|
||||
'?'=212
|
||||
':'=213
|
||||
'{'=214
|
||||
'}'=215
|
||||
'text_image'=142
|
||||
'if'=143
|
||||
'else'=144
|
||||
'while'=145
|
||||
'for'=146
|
||||
'in'=147
|
||||
'break'=148
|
||||
'continue'=149
|
||||
'return'=150
|
||||
'sort'=152
|
||||
'argsort'=153
|
||||
'argmin'=154
|
||||
'argmax'=155
|
||||
'softmax'=156
|
||||
'softmin'=157
|
||||
'unique'=158
|
||||
'flip'=159
|
||||
'roll'=160
|
||||
'cov'=161
|
||||
'entropy'=163
|
||||
'crop'=164
|
||||
'+'=185
|
||||
'-'=186
|
||||
'*'=187
|
||||
'/'=188
|
||||
'%'=189
|
||||
'^'=190
|
||||
'<<'=191
|
||||
'>>'=192
|
||||
'>='=193
|
||||
'>'=194
|
||||
'<='=195
|
||||
'<'=196
|
||||
'=='=197
|
||||
'='=198
|
||||
'+='=199
|
||||
'-='=200
|
||||
'*='=201
|
||||
'/='=202
|
||||
'%='=203
|
||||
'!='=204
|
||||
'|'=205
|
||||
'('=206
|
||||
')'=207
|
||||
','=208
|
||||
';'=209
|
||||
'->'=210
|
||||
'['=211
|
||||
']'=212
|
||||
'?'=213
|
||||
':'=214
|
||||
'{'=215
|
||||
'}'=216
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1059
-1053
File diff suppressed because it is too large
Load Diff
@@ -139,87 +139,88 @@ RGB_TO_INT=138
|
||||
INTERPOLATE_LINEAR=139
|
||||
INTERPOLATE_AREA=140
|
||||
INTERPOLATE_NEAREST=141
|
||||
IF=142
|
||||
ELSE=143
|
||||
WHILE=144
|
||||
FOR=145
|
||||
IN=146
|
||||
BREAK=147
|
||||
CONTINUE=148
|
||||
RETURN=149
|
||||
TIMESTAMP=150
|
||||
SORT=151
|
||||
ARGSORT=152
|
||||
ARGMIN=153
|
||||
ARGMAX=154
|
||||
SOFTMAX=155
|
||||
SOFTMIN=156
|
||||
UNIQUE=157
|
||||
FLIP=158
|
||||
ROLL=159
|
||||
COV=160
|
||||
CORR=161
|
||||
ENTROPY=162
|
||||
CROP=163
|
||||
NONE=164
|
||||
NOISE=165
|
||||
RAND=166
|
||||
CAUCHY=167
|
||||
EXPONENTIAL=168
|
||||
LOGNORMAL=169
|
||||
BERNOULLI=170
|
||||
POISSON=171
|
||||
GAMMADIST=172
|
||||
BETADIST=173
|
||||
LAPLACEDIST=174
|
||||
GUMBELDIST=175
|
||||
WEIBULLDIST=176
|
||||
CHI2DIST=177
|
||||
STUDENTTDIST=178
|
||||
PERLIN=179
|
||||
CELLULAR=180
|
||||
PLASMA=181
|
||||
RIDGED=182
|
||||
DOMAIN_WARP=183
|
||||
PLUS=184
|
||||
MINUS=185
|
||||
MULT=186
|
||||
DIV=187
|
||||
MOD=188
|
||||
POW=189
|
||||
LSHIFT=190
|
||||
RSHIFT=191
|
||||
GE=192
|
||||
GT=193
|
||||
LE=194
|
||||
LT=195
|
||||
EQ=196
|
||||
EQUEALS=197
|
||||
PLUS_EQ=198
|
||||
MINUS_EQ=199
|
||||
MULT_EQ=200
|
||||
DIV_EQ=201
|
||||
MOD_EQ=202
|
||||
NE=203
|
||||
PIPE=204
|
||||
LPAREN=205
|
||||
RPAREN=206
|
||||
COMMA=207
|
||||
SEMICOLON=208
|
||||
ARROW=209
|
||||
LBRACKET=210
|
||||
RBRACKET=211
|
||||
QUESTION=212
|
||||
COLON=213
|
||||
LBRACE=214
|
||||
RBRACE=215
|
||||
NUMBER=216
|
||||
CONSTANT=217
|
||||
STRING=218
|
||||
VARIABLE=219
|
||||
SL_COMMENT=220
|
||||
ML_COMMENT=221
|
||||
WS=222
|
||||
TEXT_IMAGE=142
|
||||
IF=143
|
||||
ELSE=144
|
||||
WHILE=145
|
||||
FOR=146
|
||||
IN=147
|
||||
BREAK=148
|
||||
CONTINUE=149
|
||||
RETURN=150
|
||||
TIMESTAMP=151
|
||||
SORT=152
|
||||
ARGSORT=153
|
||||
ARGMIN=154
|
||||
ARGMAX=155
|
||||
SOFTMAX=156
|
||||
SOFTMIN=157
|
||||
UNIQUE=158
|
||||
FLIP=159
|
||||
ROLL=160
|
||||
COV=161
|
||||
CORR=162
|
||||
ENTROPY=163
|
||||
CROP=164
|
||||
NONE=165
|
||||
NOISE=166
|
||||
RAND=167
|
||||
CAUCHY=168
|
||||
EXPONENTIAL=169
|
||||
LOGNORMAL=170
|
||||
BERNOULLI=171
|
||||
POISSON=172
|
||||
GAMMADIST=173
|
||||
BETADIST=174
|
||||
LAPLACEDIST=175
|
||||
GUMBELDIST=176
|
||||
WEIBULLDIST=177
|
||||
CHI2DIST=178
|
||||
STUDENTTDIST=179
|
||||
PERLIN=180
|
||||
CELLULAR=181
|
||||
PLASMA=182
|
||||
RIDGED=183
|
||||
DOMAIN_WARP=184
|
||||
PLUS=185
|
||||
MINUS=186
|
||||
MULT=187
|
||||
DIV=188
|
||||
MOD=189
|
||||
POW=190
|
||||
LSHIFT=191
|
||||
RSHIFT=192
|
||||
GE=193
|
||||
GT=194
|
||||
LE=195
|
||||
LT=196
|
||||
EQ=197
|
||||
EQUEALS=198
|
||||
PLUS_EQ=199
|
||||
MINUS_EQ=200
|
||||
MULT_EQ=201
|
||||
DIV_EQ=202
|
||||
MOD_EQ=203
|
||||
NE=204
|
||||
PIPE=205
|
||||
LPAREN=206
|
||||
RPAREN=207
|
||||
COMMA=208
|
||||
SEMICOLON=209
|
||||
ARROW=210
|
||||
LBRACKET=211
|
||||
RBRACKET=212
|
||||
QUESTION=213
|
||||
COLON=214
|
||||
LBRACE=215
|
||||
RBRACE=216
|
||||
NUMBER=217
|
||||
CONSTANT=218
|
||||
STRING=219
|
||||
VARIABLE=220
|
||||
SL_COMMENT=221
|
||||
ML_COMMENT=222
|
||||
WS=223
|
||||
'sin'=1
|
||||
'cos'=2
|
||||
'tan'=3
|
||||
@@ -333,55 +334,56 @@ WS=222
|
||||
'rgb_to_int'=138
|
||||
'interpolate_linear'=139
|
||||
'interpolate_area'=140
|
||||
'if'=142
|
||||
'else'=143
|
||||
'while'=144
|
||||
'for'=145
|
||||
'in'=146
|
||||
'break'=147
|
||||
'continue'=148
|
||||
'return'=149
|
||||
'sort'=151
|
||||
'argsort'=152
|
||||
'argmin'=153
|
||||
'argmax'=154
|
||||
'softmax'=155
|
||||
'softmin'=156
|
||||
'unique'=157
|
||||
'flip'=158
|
||||
'roll'=159
|
||||
'cov'=160
|
||||
'entropy'=162
|
||||
'crop'=163
|
||||
'+'=184
|
||||
'-'=185
|
||||
'*'=186
|
||||
'/'=187
|
||||
'%'=188
|
||||
'^'=189
|
||||
'<<'=190
|
||||
'>>'=191
|
||||
'>='=192
|
||||
'>'=193
|
||||
'<='=194
|
||||
'<'=195
|
||||
'=='=196
|
||||
'='=197
|
||||
'+='=198
|
||||
'-='=199
|
||||
'*='=200
|
||||
'/='=201
|
||||
'%='=202
|
||||
'!='=203
|
||||
'|'=204
|
||||
'('=205
|
||||
')'=206
|
||||
','=207
|
||||
';'=208
|
||||
'->'=209
|
||||
'['=210
|
||||
']'=211
|
||||
'?'=212
|
||||
':'=213
|
||||
'{'=214
|
||||
'}'=215
|
||||
'text_image'=142
|
||||
'if'=143
|
||||
'else'=144
|
||||
'while'=145
|
||||
'for'=146
|
||||
'in'=147
|
||||
'break'=148
|
||||
'continue'=149
|
||||
'return'=150
|
||||
'sort'=152
|
||||
'argsort'=153
|
||||
'argmin'=154
|
||||
'argmax'=155
|
||||
'softmax'=156
|
||||
'softmin'=157
|
||||
'unique'=158
|
||||
'flip'=159
|
||||
'roll'=160
|
||||
'cov'=161
|
||||
'entropy'=163
|
||||
'crop'=164
|
||||
'+'=185
|
||||
'-'=186
|
||||
'*'=187
|
||||
'/'=188
|
||||
'%'=189
|
||||
'^'=190
|
||||
'<<'=191
|
||||
'>>'=192
|
||||
'>='=193
|
||||
'>'=194
|
||||
'<='=195
|
||||
'<'=196
|
||||
'=='=197
|
||||
'='=198
|
||||
'+='=199
|
||||
'-='=200
|
||||
'*='=201
|
||||
'/='=202
|
||||
'%='=203
|
||||
'!='=204
|
||||
'|'=205
|
||||
'('=206
|
||||
')'=207
|
||||
','=208
|
||||
';'=209
|
||||
'->'=210
|
||||
'['=211
|
||||
']'=212
|
||||
'?'=213
|
||||
':'=214
|
||||
'{'=215
|
||||
'}'=216
|
||||
|
||||
@@ -1871,6 +1871,15 @@ class MathExprListener(ParseTreeListener):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by MathExprParser#TextImageFunc.
|
||||
def enterTextImageFunc(self, ctx:MathExprParser.TextImageFuncContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by MathExprParser#TextImageFunc.
|
||||
def exitTextImageFunc(self, ctx:MathExprParser.TextImageFuncContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by MathExprParser#SwapFunc.
|
||||
def enterSwapFunc(self, ctx:MathExprParser.SwapFuncContext):
|
||||
pass
|
||||
|
||||
+1356
-1220
File diff suppressed because it is too large
Load Diff
@@ -1044,6 +1044,11 @@ class MathExprVisitor(ParseTreeVisitor):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#TextImageFunc.
|
||||
def visitTextImageFunc(self, ctx:MathExprParser.TextImageFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#SwapFunc.
|
||||
def visitSwapFunc(self, ctx:MathExprParser.SwapFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
@@ -6,5 +6,5 @@ INBUILT_CONSTANTS = {
|
||||
'e', 'pi'
|
||||
}
|
||||
INBUILT_FUNCTIONS = {
|
||||
'abs', 'acos', 'acosh', 'all', 'angle', 'any', 'append', 'argmax', 'argmin', 'argsort', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'band', 'batch_shuffle', 'bitcount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blur', 'bnot', 'bor', 'botk', 'botk_ind', 'botk_indices', 'bxor', 'cat', 'ceil', 'cellular', 'cellular_noise', 'cielab_to_rgb', 'clamp', 'cnt', 'concat', 'concatenate', 'conv', 'convolution', 'corr', 'correlation', 'cos', 'cosh', 'cosine_similarity', 'cossim', 'count', 'cov', 'crop', 'cross', 'cubic', 'cubic_ease', 'cumprod', 'cumsum', 'dilate', 'dist', 'distance', 'domain_warp', 'domain_warp_noise', 'dot', 'edge', 'elastic', 'elastic_ease', 'entropy', 'erf', 'erfinv', 'erode', 'exp', 'ezconv', 'ezconvolution', 'fft', 'find', 'flatten', 'flip', 'float', 'floor', 'flow_ang', 'flow_angle', 'flow_apply', 'flow_mag', 'flow_magnitude', 'flow_to_image', 'fract', 'gamma', 'gaussian', 'gelu', 'get_value', 'hist', 'histogram', 'hsv_to_rgb', 'ifft', 'int', 'int_to_rgb', 'interpolate_area', 'interpolate_linear', 'interpolate_nearest', 'interpolate_nearest_exact', 'join', 'length', 'lerp', 'linspace', 'ln', 'log', 'logspace', 'lower', 'map', 'matmul', 'mean', 'median', 'mode', 'moment', 'morph_close', 'morph_open', 'motion_mask', 'nan_to_num', 'noise', 'now', 'nvl', 'oklab_to_rgb', 'overlay', 'pad', 'percentile', 'perlin', 'perlin_noise', 'perm', 'permute', 'pinv', 'plasma', 'plasma_noise', 'popcnt', 'popcount', 'pow', 'prcnt', 'print', 'print_shape', 'pshp', 'quantile', 'quartil', 'quartile', 'rand', 'randb', 'randbeta', 'randc', 'rande', 'randg', 'randgumbel', 'randchi2', 'randl', 'randln', 'randn', 'random_bernoulli', 'random_beta', 'random_cauchy', 'random_exponential', 'random_gamma', 'random_gumbel', 'random_chi2', 'random_laplace', 'random_log_normal', 'random_normal', 'random_poisson', 'random_studentt', 'random_uniform', 'random_weibull', 'randp', 'randt', 'randu', 'randw', 'range', 'relu', 'remap', 'replace', 'reshape', 'rgb_to_cielab', 'rgb_to_hsv', 'rgb_to_int', 'rgb_to_oklab', 'ridged', 'ridged_noise', 'rife', 'roll', 'round', 'rshp', 'select', 'shape', 'shuffle', 'sigm', 'sign', 'sin', 'sine', 'sine_ease', 'sinh', 'smax', 'smin', 'smootherstep', 'smoothstep', 'snorm', 'softmax', 'softmin', 'softplus', 'sort', 'split', 'sqrt', 'stack_clear', 'stack_get', 'stack_has', 'stack_pop', 'stack_push', 'std', 'step', 'substr', 'substring', 'sum', 'swap', 'tan', 'tanh', 'tensor', 'timestamp', 'tmax', 'tmin', 'tnorm', 'topk', 'topk_ind', 'topk_indices', 'trim', 'turbulence', 'unique', 'upper', 'var', 'voronoi', 'voronoi_noise', 'where', 'worley'
|
||||
'abs', 'acos', 'acosh', 'all', 'angle', 'any', 'append', 'argmax', 'argmin', 'argsort', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'band', 'batch_shuffle', 'bitcount', 'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blur', 'bnot', 'bor', 'botk', 'botk_ind', 'botk_indices', 'bxor', 'cat', 'ceil', 'cellular', 'cellular_noise', 'cielab_to_rgb', 'clamp', 'cnt', 'concat', 'concatenate', 'conv', 'convolution', 'corr', 'correlation', 'cos', 'cosh', 'cosine_similarity', 'cossim', 'count', 'cov', 'crop', 'cross', 'cubic', 'cubic_ease', 'cumprod', 'cumsum', 'dilate', 'dist', 'distance', 'domain_warp', 'domain_warp_noise', 'dot', 'edge', 'elastic', 'elastic_ease', 'entropy', 'erf', 'erfinv', 'erode', 'exp', 'ezconv', 'ezconvolution', 'fft', 'find', 'flatten', 'flip', 'float', 'floor', 'flow_ang', 'flow_angle', 'flow_apply', 'flow_mag', 'flow_magnitude', 'flow_to_image', 'fract', 'gamma', 'gaussian', 'gelu', 'get_value', 'hist', 'histogram', 'hsv_to_rgb', 'ifft', 'int', 'int_to_rgb', 'interpolate_area', 'interpolate_linear', 'interpolate_nearest', 'interpolate_nearest_exact', 'join', 'length', 'lerp', 'linspace', 'ln', 'log', 'logspace', 'lower', 'map', 'matmul', 'mean', 'median', 'mode', 'moment', 'morph_close', 'morph_open', 'motion_mask', 'nan_to_num', 'noise', 'now', 'nvl', 'oklab_to_rgb', 'overlay', 'pad', 'percentile', 'perlin', 'perlin_noise', 'perm', 'permute', 'pinv', 'plasma', 'plasma_noise', 'popcnt', 'popcount', 'pow', 'prcnt', 'print', 'print_shape', 'pshp', 'quantile', 'quartil', 'quartile', 'rand', 'randb', 'randbeta', 'randc', 'rande', 'randg', 'randgumbel', 'randchi2', 'randl', 'randln', 'randn', 'random_bernoulli', 'random_beta', 'random_cauchy', 'random_exponential', 'random_gamma', 'random_gumbel', 'random_chi2', 'random_laplace', 'random_log_normal', 'random_normal', 'random_poisson', 'random_studentt', 'random_uniform', 'random_weibull', 'randp', 'randt', 'randu', 'randw', 'range', 'relu', 'remap', 'replace', 'reshape', 'rgb_to_cielab', 'rgb_to_hsv', 'rgb_to_int', 'rgb_to_oklab', 'ridged', 'ridged_noise', 'rife', 'roll', 'round', 'rshp', 'select', 'shape', 'shuffle', 'sigm', 'sign', 'sin', 'sine', 'sine_ease', 'sinh', 'smax', 'smin', 'smootherstep', 'smoothstep', 'snorm', 'softmax', 'softmin', 'softplus', 'sort', 'split', 'sqrt', 'stack_clear', 'stack_get', 'stack_has', 'stack_pop', 'stack_push', 'std', 'step', 'substr', 'substring', 'sum', 'swap', 'tan', 'tanh', 'tensor', 'text_image', 'timestamp', 'tmax', 'tmin', 'tnorm', 'topk', 'topk_ind', 'topk_indices', 'trim', 'turbulence', 'unique', 'upper', 'var', 'voronoi', 'voronoi_noise', 'where', 'worley'
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -139,87 +139,88 @@ RGB_TO_INT=138
|
||||
INTERPOLATE_LINEAR=139
|
||||
INTERPOLATE_AREA=140
|
||||
INTERPOLATE_NEAREST=141
|
||||
IF=142
|
||||
ELSE=143
|
||||
WHILE=144
|
||||
FOR=145
|
||||
IN=146
|
||||
BREAK=147
|
||||
CONTINUE=148
|
||||
RETURN=149
|
||||
TIMESTAMP=150
|
||||
SORT=151
|
||||
ARGSORT=152
|
||||
ARGMIN=153
|
||||
ARGMAX=154
|
||||
SOFTMAX=155
|
||||
SOFTMIN=156
|
||||
UNIQUE=157
|
||||
FLIP=158
|
||||
ROLL=159
|
||||
COV=160
|
||||
CORR=161
|
||||
ENTROPY=162
|
||||
CROP=163
|
||||
NONE=164
|
||||
NOISE=165
|
||||
RAND=166
|
||||
CAUCHY=167
|
||||
EXPONENTIAL=168
|
||||
LOGNORMAL=169
|
||||
BERNOULLI=170
|
||||
POISSON=171
|
||||
GAMMADIST=172
|
||||
BETADIST=173
|
||||
LAPLACEDIST=174
|
||||
GUMBELDIST=175
|
||||
WEIBULLDIST=176
|
||||
CHI2DIST=177
|
||||
STUDENTTDIST=178
|
||||
PERLIN=179
|
||||
CELLULAR=180
|
||||
PLASMA=181
|
||||
RIDGED=182
|
||||
DOMAIN_WARP=183
|
||||
PLUS=184
|
||||
MINUS=185
|
||||
MULT=186
|
||||
DIV=187
|
||||
MOD=188
|
||||
POW=189
|
||||
LSHIFT=190
|
||||
RSHIFT=191
|
||||
GE=192
|
||||
GT=193
|
||||
LE=194
|
||||
LT=195
|
||||
EQ=196
|
||||
EQUEALS=197
|
||||
PLUS_EQ=198
|
||||
MINUS_EQ=199
|
||||
MULT_EQ=200
|
||||
DIV_EQ=201
|
||||
MOD_EQ=202
|
||||
NE=203
|
||||
PIPE=204
|
||||
LPAREN=205
|
||||
RPAREN=206
|
||||
COMMA=207
|
||||
SEMICOLON=208
|
||||
ARROW=209
|
||||
LBRACKET=210
|
||||
RBRACKET=211
|
||||
QUESTION=212
|
||||
COLON=213
|
||||
LBRACE=214
|
||||
RBRACE=215
|
||||
NUMBER=216
|
||||
CONSTANT=217
|
||||
STRING=218
|
||||
VARIABLE=219
|
||||
SL_COMMENT=220
|
||||
ML_COMMENT=221
|
||||
WS=222
|
||||
TEXT_IMAGE=142
|
||||
IF=143
|
||||
ELSE=144
|
||||
WHILE=145
|
||||
FOR=146
|
||||
IN=147
|
||||
BREAK=148
|
||||
CONTINUE=149
|
||||
RETURN=150
|
||||
TIMESTAMP=151
|
||||
SORT=152
|
||||
ARGSORT=153
|
||||
ARGMIN=154
|
||||
ARGMAX=155
|
||||
SOFTMAX=156
|
||||
SOFTMIN=157
|
||||
UNIQUE=158
|
||||
FLIP=159
|
||||
ROLL=160
|
||||
COV=161
|
||||
CORR=162
|
||||
ENTROPY=163
|
||||
CROP=164
|
||||
NONE=165
|
||||
NOISE=166
|
||||
RAND=167
|
||||
CAUCHY=168
|
||||
EXPONENTIAL=169
|
||||
LOGNORMAL=170
|
||||
BERNOULLI=171
|
||||
POISSON=172
|
||||
GAMMADIST=173
|
||||
BETADIST=174
|
||||
LAPLACEDIST=175
|
||||
GUMBELDIST=176
|
||||
WEIBULLDIST=177
|
||||
CHI2DIST=178
|
||||
STUDENTTDIST=179
|
||||
PERLIN=180
|
||||
CELLULAR=181
|
||||
PLASMA=182
|
||||
RIDGED=183
|
||||
DOMAIN_WARP=184
|
||||
PLUS=185
|
||||
MINUS=186
|
||||
MULT=187
|
||||
DIV=188
|
||||
MOD=189
|
||||
POW=190
|
||||
LSHIFT=191
|
||||
RSHIFT=192
|
||||
GE=193
|
||||
GT=194
|
||||
LE=195
|
||||
LT=196
|
||||
EQ=197
|
||||
EQUEALS=198
|
||||
PLUS_EQ=199
|
||||
MINUS_EQ=200
|
||||
MULT_EQ=201
|
||||
DIV_EQ=202
|
||||
MOD_EQ=203
|
||||
NE=204
|
||||
PIPE=205
|
||||
LPAREN=206
|
||||
RPAREN=207
|
||||
COMMA=208
|
||||
SEMICOLON=209
|
||||
ARROW=210
|
||||
LBRACKET=211
|
||||
RBRACKET=212
|
||||
QUESTION=213
|
||||
COLON=214
|
||||
LBRACE=215
|
||||
RBRACE=216
|
||||
NUMBER=217
|
||||
CONSTANT=218
|
||||
STRING=219
|
||||
VARIABLE=220
|
||||
SL_COMMENT=221
|
||||
ML_COMMENT=222
|
||||
WS=223
|
||||
'sin'=1
|
||||
'cos'=2
|
||||
'tan'=3
|
||||
@@ -333,55 +334,56 @@ WS=222
|
||||
'rgb_to_int'=138
|
||||
'interpolate_linear'=139
|
||||
'interpolate_area'=140
|
||||
'if'=142
|
||||
'else'=143
|
||||
'while'=144
|
||||
'for'=145
|
||||
'in'=146
|
||||
'break'=147
|
||||
'continue'=148
|
||||
'return'=149
|
||||
'sort'=151
|
||||
'argsort'=152
|
||||
'argmin'=153
|
||||
'argmax'=154
|
||||
'softmax'=155
|
||||
'softmin'=156
|
||||
'unique'=157
|
||||
'flip'=158
|
||||
'roll'=159
|
||||
'cov'=160
|
||||
'entropy'=162
|
||||
'crop'=163
|
||||
'+'=184
|
||||
'-'=185
|
||||
'*'=186
|
||||
'/'=187
|
||||
'%'=188
|
||||
'^'=189
|
||||
'<<'=190
|
||||
'>>'=191
|
||||
'>='=192
|
||||
'>'=193
|
||||
'<='=194
|
||||
'<'=195
|
||||
'=='=196
|
||||
'='=197
|
||||
'+='=198
|
||||
'-='=199
|
||||
'*='=200
|
||||
'/='=201
|
||||
'%='=202
|
||||
'!='=203
|
||||
'|'=204
|
||||
'('=205
|
||||
')'=206
|
||||
','=207
|
||||
';'=208
|
||||
'->'=209
|
||||
'['=210
|
||||
']'=211
|
||||
'?'=212
|
||||
':'=213
|
||||
'{'=214
|
||||
'}'=215
|
||||
'text_image'=142
|
||||
'if'=143
|
||||
'else'=144
|
||||
'while'=145
|
||||
'for'=146
|
||||
'in'=147
|
||||
'break'=148
|
||||
'continue'=149
|
||||
'return'=150
|
||||
'sort'=152
|
||||
'argsort'=153
|
||||
'argmin'=154
|
||||
'argmax'=155
|
||||
'softmax'=156
|
||||
'softmin'=157
|
||||
'unique'=158
|
||||
'flip'=159
|
||||
'roll'=160
|
||||
'cov'=161
|
||||
'entropy'=163
|
||||
'crop'=164
|
||||
'+'=185
|
||||
'-'=186
|
||||
'*'=187
|
||||
'/'=188
|
||||
'%'=189
|
||||
'^'=190
|
||||
'<<'=191
|
||||
'>>'=192
|
||||
'>='=193
|
||||
'>'=194
|
||||
'<='=195
|
||||
'<'=196
|
||||
'=='=197
|
||||
'='=198
|
||||
'+='=199
|
||||
'-='=200
|
||||
'*='=201
|
||||
'/='=202
|
||||
'%='=203
|
||||
'!='=204
|
||||
'|'=205
|
||||
'('=206
|
||||
')'=207
|
||||
','=208
|
||||
';'=209
|
||||
'->'=210
|
||||
'['=211
|
||||
']'=212
|
||||
'?'=213
|
||||
':'=214
|
||||
'{'=215
|
||||
'}'=216
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1227
-1220
File diff suppressed because it is too large
Load Diff
@@ -139,87 +139,88 @@ RGB_TO_INT=138
|
||||
INTERPOLATE_LINEAR=139
|
||||
INTERPOLATE_AREA=140
|
||||
INTERPOLATE_NEAREST=141
|
||||
IF=142
|
||||
ELSE=143
|
||||
WHILE=144
|
||||
FOR=145
|
||||
IN=146
|
||||
BREAK=147
|
||||
CONTINUE=148
|
||||
RETURN=149
|
||||
TIMESTAMP=150
|
||||
SORT=151
|
||||
ARGSORT=152
|
||||
ARGMIN=153
|
||||
ARGMAX=154
|
||||
SOFTMAX=155
|
||||
SOFTMIN=156
|
||||
UNIQUE=157
|
||||
FLIP=158
|
||||
ROLL=159
|
||||
COV=160
|
||||
CORR=161
|
||||
ENTROPY=162
|
||||
CROP=163
|
||||
NONE=164
|
||||
NOISE=165
|
||||
RAND=166
|
||||
CAUCHY=167
|
||||
EXPONENTIAL=168
|
||||
LOGNORMAL=169
|
||||
BERNOULLI=170
|
||||
POISSON=171
|
||||
GAMMADIST=172
|
||||
BETADIST=173
|
||||
LAPLACEDIST=174
|
||||
GUMBELDIST=175
|
||||
WEIBULLDIST=176
|
||||
CHI2DIST=177
|
||||
STUDENTTDIST=178
|
||||
PERLIN=179
|
||||
CELLULAR=180
|
||||
PLASMA=181
|
||||
RIDGED=182
|
||||
DOMAIN_WARP=183
|
||||
PLUS=184
|
||||
MINUS=185
|
||||
MULT=186
|
||||
DIV=187
|
||||
MOD=188
|
||||
POW=189
|
||||
LSHIFT=190
|
||||
RSHIFT=191
|
||||
GE=192
|
||||
GT=193
|
||||
LE=194
|
||||
LT=195
|
||||
EQ=196
|
||||
EQUEALS=197
|
||||
PLUS_EQ=198
|
||||
MINUS_EQ=199
|
||||
MULT_EQ=200
|
||||
DIV_EQ=201
|
||||
MOD_EQ=202
|
||||
NE=203
|
||||
PIPE=204
|
||||
LPAREN=205
|
||||
RPAREN=206
|
||||
COMMA=207
|
||||
SEMICOLON=208
|
||||
ARROW=209
|
||||
LBRACKET=210
|
||||
RBRACKET=211
|
||||
QUESTION=212
|
||||
COLON=213
|
||||
LBRACE=214
|
||||
RBRACE=215
|
||||
NUMBER=216
|
||||
CONSTANT=217
|
||||
STRING=218
|
||||
VARIABLE=219
|
||||
SL_COMMENT=220
|
||||
ML_COMMENT=221
|
||||
WS=222
|
||||
TEXT_IMAGE=142
|
||||
IF=143
|
||||
ELSE=144
|
||||
WHILE=145
|
||||
FOR=146
|
||||
IN=147
|
||||
BREAK=148
|
||||
CONTINUE=149
|
||||
RETURN=150
|
||||
TIMESTAMP=151
|
||||
SORT=152
|
||||
ARGSORT=153
|
||||
ARGMIN=154
|
||||
ARGMAX=155
|
||||
SOFTMAX=156
|
||||
SOFTMIN=157
|
||||
UNIQUE=158
|
||||
FLIP=159
|
||||
ROLL=160
|
||||
COV=161
|
||||
CORR=162
|
||||
ENTROPY=163
|
||||
CROP=164
|
||||
NONE=165
|
||||
NOISE=166
|
||||
RAND=167
|
||||
CAUCHY=168
|
||||
EXPONENTIAL=169
|
||||
LOGNORMAL=170
|
||||
BERNOULLI=171
|
||||
POISSON=172
|
||||
GAMMADIST=173
|
||||
BETADIST=174
|
||||
LAPLACEDIST=175
|
||||
GUMBELDIST=176
|
||||
WEIBULLDIST=177
|
||||
CHI2DIST=178
|
||||
STUDENTTDIST=179
|
||||
PERLIN=180
|
||||
CELLULAR=181
|
||||
PLASMA=182
|
||||
RIDGED=183
|
||||
DOMAIN_WARP=184
|
||||
PLUS=185
|
||||
MINUS=186
|
||||
MULT=187
|
||||
DIV=188
|
||||
MOD=189
|
||||
POW=190
|
||||
LSHIFT=191
|
||||
RSHIFT=192
|
||||
GE=193
|
||||
GT=194
|
||||
LE=195
|
||||
LT=196
|
||||
EQ=197
|
||||
EQUEALS=198
|
||||
PLUS_EQ=199
|
||||
MINUS_EQ=200
|
||||
MULT_EQ=201
|
||||
DIV_EQ=202
|
||||
MOD_EQ=203
|
||||
NE=204
|
||||
PIPE=205
|
||||
LPAREN=206
|
||||
RPAREN=207
|
||||
COMMA=208
|
||||
SEMICOLON=209
|
||||
ARROW=210
|
||||
LBRACKET=211
|
||||
RBRACKET=212
|
||||
QUESTION=213
|
||||
COLON=214
|
||||
LBRACE=215
|
||||
RBRACE=216
|
||||
NUMBER=217
|
||||
CONSTANT=218
|
||||
STRING=219
|
||||
VARIABLE=220
|
||||
SL_COMMENT=221
|
||||
ML_COMMENT=222
|
||||
WS=223
|
||||
'sin'=1
|
||||
'cos'=2
|
||||
'tan'=3
|
||||
@@ -333,55 +334,56 @@ WS=222
|
||||
'rgb_to_int'=138
|
||||
'interpolate_linear'=139
|
||||
'interpolate_area'=140
|
||||
'if'=142
|
||||
'else'=143
|
||||
'while'=144
|
||||
'for'=145
|
||||
'in'=146
|
||||
'break'=147
|
||||
'continue'=148
|
||||
'return'=149
|
||||
'sort'=151
|
||||
'argsort'=152
|
||||
'argmin'=153
|
||||
'argmax'=154
|
||||
'softmax'=155
|
||||
'softmin'=156
|
||||
'unique'=157
|
||||
'flip'=158
|
||||
'roll'=159
|
||||
'cov'=160
|
||||
'entropy'=162
|
||||
'crop'=163
|
||||
'+'=184
|
||||
'-'=185
|
||||
'*'=186
|
||||
'/'=187
|
||||
'%'=188
|
||||
'^'=189
|
||||
'<<'=190
|
||||
'>>'=191
|
||||
'>='=192
|
||||
'>'=193
|
||||
'<='=194
|
||||
'<'=195
|
||||
'=='=196
|
||||
'='=197
|
||||
'+='=198
|
||||
'-='=199
|
||||
'*='=200
|
||||
'/='=201
|
||||
'%='=202
|
||||
'!='=203
|
||||
'|'=204
|
||||
'('=205
|
||||
')'=206
|
||||
','=207
|
||||
';'=208
|
||||
'->'=209
|
||||
'['=210
|
||||
']'=211
|
||||
'?'=212
|
||||
':'=213
|
||||
'{'=214
|
||||
'}'=215
|
||||
'text_image'=142
|
||||
'if'=143
|
||||
'else'=144
|
||||
'while'=145
|
||||
'for'=146
|
||||
'in'=147
|
||||
'break'=148
|
||||
'continue'=149
|
||||
'return'=150
|
||||
'sort'=152
|
||||
'argsort'=153
|
||||
'argmin'=154
|
||||
'argmax'=155
|
||||
'softmax'=156
|
||||
'softmin'=157
|
||||
'unique'=158
|
||||
'flip'=159
|
||||
'roll'=160
|
||||
'cov'=161
|
||||
'entropy'=163
|
||||
'crop'=164
|
||||
'+'=185
|
||||
'-'=186
|
||||
'*'=187
|
||||
'/'=188
|
||||
'%'=189
|
||||
'^'=190
|
||||
'<<'=191
|
||||
'>>'=192
|
||||
'>='=193
|
||||
'>'=194
|
||||
'<='=195
|
||||
'<'=196
|
||||
'=='=197
|
||||
'='=198
|
||||
'+='=199
|
||||
'-='=200
|
||||
'*='=201
|
||||
'/='=202
|
||||
'%='=203
|
||||
'!='=204
|
||||
'|'=205
|
||||
'('=206
|
||||
')'=207
|
||||
','=208
|
||||
';'=209
|
||||
'->'=210
|
||||
'['=211
|
||||
']'=212
|
||||
'?'=213
|
||||
':'=214
|
||||
'{'=215
|
||||
'}'=216
|
||||
|
||||
@@ -1871,6 +1871,15 @@ class MathExprListener(ParseTreeListener):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by MathExprParser#TextImageFunc.
|
||||
def enterTextImageFunc(self, ctx:MathExprParser.TextImageFuncContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by MathExprParser#TextImageFunc.
|
||||
def exitTextImageFunc(self, ctx:MathExprParser.TextImageFuncContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by MathExprParser#SwapFunc.
|
||||
def enterSwapFunc(self, ctx:MathExprParser.SwapFuncContext):
|
||||
pass
|
||||
|
||||
+1451
-1310
File diff suppressed because one or more lines are too long
@@ -1044,6 +1044,11 @@ class MathExprVisitor(ParseTreeVisitor):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#TextImageFunc.
|
||||
def visitTextImageFunc(self, ctx:MathExprParser.TextImageFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#SwapFunc.
|
||||
def visitSwapFunc(self, ctx:MathExprParser.SwapFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
@@ -9,5 +9,5 @@ export const CONSTANTS = new Set([
|
||||
]);
|
||||
|
||||
export const FUNCTIONS = new Set([
|
||||
"abs", "acos", "acosh", "all", "angle", "any", "append", "argmax", "argmin", "argsort", "asin", "asinh", "atan", "atan2", "atanh", "band", "batch_shuffle", "bitcount", "bitwise_and", "bitwise_not", "bitwise_or", "bitwise_xor", "blur", "bnot", "bor", "botk", "botk_ind", "botk_indices", "bxor", "cat", "ceil", "cellular", "cellular_noise", "cielab_to_rgb", "clamp", "cnt", "concat", "concatenate", "conv", "convolution", "corr", "correlation", "cos", "cosh", "cosine_similarity", "cossim", "count", "cov", "crop", "cross", "cubic", "cubic_ease", "cumprod", "cumsum", "dilate", "dist", "distance", "domain_warp", "domain_warp_noise", "dot", "edge", "elastic", "elastic_ease", "entropy", "erf", "erfinv", "erode", "exp", "ezconv", "ezconvolution", "fft", "find", "flatten", "flip", "float", "floor", "flow_ang", "flow_angle", "flow_apply", "flow_mag", "flow_magnitude", "flow_to_image", "fract", "gamma", "gaussian", "gelu", "get_value", "hist", "histogram", "hsv_to_rgb", "ifft", "int", "int_to_rgb", "interpolate_area", "interpolate_linear", "interpolate_nearest", "interpolate_nearest_exact", "join", "length", "lerp", "linspace", "ln", "log", "logspace", "lower", "map", "matmul", "mean", "median", "mode", "moment", "morph_close", "morph_open", "motion_mask", "nan_to_num", "noise", "now", "nvl", "oklab_to_rgb", "overlay", "pad", "percentile", "perlin", "perlin_noise", "perm", "permute", "pinv", "plasma", "plasma_noise", "popcnt", "popcount", "pow", "prcnt", "print", "print_shape", "pshp", "quantile", "quartil", "quartile", "rand", "randb", "randbeta", "randc", "rande", "randg", "randgumbel", "randchi2", "randl", "randln", "randn", "random_bernoulli", "random_beta", "random_cauchy", "random_exponential", "random_gamma", "random_gumbel", "random_chi2", "random_laplace", "random_log_normal", "random_normal", "random_poisson", "random_studentt", "random_uniform", "random_weibull", "randp", "randt", "randu", "randw", "range", "relu", "remap", "replace", "reshape", "rgb_to_cielab", "rgb_to_hsv", "rgb_to_int", "rgb_to_oklab", "ridged", "ridged_noise", "rife", "roll", "round", "rshp", "select", "shape", "shuffle", "sigm", "sign", "sin", "sine", "sine_ease", "sinh", "smax", "smin", "smootherstep", "smoothstep", "snorm", "softmax", "softmin", "softplus", "sort", "split", "sqrt", "stack_clear", "stack_get", "stack_has", "stack_pop", "stack_push", "std", "step", "substr", "substring", "sum", "swap", "tan", "tanh", "tensor", "timestamp", "tmax", "tmin", "tnorm", "topk", "topk_ind", "topk_indices", "trim", "turbulence", "unique", "upper", "var", "voronoi", "voronoi_noise", "where", "worley"
|
||||
"abs", "acos", "acosh", "all", "angle", "any", "append", "argmax", "argmin", "argsort", "asin", "asinh", "atan", "atan2", "atanh", "band", "batch_shuffle", "bitcount", "bitwise_and", "bitwise_not", "bitwise_or", "bitwise_xor", "blur", "bnot", "bor", "botk", "botk_ind", "botk_indices", "bxor", "cat", "ceil", "cellular", "cellular_noise", "cielab_to_rgb", "clamp", "cnt", "concat", "concatenate", "conv", "convolution", "corr", "correlation", "cos", "cosh", "cosine_similarity", "cossim", "count", "cov", "crop", "cross", "cubic", "cubic_ease", "cumprod", "cumsum", "dilate", "dist", "distance", "domain_warp", "domain_warp_noise", "dot", "edge", "elastic", "elastic_ease", "entropy", "erf", "erfinv", "erode", "exp", "ezconv", "ezconvolution", "fft", "find", "flatten", "flip", "float", "floor", "flow_ang", "flow_angle", "flow_apply", "flow_mag", "flow_magnitude", "flow_to_image", "fract", "gamma", "gaussian", "gelu", "get_value", "hist", "histogram", "hsv_to_rgb", "ifft", "int", "int_to_rgb", "interpolate_area", "interpolate_linear", "interpolate_nearest", "interpolate_nearest_exact", "join", "length", "lerp", "linspace", "ln", "log", "logspace", "lower", "map", "matmul", "mean", "median", "mode", "moment", "morph_close", "morph_open", "motion_mask", "nan_to_num", "noise", "now", "nvl", "oklab_to_rgb", "overlay", "pad", "percentile", "perlin", "perlin_noise", "perm", "permute", "pinv", "plasma", "plasma_noise", "popcnt", "popcount", "pow", "prcnt", "print", "print_shape", "pshp", "quantile", "quartil", "quartile", "rand", "randb", "randbeta", "randc", "rande", "randg", "randgumbel", "randchi2", "randl", "randln", "randn", "random_bernoulli", "random_beta", "random_cauchy", "random_exponential", "random_gamma", "random_gumbel", "random_chi2", "random_laplace", "random_log_normal", "random_normal", "random_poisson", "random_studentt", "random_uniform", "random_weibull", "randp", "randt", "randu", "randw", "range", "relu", "remap", "replace", "reshape", "rgb_to_cielab", "rgb_to_hsv", "rgb_to_int", "rgb_to_oklab", "ridged", "ridged_noise", "rife", "roll", "round", "rshp", "select", "shape", "shuffle", "sigm", "sign", "sin", "sine", "sine_ease", "sinh", "smax", "smin", "smootherstep", "smoothstep", "snorm", "softmax", "softmin", "softplus", "sort", "split", "sqrt", "stack_clear", "stack_get", "stack_has", "stack_pop", "stack_push", "std", "step", "substr", "substring", "sum", "swap", "tan", "tanh", "tensor", "text_image", "timestamp", "tmax", "tmin", "tnorm", "topk", "topk_ind", "topk_indices", "trim", "turbulence", "unique", "upper", "var", "voronoi", "voronoi_noise", "where", "worley"
|
||||
]);
|
||||
Reference in New Issue
Block a user