初始匯入:選舉小鎮(backend、web、art 合成一個 repo)
- backend:規則(選戰卡牌、選民模型)、Fastify 伺服器、校準工具、Python 資料管線 - web:React + Vite 前端 - art:卡牌插圖的生圖腳本與原圖(原圖用 Git LFS) - 架構總覽在 backend/docs/README.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
8cebfc9db5
|
|
@ -0,0 +1,3 @@
|
||||||
|
# 生圖原圖(每張約 1.4 MB,整批重生時會換掉)放 Git LFS;code.30cm.net 的 Gitea 已開 LFS。
|
||||||
|
# 要先安裝 git-lfs 並執行過 git lfs install,再 git add,否則會被當成一般檔案收進去。
|
||||||
|
art/generated/*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# 整個專案共用;backend/ 與 web/ 另有自己的 .gitignore(只管各自的資料夾)
|
||||||
|
|
||||||
|
# 系統與編輯器
|
||||||
|
.DS_Store
|
||||||
|
._*
|
||||||
|
Thumbs.db
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# 生圖工具的暫存工作資料夾(art/gen-card-grokcli.sh 產生)
|
||||||
|
art/grok-work/
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
web/src/game/Feed.tsx
|
||||||
|
web/src/game/GameScreen.tsx
|
||||||
|
web/src/game/StartScreen.tsx
|
||||||
|
web/src/game/audio/speech.ts
|
||||||
|
web/src/game/hq
|
||||||
|
web/src/game/hud/TopBar.tsx
|
||||||
|
web/src/game/hud/WeekBanner.tsx
|
||||||
|
web/src/game/news/BreakingNews.tsx
|
||||||
|
web/src/game/news/NewsRoom.tsx
|
||||||
|
web/src/game/news/advice.ts
|
||||||
|
web/src/game/news/newsroom.css
|
||||||
|
web/src/game/night
|
||||||
|
web/src/game/paper
|
||||||
|
web/src/game/plan
|
||||||
|
web/src/game/playback
|
||||||
|
web/src/game/start/CandidateStats.tsx
|
||||||
|
web/src/game/start/LineupBuilder.tsx
|
||||||
|
web/src/game/start/RunningMatePicker.tsx
|
||||||
|
web/src/game/start/TaiwanPicker.tsx
|
||||||
|
web/src/game/art/scenes/title.tsx
|
||||||
|
web/test/tactics.test.ts
|
||||||
|
web/test/cards.test.ts
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,87 @@
|
||||||
|
street_canvass a candidate team walking down a busy Taiwanese street lined with arcade shophouses (騎樓), scooters parked, shopkeepers waving, campaign volunteers in matching vests handing out flyers
|
||||||
|
market_visit a lively Taiwanese traditional wet market, vegetable and fruit stalls under striped awnings, a small campaign group shaking hands with stall owners and elderly shoppers
|
||||||
|
temple_visit a Taiwanese temple courtyard with ornate swallowtail roof and dragons, incense burner with smoke, worshippers holding incense, a small campaign group bowing
|
||||||
|
factory_visit an industrial park in Taiwan at shift change, factory buildings with sawtooth roofs, workers in uniforms and safety helmets at the gate, a campaign group greeting them
|
||||||
|
sound_truck a small campaign sound truck with loudspeakers on its roof driving through a rural Taiwanese town with rice paddies and a betel nut stand, villagers looking on
|
||||||
|
rally a huge night-time campaign rally in a Taiwanese city plaza, big illuminated stage with spotlights, a sea of supporters waving blank colored flags and glow sticks
|
||||||
|
open_office a newly opened campaign office in a Taiwanese street-front shop, big blank banners, flower baskets lined up outside, volunteers setting up tables
|
||||||
|
recruit_machine a neighborhood chief (village head) in a small Taiwanese community office, tea set on the table, local elders chatting with a campaign aide
|
||||||
|
hire_staff a busy campaign war room with desks, laptops, whiteboards with blank sticky notes and a map of Taiwan, staff members discussing strategy
|
||||||
|
recruit_volunteers young volunteers in matching vests gathering at a campaign headquarters, sign-up table, stacks of leaflets and boxes, cheerful atmosphere
|
||||||
|
print_flyers a Taiwanese print shop with offset presses, stacks of colorful blank campaign leaflets and posters coming off the press, workers bundling them
|
||||||
|
tv_ad a television studio shooting a campaign commercial, cameras, lighting rigs, a director's monitor, a crew filming a small anonymous actor family on a set
|
||||||
|
online_ad an anonymous person on a crowded Taipei MRT train scrolling a smartphone with blank colorful video thumbnails glowing, other commuters on phones
|
||||||
|
talk_show a Taiwanese political TV talk show studio, panel desk with four anonymous pundits, bright studio lights, cameras and a live audience-less set with blank screens
|
||||||
|
announce_policy a press conference podium in a hotel ballroom, rows of reporters with cameras and microphones raised, blank backdrop panel
|
||||||
|
fundraiser_dinner a Taiwanese banquet hall fundraising dinner with round tables and red tablecloths, many guests toasting, a small stage at the front
|
||||||
|
small_donations a cozy home desk at night with a laptop showing a blank progress bar and coins, a piggy bank, many tiny glowing notification bubbles floating
|
||||||
|
self_fund a campaign treasurer's desk with a bank passbook, stacks of banknotes, a calculator and a worried anonymous person counting money
|
||||||
|
expose_press a dramatic press conference where an anonymous spokesperson holds up a thick folder of documents, flashbulbs going off, reporters crowding
|
||||||
|
rebuttal_press a calm press conference with an anonymous spokesperson standing beside a blank chart board, reporters listening, a clock on the wall
|
||||||
|
investigate a private investigator in a parked car at night with a long-lens camera watching a building, rain on the windshield, noir mood but cozy miniature style
|
||||||
|
internal_poll a phone survey call center with rows of operators wearing headsets, monitors showing blank bar charts, late evening
|
||||||
|
vote_buying a shady back alley at night where an anonymous figure secretly hands over a red envelope, shadows, a lamp post, tense mood, no faces visible
|
||||||
|
troll_army a dim room full of computer monitors and smartphones on racks, anonymous figures typing, many identical blank chat bubbles floating upward
|
||||||
|
rest a quiet morning in a small Taiwanese apartment, a tired campaigner napping on a sofa, a cup of tea, sunlight through the window, a cat
|
||||||
|
eve_rally the final eve-of-election mega rally, a gigantic crowd filling a boulevard at night, fireworks overhead, stage with giant blank screens, confetti
|
||||||
|
kneel on a rally stage in the rain, a small anonymous candidate figure kneeling and bowing to the crowd, supporters holding umbrellas, emotional atmosphere
|
||||||
|
eve_phone_bank a campaign phone bank late at night, volunteers making calls with lists, clock showing late hour, cups of instant noodles on the desks
|
||||||
|
eve_online_ad a night city skyline with dozens of floating smartphone screens showing blank campaign video thumbnails, energetic neon glow
|
||||||
|
eve_vote_buying a village at night before election day, an anonymous figure on a scooter dropping envelopes at doorsteps, dogs barking, lights in windows
|
||||||
|
scene-typhoon a Taiwanese coastal city during a typhoon, palm trees bending, rain sheets, flooded street with scooters, emergency crew in raincoats
|
||||||
|
scene-debate a televised election debate stage with three empty podiums, dramatic lighting, studio audience seats, big blank screens
|
||||||
|
scene-election-night election night inside a campaign headquarters, crowd watching a giant screen with blank rising bar charts, confetti and tense faces from behind
|
||||||
|
scene-ballot a Taiwanese polling station in a school classroom, voting booths, ballot boxes, voters lining up, election officials at tables
|
||||||
|
scene-registration candidates registering at the Central Election Commission office, anonymous figures with document folders, staff behind counters, cameras
|
||||||
|
scene-scandal a newspaper stand with stacks of newspapers and magazines with blank dramatic headlines blocks, people gathering to read, morning light
|
||||||
|
night_market a bustling Taiwanese night market at night, food stalls with steam and lanterns, crowds of young people and office workers, a small campaign group greeting visitors
|
||||||
|
door_to_door a quiet residential lane of Taiwanese apartment buildings with iron gates and potted plants, a campaign volunteer ringing a doorbell, an elderly resident opening the door
|
||||||
|
pilgrimage a long temple pilgrimage procession on a rural road, palanquin carriers, flags, drums, firecracker smoke, pilgrims walking in a line
|
||||||
|
church_visit a small church and a Buddhist temple side by side in a Taiwanese town, a campaign group respectfully greeting worshippers at the entrance
|
||||||
|
weddings_funerals a lively Taiwanese outdoor wedding banquet under a red tent at night, round tables, a small anonymous figure toasting guests table by table
|
||||||
|
banquet a Taiwanese outdoor roadside banquet (bando) with many round tables under a big red-and-white tent, chefs cooking in large woks, elderly guests eating
|
||||||
|
concert an outdoor evening campaign concert, a band on a lit stage, young crowd with glow sticks, festive lights
|
||||||
|
flags_billboards a Taiwanese street intersection lined with rows of plain colorful campaign flags and big blank billboards, scooters passing by
|
||||||
|
phone_banking volunteers making phone calls in a campaign office in the evening, call lists on desks, headsets, warm lamp light
|
||||||
|
homecoming a busy Taiwanese train station and bus terminal crowded with people carrying luggage going home, chartered buses waiting outside
|
||||||
|
radio_ad a cozy radio studio with an anonymous host at a microphone, on-air light glowing, and an elderly couple listening to a radio at home in an inset
|
||||||
|
short_video a young campaign staffer filming a short video on a smartphone gimbal in a colorful street, ring light, playful energy
|
||||||
|
line_groups a grandmother and grandfather on a sofa looking at smartphones with many blank chat bubbles and sticker icons floating around
|
||||||
|
influencer_live a podcast and livestream studio with microphones, a ring light, a camera, two anonymous hosts chatting, neon sign without text
|
||||||
|
press_conference a policy press conference in a hotel meeting room, podium with flowers, reporters with cameras and microphones, blank backdrop
|
||||||
|
interview a calm newspaper interview in a cafe, a journalist with a notebook and recorder sitting across from an anonymous figure, warm light
|
||||||
|
forum a government-hosted candidate forum in a school auditorium, three podiums on stage, sparse audience, TV cameras broadcasting
|
||||||
|
visit_associations a clan association hall with ancestral tablets and red decorations, elders in a meeting room, a campaign group bowing and shaking hands
|
||||||
|
endorsement a respected elderly scholar and local notables standing on a small stage giving thumbs up, a modest crowd applauding, plain banners
|
||||||
|
party_elder a big rally stage where a senior party figure (anonymous, seen from behind) raises the hand of a candidate, crowd cheering, plain flags
|
||||||
|
gifts gift boxes with fruit baskets, tea tins and liquor bottles being delivered to a traditional house courtyard, tense subtle mood
|
||||||
|
councilor_allies several anonymous local politicians in campaign sashes (blank) walking together through a market street waving to people
|
||||||
|
big_donor a modern office tower lobby, an anonymous campaign team meeting a businessman in a glass meeting room overlooking the city
|
||||||
|
party_fund a political party headquarters building with a treasury counter, an envelope and documents being handed over at a desk
|
||||||
|
white_paper a stack of thick policy documents and charts on a large table, a team working late with highlighters and laptops
|
||||||
|
lawsuit a Taiwanese courthouse entrance with stone steps, lawyers carrying folders, reporters waiting with cameras
|
||||||
|
report_prosecutor a prosecutors office building at dusk, an anonymous person handing a sealed envelope of evidence at the reception counter
|
||||||
|
protest_government a peaceful protest in front of a government building, people holding blank placards and a petition, police lined calmly
|
||||||
|
protest_hq a noisy crowd with blank placards gathered in front of a rival campaign headquarters storefront, reporters filming
|
||||||
|
crisis_pr an anonymous spokesperson bowing deeply in apology at a press conference, camera flashes, serious mood
|
||||||
|
fact_check a fact-checking room with screens showing blank charts and magnifying glass icons, staff marking items as checked
|
||||||
|
promise_bribe a secret late-night meeting in a back room of a small restaurant, two anonymous figures shaking hands over a table, shadows
|
||||||
|
smear a dark room where anonymous figures send many messages from phones, red warning icons and blank messages flying out
|
||||||
|
impersonate late at night, an elderly person woken up by a ringing phone in a dark bedroom, annoyed expression, clock showing midnight
|
||||||
|
frame_vote_buying a nighttime alley where an anonymous figure hands out envelopes while another hides and secretly photographs it, noir mood
|
||||||
|
staged_attack a chaotic moment on a rally street with spilled paint on the ground, security guards and crowd reacting, dramatic but not violent
|
||||||
|
buyout two anonymous figures meeting in a parked car at night, a briefcase of money on the seat between them, city lights outside
|
||||||
|
slush_fund a white-gloved hand passing a bag of cash under a table in a dim karaoke room, secretive mood
|
||||||
|
fake_poll a messy desk with printed fake charts and a phone screen showing a blank rising bar chart, a mischievous mood
|
||||||
|
chicken_oath a traditional Taiwanese temple square where an anonymous figure in a sash swears an oath before the temple, holding a rooster, crowd watching, dramatic
|
||||||
|
invite_oath two empty chairs and a rooster cage in front of a temple, reporters waiting, a sign-less table set for an oath ceremony
|
||||||
|
live_pledge an anonymous candidate signing a pledge document while being livestreamed on a smartphone on a tripod, chat bubbles floating
|
||||||
|
workout an early morning riverside park in Taiwan, an anonymous campaigner jogging with staff, joggers and morning exercisers around
|
||||||
|
study a cozy study at night with piles of books, policy reports and a desk lamp, an anonymous figure reading intently
|
||||||
|
debate_training a mock debate rehearsal in a campaign office, staff playing opponents at podiums, a coach with a stopwatch
|
||||||
|
media_training a media training session with a coach, a camera and a monitor replaying a clip, an anonymous trainee practicing answers
|
||||||
|
fire_staff an empty office desk with a cardboard box of belongings, an anonymous staffer walking out the door, somber light
|
||||||
|
street_interview a Taiwanese street corner with arcade shophouses, a small camera crew filming a friendly interview with a passer-by holding a bubble tea, a microphone held out, scooters in background
|
||||||
|
grassroots_walk a lone campaigner walking along a quiet Taiwanese rural road past rice paddies and a small temple, wearing a plain sash and carrying a rolled cloth banner, afternoon light
|
||||||
|
facebook_live a small cluttered Taiwanese campaign office at night, a smartphone on a tripod with ring light streaming live, floating heart and comment bubbles shown as abstract shapes, cup of tea on the desk
|
||||||
|
volunteer_calls a cozy Taiwanese apartment living room in the evening, two older volunteers sitting at a table with mobile phones and a handwritten contact notebook, making friendly calls
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
Copyright 2014-2019 Adobe (http://www.adobe.com/), with Reserved Font
|
||||||
|
Name 'Source'. Source is a trademark of Adobe in the United States
|
||||||
|
and/or other countries.
|
||||||
|
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# 用 xAI(grok-imagine-image-2.0)產生一張卡牌插圖:gen-card-grok.sh <id> <題材>
|
||||||
|
# 金鑰從環境變數 XAI_API_KEY 讀;沒有的話讀 ~/.config/tongsuan/xai.env(XAI_API_KEY=...)。不會印出金鑰。
|
||||||
|
# 原圖存 art/generated/<id>.png,網頁用的縮圖存 web/public/cards/<id>.webp(和 gen-card.sh 一樣)
|
||||||
|
set -u
|
||||||
|
id="$1"; subject="$2"
|
||||||
|
here="${0:A:h}"
|
||||||
|
out="$here/generated/$id.png"
|
||||||
|
web="$here/../web/public/cards/$id.webp"
|
||||||
|
if [[ -z "${XAI_API_KEY:-}" && -r "$HOME/.config/tongsuan/xai.env" ]]; then
|
||||||
|
source "$HOME/.config/tongsuan/xai.env"
|
||||||
|
fi
|
||||||
|
if [[ -z "${XAI_API_KEY:-}" ]]; then
|
||||||
|
echo "FAIL $id(沒有 XAI_API_KEY)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
style="Style: tabletop board-game card illustration, miniature diorama look with tilt-shift depth of field, soft isometric three-quarter top-down view, warm gouache texture, clean readable shapes, cohesive warm palette with a few saturated accents. Setting: present-day Taiwan. Absolutely no text, no letters, no numbers, no logos, no party symbols or party colors on flags (flags and banners are plain), no real or recognizable people; all figures are small, anonymous and stylized. Square image."
|
||||||
|
if [[ ! -s "$out" ]]; then
|
||||||
|
body=$(python3 -c 'import json,sys; print(json.dumps({"model": "grok-imagine-image-2.0", "prompt": sys.argv[1], "n": 1, "response_format": "b64_json"}))' "Subject: $subject. $style")
|
||||||
|
resp=$(curl -sS --max-time 180 https://api.x.ai/v1/images/generations \
|
||||||
|
-H "Content-Type: application/json" -H "Authorization: Bearer $XAI_API_KEY" -d "$body")
|
||||||
|
# 回傳可能是 base64 或網址;兩種都接受(回應先存檔,避免和程式碼搶標準輸入)
|
||||||
|
print -r -- "$resp" > "$here/generated/$id.json"
|
||||||
|
python3 - "$out" "$here/generated/$id.json" 2>"$here/generated/$id.log" <<'PY'
|
||||||
|
import base64, json, sys, urllib.request
|
||||||
|
out = sys.argv[1]
|
||||||
|
raw = open(sys.argv[2], encoding="utf-8").read()
|
||||||
|
try:
|
||||||
|
d = json.loads(raw)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
sys.exit(f"不是 JSON:{raw[:200]}")
|
||||||
|
if "error" in d or not d.get("data"):
|
||||||
|
sys.exit(f"API 錯誤:{json.dumps(d, ensure_ascii=False)[:300]}")
|
||||||
|
item = d["data"][0]
|
||||||
|
if item.get("b64_json"):
|
||||||
|
data = base64.b64decode(item["b64_json"])
|
||||||
|
else:
|
||||||
|
data = urllib.request.urlopen(item["url"], timeout=120).read()
|
||||||
|
open(out, "wb").write(data)
|
||||||
|
PY
|
||||||
|
rm -f "$here/generated/$id.json"
|
||||||
|
fi
|
||||||
|
if [[ -s "$out" ]]; then
|
||||||
|
# 原圖可能是 JPEG:先轉 PNG 存檔,網頁用 webp
|
||||||
|
file "$out" | grep -q PNG || { ffmpeg -loglevel error -y -i "$out" "$out.tmp.png" && mv "$out.tmp.png" "$out"; }
|
||||||
|
cwebp -quiet -q 80 -resize 640 640 "$out" -o "$web" && echo "ok $id"
|
||||||
|
else
|
||||||
|
echo "FAIL $id($(tail -1 "$here/generated/$id.log" 2>/dev/null))"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# 用本機 Grok Build(grok CLI 的 image_gen)產生一張卡牌插圖:gen-card-grokcli.sh <id> <題材>
|
||||||
|
# 只開放生圖工具(--allow imagine),不讓它執行指令;圖存在 grok 自己的 session 資料夾,這裡再轉檔。
|
||||||
|
# 原圖存 art/generated/<id>.png,網頁用的縮圖存 web/public/cards/<id>.webp(和 gen-card.sh 一樣)
|
||||||
|
set -u
|
||||||
|
id="$1"; subject="$2"
|
||||||
|
here="${0:A:h}"
|
||||||
|
out="$here/generated/$id.png"
|
||||||
|
web="$here/../web/public/cards/$id.webp"
|
||||||
|
work="$here/grok-work/$id"
|
||||||
|
style="Style: tabletop board-game card illustration, miniature diorama look with tilt-shift depth of field, soft isometric three-quarter top-down view, warm gouache texture, clean readable shapes, cohesive warm palette with a few saturated accents. Setting: present-day Taiwan. Absolutely no text, no letters, no numbers, no logos, no party symbols or party colors on flags (flags and banners are plain), no real or recognizable people; all figures are small, anonymous and stylized. Square image."
|
||||||
|
if [[ ! -s "$out" ]]; then
|
||||||
|
mkdir -p "$work"
|
||||||
|
marker="$work/.start"
|
||||||
|
: > "$marker"
|
||||||
|
grok -p "Use your image generation tool to create exactly ONE image. Subject: $subject. $style Do not run any shell commands and do not edit files; just generate the image and reply with the word done." \
|
||||||
|
--cwd "$work" --allow imagine --max-turns 4 > "$here/generated/$id.log" 2>&1
|
||||||
|
img=$(find "$HOME/.grok/sessions" -path "*grok-work%2F$id*" -newer "$marker" -type f \( -name "*.jpg" -o -name "*.png" -o -name "*.webp" \) 2>/dev/null | head -1)
|
||||||
|
if [[ -n "$img" ]]; then
|
||||||
|
ffmpeg -loglevel error -y -i "$img" "$out"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -s "$out" ]]; then
|
||||||
|
cwebp -quiet -q 80 -resize 640 640 "$out" -o "$web" && echo "ok $id"
|
||||||
|
else
|
||||||
|
echo "FAIL $id"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# 用本機 codex 的生圖工具產生一張卡牌插圖:gen-card.sh <id> <題材>
|
||||||
|
# 原圖存 art/generated/<id>.png,網頁用的縮圖存 web/public/cards/<id>.webp
|
||||||
|
set -u
|
||||||
|
id="$1"; subject="$2"
|
||||||
|
here="${0:A:h}"
|
||||||
|
out="$here/generated/$id.png"
|
||||||
|
web="$here/../web/public/cards/$id.webp"
|
||||||
|
style="Style: tabletop board-game card illustration, miniature diorama look with tilt-shift depth of field, soft isometric three-quarter top-down view, warm gouache texture, clean readable shapes, cohesive warm palette with a few saturated accents. Setting: present-day Taiwan. Absolutely no text, no letters, no numbers, no logos, no party symbols or party colors on flags (flags and banners are plain), no real or recognizable people; all figures are small, anonymous and stylized. Square 1024x1024."
|
||||||
|
if [[ ! -s "$out" ]]; then
|
||||||
|
codex exec --skip-git-repo-check --sandbox workspace-write -C "$here/generated" \
|
||||||
|
"Use your image generation tool to create ONE image and save it as $id.png in the current directory (overwrite if it exists). Subject: $subject. $style After saving, print the absolute path of the file and nothing else." \
|
||||||
|
> "$here/generated/$id.log" 2>&1
|
||||||
|
fi
|
||||||
|
if [[ -s "$out" ]]; then
|
||||||
|
cwebp -quiet -q 80 -resize 640 640 "$out" -o "$web" && echo "ok $id"
|
||||||
|
else
|
||||||
|
echo "FAIL $id"
|
||||||
|
fi
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue