喵撲宇宙

喵嗚(Mew,@meow 8.0)的前端(從詞法到展開)已經完成,可以在實驗場試寫;還沒有執行階段,也沒有任何已出貨的宿主,喵撲的主題工坊今天用的是 @meow 6.0。

繪圖 API

draw.*、box.*、a11y 需要 draw 能力,只能在 view 和它呼叫的函式裡用(效果 draws)。除了鍵盤主題與 kit,所有宿主都有 draw。簽名的唯一定義在 HOSTS.md §3;下表由前端的宿主函式表產生。

draw

函式參數回傳能力效果
draw.clearc: colornothingdrawdraws
draw.rectx: num
y: num
w: num
h: num
c: color
{outline: num, to: color, angle: num}?
nothingdrawdraws
draw.rrectx: num
y: num
w: num
h: num
r: num
c: color
{outline: num, to: color, angle: num}?
nothingdrawdraws
draw.circlecx: num
cy: num
r: num
c: color
{outline: num, to: color, angle: num}?
nothingdrawdraws
draw.ellipsecx: num
cy: num
rx: num
ry: num
c: color
{outline: num, to: color, angle: num}?
nothingdrawdraws
draw.trix0: num
y0: num
x1: num
y1: num
x2: num
y2: num
c: color
{outline: num, to: color, angle: num}?
nothingdrawdraws
draw.polypoints: [vec2; N]
c: color
{outline: num, to: color, angle: num}?
nothingdrawdraws
draw.linex0: num
y0: num
x1: num
y1: num
c: color
{width: num}?
nothingdrawdraws
draw.arccx: num
cy: num
r: num
a0: num
a1: num
c: color
{width: num}?
nothingdrawdraws
draw.textt: text
x: num
y: num
{size: num, color: color, align: "left" | "center" | "right", baseline: "top" | "middle" | "alphabetic", weight: "regular" | "bold"}?
nothingdrawdraws
draw.numbern: num
x: num
y: num
{size: num, color: color, align: "left" | "center" | "right", baseline: "top" | "middle" | "alphabetic", weight: "regular" | "bold"}?
nothingdrawdraws
draw.textWidtht: text
size: num
numdrawpure
draw.sprites: ref sprite
cx: num
cy: num
{scale: num, rot: num, flipX: bool}?
nothingdrawdraws
draw.catwho: "mimimo" | "momo"
pose: "sit" | "walk" | "run" | "sleep" | …
cx: num
cy: num
size: num
{rot: num, flipX: bool}?
nothingdraw catsdraws
draw.iconname: "phone" | "mail" | "camera" | "music" | …
cx: num
cy: num
size: num
c: color
nothingdrawdraws
draw.shadex: num
y: num
w: num
h: num
f: ref fn
nothingdrawdraws
draw.pushnothingdrawdraws
draw.popnothingdrawdraws
draw.translatedx: num
dy: num
nothingdrawdraws
draw.rotatea: numnothingdrawdraws
draw.scalesx: num
sy: num
nothingdrawdraws
draw.alphaa: numnothingdrawdraws
draw.clipx: num
y: num
w: num
h: num
nothingdrawdraws
draw.clockx: num
y: num
{size: num, color: color, align: "left" | "center" | "right", baseline: "top" | "middle" | "alphabetic", weight: "regular" | "bold", format: "hm" | "h" | "m" | "weekday" | …}?
nothingdrawdraws,只在烘焙 view 的宿主
draw.timerx: num
y: num
{until: num, size: num, color: color, align: "left" | "center" | "right", baseline: "top" | "middle" | "alphabetic", weight: "regular" | "bold"}?
nothingdrawdraws,只在烘焙 view 的宿主
draw.progressx: num
y: num
w: num
h: num
c: color
{from: num, until: num}?
nothingdrawdraws,只在烘焙 view 的宿主
a11yt: text
{value: num}?
nothingdrawdraws

rand

函式參數回傳能力效果
rand.nextnumrandrand
rand.rangelo: num
hi: num
numrandrand
rand.intlo: num
hi: num
numrandrand
rand.chancep: numboolrandrand

time

函式參數回傳能力效果
time.everyseconds: numbooltimereads_time

clock

函式參數回傳能力效果
clock.athour: num
minute: num
numclockreads_data,只在烘焙 view 的宿主

pad

函式參數回傳能力效果
pad.colsrow: numnumpadsreads_data
pad.recti: num{x: num, y: num, w: num, h: num}padsreads_data
pad.centeri: numvec2padsreads_data
pad.rowi: numnumpadsreads_data
pad.coli: numnumpadsreads_data
pad.indexrow: num
col: num
numpadsreads_data
pad.atx: num
y: num
numpadsreads_data
pad.downi: numboolpadsreads_data
pad.heldi: numnumpadsreads_data

touch

函式參數回傳能力效果
touch.downid: numbooltouchreads_data
touch.posid: numvec2touchreads_data

sfx

函式參數回傳能力效果
sfx.playname: "pop" | "chime" | "thud" | "drip" | …
{gain: num}?
nothingsfxsfx
sfx.notedegree: num
{scale: "theme" | "pentatonic" | "major", voice: "theme" | "musicBox" | "kalimba" | "guzheng" | …, octave: num, gain: num}?
nothingsfxsfx

haptic

函式參數回傳能力效果
haptic.tapstrength: "light" | "medium" | "heavy"nothinghaptichaptic

可讀的值

名稱型別能力備註
time.ticknumtime
time.dtnumtime
time.tnumtime
time.ratenumtime
box.wnumdraw
box.hnumdraw
pad.countnumpads宿主常數
pad.rowsnumpads宿主常數
pad.anyDownboolpads
touch.countnumtouch

選項記錄

記錄欄位(都可省略)
Filloutline: num to: color angle: num
TextOptssize: num color: color align: "center" | "left" | "right" baseline: "alphabetic" | "middle" | "top" weight: "bold" | "regular"
LineOptswidth: num
SpriteOptsscale: num rot: num flipX: bool
CatOptsrot: num flipX: bool
ClockOptssize: num color: color align: "center" | "left" | "right" baseline: "alphabetic" | "middle" | "top" weight: "bold" | "regular" format: "h" | "hm" | "m" | "monthDay" | "weekday"
TimerOptsuntil: num size: num color: color align: "center" | "left" | "right" baseline: "alphabetic" | "middle" | "top" weight: "bold" | "regular"
ProgressOptsfrom: num until: num
A11yOptsvalue: num
PlayOptsgain: num
NoteOptsscale: "major" | "pentatonic" | "theme" voice: "bubble" | "glass" | "guzheng" | "hangDrum" | "kalimba" | "musicBox" | "retro8bit" | "theme" | … octave: num gain: num

模型

立即模式:view 裡每一個 draw.* 呼叫往繪圖清單附加一個指令。view 結束後,宿主原生重播這份清單,VM 不碰像素。後畫的蓋住先畫的。

繪圖清單(MDL1)、編碼器與三個重播器都還沒有實作。

簽名慣例

  1. 命名空間.動詞,camelCase:draw.rrect、sfx.play。
  2. 沒有「影響下一個呼叫」的修飾(沒有 draw.setColor、draw.stroke()、draw.gradient())。外框、漸層用選項記錄。唯一的狀態是成對的 draw.push()/draw.pop()。
  3. 參數順序固定:幾何 → 顏色 → 選項記錄。
  4. 少用的參數放在最後一個選項記錄裡:draw.text(t, x, y, {size: 12, color: kit.ink, align: "center"})。選項的每個欄位都有預設值,可以省略;未知的欄位是 E-TYP-011,附合法欄位清單。
  5. 每個封閉集合的字串參數(姿勢、圖示、音色、觸覺強度)都是列舉型別,寫錯是 E-TYP-006,列出全部合法值。
  6. 名字參照參數寫成 ref sprite、ref fn,而且函式參照放在幾何之後:draw.shade(x, y, w, h, f)。

選項

文字

變換、透明度、裁切

draw.push()
draw.translate(dx, dy)   draw.rotate(a)   draw.scale(sx, sy)
draw.alpha(a)            draw.clip(x, y, w, h)
draw.pop()

這五個呼叫只能出現在 draw.push() 與對應的 draw.pop() 之間,pop 時全部還原。在 push 之外用是 E-EFF-006;push/pop 不成對(靜態判斷得出的情況)是 E-EFF-007。變換堆疊深度 ≤ 8、裁切巢狀 ≤ 4(未驗證)。

@meow 8.0 for keyboard.canvas

view {
  draw.clear(kit.deck)
  draw.rotate(15deg)
  draw.rect(140, 60, 40, 40, kit.accent)
}
在實驗場打開 預期錯誤 E-EFF-006
@meow 8.0 for keyboard.canvas

view {
  draw.clear(kit.deck)
  draw.push()
  draw.translate(160, 80)
  draw.rotate(15deg)
  draw.rect(-20, -20, 40, 40, kit.accent)
  draw.pop()
  a11y(L.cat)
}
在實驗場打開

角度是弧度,順時針為正(y 向下);可以寫 15deg。

sprite

@meow 8.0 for keyboard.canvas

sprite snack 7x5 [kit.accent, kit.deck] {
  .11..1.
  1111.11
  1211111
  1111.11
  .11..1.
}

view {
  draw.clear(kit.deck)
  draw.sprite(snack, 160, 80, {scale: 3})
}
在實驗場打開

貓、圖示

draw.cat(who: Cat, pose: Pose, cx, cy, size, {rot, flipX})
draw.icon(name: Icon, cx, cy, size, c)

貓是第一方美術,由宿主畫,程式只選角色和姿勢;要寫 cats 能力(推斷得出)。圖示是第一方的線條圖。角色、姿勢、圖示的列舉在列舉與常數。每個姿勢與圖示的美術還沒畫。

著色器填色

draw.shade(x, y, w, h, f) 用一個能上 GPU 的純函式填一塊矩形。輸入按名字綁定:uv、time、accent、dark,沒有任何打字衍生的輸入。

a11y

a11y(t, {value}) 是這個 view 的無障礙描述。每個 view 最多 1 次(第二次起被忽略,Studio 給 W-A11Y-002),≤ 48 個字形(未驗證)。value 讓螢幕閱讀器在片語後面唸一個數字:a11y(L.score, {value: state.score})。

夾限與面積

不論程式傳什麼值,編碼器在計費之前會夾限幾何參數:座標、線寬(0.25–32)、文字大小(6–96,鍵盤畫布 8–40)、圖示與貓與 sprite 的邊長(不超過畫面短邊的 2 倍)。這些夾限值都是未驗證的起始值。夾限不是錯誤,東西只是比預期小。

每個 view 有面積預算:1 個面積單位是畫面面積的 1/64。填色類按套用變換與裁切之後的包圍盒計(至少 1 單位);線、弧按「(長度 + 寬度) × 寬度」計;文字按字形數與大小計。超過預算的指令被丟掉(R-AREA)。這是為了管住燃料和指令數都管不到的重播成本。各宿主的面積預算未驗證,見限制與預算。

自我更新的元件

draw.clock、draw.timer、draw.progress 只在烘焙宿主(小工具、動態島、鎖定畫面、圖示)可用,見 Nyadeco(喵扮)元件。

核對日期 2026-12-03 · 依據 MeowLang/docs/HOSTS.md#3.1、MeowLang/docs/HOSTS.md#3.2、MeowLang/docs/LANGUAGE.md#5.3、MeowLang/docs/LANGUAGE.md#9.4、MeowLang/docs/LANGUAGE.md#10.5、MeowLang/docs/LANGUAGE.md#11.6、MeowLang/docs/LANGUAGE.md#16.4、MeowLang/docs/CANVAS.md#8