[{"data":1,"prerenderedAt":1208},["ShallowReactive",2],{"content-query-MRVgATMcmN":3,"link-card-/articles/tech/mindset/how-to-practice-tech-stack":1205},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"rowTypeId":17,"sitemap":18,"body":19,"_type":1199,"_id":1200,"_source":1201,"_file":1202,"_stem":1203,"_extension":1204},"/articles/tech/development/yomogi-constraint-driven-design","development",false,"","軽量なツールの設計は「何をしないか」から始まる — Yomogi の具体例で考える","個人開発の軽量ツールでは、何を「できなくするか」を決めることが設計の本質になります。ドット絵エディタ Yomogi で実際に設けた制約と、その判断基準を具体的にまとめます。","2026-04-19",[12,13,14,15,16],"Yomogi","TypeScript","設計","個人開発","制約",1,{"loc":4,"lastmod":10,"priority":17},{"type":20,"children":21,"toc":1185},"root",[22,30,52,57,62,71,77,82,87,92,104,1179],{"type":23,"tag":24,"props":25,"children":27},"element","h2",{"id":26},"はじめに",[28],{"type":29,"value":26},"text",{"type":23,"tag":31,"props":32,"children":33},"p",{},[34,36,42,44,50],{"type":29,"value":35},"自作のドット絵エディタ ",{"type":23,"tag":37,"props":38,"children":40},"a",{"href":39},"/tools/yomogi",[41],{"type":29,"value":12},{"type":29,"value":43}," を開発していて、一番時間をかけたのは機能の実装ではありませんでした。「この機能は",{"type":23,"tag":45,"props":46,"children":47},"strong",{},[48],{"type":29,"value":49},"入れない",{"type":29,"value":51},"」と決めることに、もっとも頭を使いました。",{"type":23,"tag":31,"props":53,"children":54},{},[55],{"type":29,"value":56},"レイヤーは何枚にするか。キャンバスの上限はいくつか。タイルサイズは自由入力にするかプリセットにするか。こうした問いに対して「増やさない」「広げない」と決断するたびに、コードは単純になり、UI は分かりやすくなりました。",{"type":23,"tag":31,"props":58,"children":59},{},[60],{"type":29,"value":61},"この記事では、Yomogi で実際に設けた制約を具体例として挙げながら、「制約を決めることも立派な設計である」という考え方を整理します。",{"type":23,"tag":63,"props":64,"children":65},"summary-box",{},[66],{"type":23,"tag":31,"props":67,"children":68},{},[69],{"type":29,"value":70},"軽量ツールの設計では、何を「できるようにするか」よりも何を「できなくするか」が重要です。Yomogi のレイヤー数・キャンバスサイズ・タイルサイズなどの制約を実例に、拡張性を追わない設計のメリットと判断基準をまとめます。",{"type":23,"tag":24,"props":72,"children":74},{"id":73},"制約の設計とは",[75],{"type":29,"value":76},"「制約の設計」とは",{"type":23,"tag":31,"props":78,"children":79},{},[80],{"type":29,"value":81},"設計というと「拡張性を担保する」「変更に強い構造にする」という方向がまず思い浮かびます。チーム開発や長期運用のプロダクトでは、その方向が正解になることも多いでしょう。",{"type":23,"tag":31,"props":83,"children":84},{},[85],{"type":29,"value":86},"しかし、個人開発の軽量ツールでは事情が異なります。ユーザーは限られ、開発者は自分一人、スコープは狭い。このような環境で拡張性を追うと、使われない抽象化のためにコードが膨れ上がり、結果として開発もメンテナンスも止まります。",{"type":23,"tag":31,"props":88,"children":89},{},[90],{"type":29,"value":91},"さらに、ユーザ視点に立ってみます。高機能なものは既製品を使う方が良いという場合が多いと思います。私自身、自分のやりたいことに対して、機能が多すぎてわかりづらいと感じることがこれまでも多くありましたから、そのような体験をできる限り減らしたいということも考えています。",{"type":23,"tag":31,"props":93,"children":94},{},[95,97,102],{"type":29,"value":96},"以前の記事では、個人開発でオーバーエンジニアリングをした経験を書きました。あの記事は「技術のコスト」を知るという話でした。今回はその逆の視点で、",{"type":23,"tag":45,"props":98,"children":99},{},[100],{"type":29,"value":101},"コストを払わないために制約を先に決める",{"type":29,"value":103},"というアプローチについて書きます。",{"type":23,"tag":105,"props":106,"children":109},"link-card",{"label":107,"to":108},"オーバーエンジニアリングの記事はこちら⬇️","/articles/tech/mindset/how-to-practice-tech-stack",[110,115,121,126,283,288,294,299,304,316,345,350,939,958,995,1000,1006,1011,1016,1021,1034,1039,1045,1058,1063,1068,1086,1091,1096,1102,1107,1112,1117,1122,1127,1132,1141,1146,1174],{"type":23,"tag":31,"props":111,"children":112},{},[113],{"type":29,"value":114},"拡張性を重視する設計と制約を重視する設計は、目的が違うだけでどちらも「設計」です。何を目的にするかで正解は変わります。",{"type":23,"tag":24,"props":116,"children":118},{"id":117},"yomogi-の制約一覧",[119],{"type":29,"value":120},"Yomogi の制約一覧",{"type":23,"tag":31,"props":122,"children":123},{},[124],{"type":29,"value":125},"まず、Yomogi に設けた主な制約を一覧にします。",{"type":23,"tag":127,"props":128,"children":129},"table",{},[130,153],{"type":23,"tag":131,"props":132,"children":133},"thead",{},[134],{"type":23,"tag":135,"props":136,"children":137},"tr",{},[138,144,148],{"type":23,"tag":139,"props":140,"children":141},"th",{},[142],{"type":29,"value":143},"対象",{"type":23,"tag":139,"props":145,"children":146},{},[147],{"type":29,"value":16},{"type":23,"tag":139,"props":149,"children":150},{},[151],{"type":29,"value":152},"値",{"type":23,"tag":154,"props":155,"children":156},"tbody",{},[157,176,194,212,229,247,265],{"type":23,"tag":135,"props":158,"children":159},{},[160,166,171],{"type":23,"tag":161,"props":162,"children":163},"td",{},[164],{"type":29,"value":165},"キャンバスサイズ",{"type":23,"tag":161,"props":167,"children":168},{},[169],{"type":29,"value":170},"上限",{"type":23,"tag":161,"props":172,"children":173},{},[174],{"type":29,"value":175},"128×128",{"type":23,"tag":135,"props":177,"children":178},{},[179,184,189],{"type":23,"tag":161,"props":180,"children":181},{},[182],{"type":29,"value":183},"レイヤー数",{"type":23,"tag":161,"props":185,"children":186},{},[187],{"type":29,"value":188},"固定",{"type":23,"tag":161,"props":190,"children":191},{},[192],{"type":29,"value":193},"3（背景・中景・前景）",{"type":23,"tag":135,"props":195,"children":196},{},[197,202,207],{"type":23,"tag":161,"props":198,"children":199},{},[200],{"type":29,"value":201},"タイルサイズ",{"type":23,"tag":161,"props":203,"children":204},{},[205],{"type":29,"value":206},"プリセット",{"type":23,"tag":161,"props":208,"children":209},{},[210],{"type":29,"value":211},"8, 16, 24, 32, 48, 64",{"type":23,"tag":135,"props":213,"children":214},{},[215,220,224],{"type":23,"tag":161,"props":216,"children":217},{},[218],{"type":29,"value":219},"タイルマップ",{"type":23,"tag":161,"props":221,"children":222},{},[223],{"type":29,"value":170},{"type":23,"tag":161,"props":225,"children":226},{},[227],{"type":29,"value":228},"64×64 セル",{"type":23,"tag":135,"props":230,"children":231},{},[232,237,242],{"type":23,"tag":161,"props":233,"children":234},{},[235],{"type":29,"value":236},"デフォルトパレット",{"type":23,"tag":161,"props":238,"children":239},{},[240],{"type":29,"value":241},"色数",{"type":23,"tag":161,"props":243,"children":244},{},[245],{"type":29,"value":246},"28色",{"type":23,"tag":135,"props":248,"children":249},{},[250,255,260],{"type":23,"tag":161,"props":251,"children":252},{},[253],{"type":29,"value":254},"描画ツール",{"type":23,"tag":161,"props":256,"children":257},{},[258],{"type":29,"value":259},"種類",{"type":23,"tag":161,"props":261,"children":262},{},[263],{"type":29,"value":264},"5（ペン・消しゴム・塗りつぶし・スポイト・移動）",{"type":23,"tag":135,"props":266,"children":267},{},[268,273,278],{"type":23,"tag":161,"props":269,"children":270},{},[271],{"type":29,"value":272},"SVG エクスポート",{"type":23,"tag":161,"props":274,"children":275},{},[276],{"type":29,"value":277},"方式",{"type":23,"tag":161,"props":279,"children":280},{},[281],{"type":29,"value":282},"1ピクセル = 1rect、最適化なし",{"type":23,"tag":31,"props":284,"children":285},{},[286],{"type":29,"value":287},"これらはどれも「もっと増やせる」ものばかりです。レイヤーは10枚にできるし、キャンバスは1024×1024にもできます。あえてそうしなかった理由を、以降で具体的に見ていきます。",{"type":23,"tag":24,"props":289,"children":291},{"id":290},"実例１-3レイヤー固定",[292],{"type":29,"value":293},"実例１ 3レイヤー固定",{"type":23,"tag":31,"props":295,"children":296},{},[297],{"type":29,"value":298},"タイルマップエディタを設計するとき、真っ先に悩んだのは「レイヤーを何枚にするか」でした。",{"type":23,"tag":31,"props":300,"children":301},{},[302],{"type":29,"value":303},"ユーザーが自由にレイヤーを追加・削除できる方式にすれば柔軟性は上がります。しかし、そうすると描画順の管理（Z-index）、レイヤー一覧 UI のスクロール、レイヤー間のドラッグ並べ替えなど、実装しなければならない機能が一気に増えます。",{"type":23,"tag":31,"props":305,"children":306},{},[307,309,314],{"type":29,"value":308},"結論として、",{"type":23,"tag":45,"props":310,"children":311},{},[312],{"type":29,"value":313},"背景・中景・前景の3枚に固定",{"type":29,"value":315},"しました。理由は以下の３点となります。",{"type":23,"tag":317,"props":318,"children":319},"ul",{},[320,335,340],{"type":23,"tag":321,"props":322,"children":323},"li",{},[324,326,333],{"type":29,"value":325},"描画順を ",{"type":23,"tag":327,"props":328,"children":330},"code",{"className":329},[],[331],{"type":29,"value":332},"background → middle → foreground",{"type":29,"value":334}," の固定順にでき、Z-index の管理コードが不要",{"type":23,"tag":321,"props":336,"children":337},{},[338],{"type":29,"value":339},"「背景に地面、中景にキャラ、前景に葉っぱ」のように役割を説明しやすく、シンプル",{"type":23,"tag":321,"props":341,"children":342},{},[343],{"type":29,"value":344},"レイヤー選択タブが常に3つで、UI が複雑化しない",{"type":23,"tag":31,"props":346,"children":347},{},[348],{"type":29,"value":349},"描画コードも制約の恩恵で単純になっています。",{"type":23,"tag":351,"props":352,"children":356},"pre",{"className":353,"code":354,"language":355,"meta":7,"style":7},"language-typescript shiki shiki-themes vitesse-dark","for (const layerId of LAYER_IDS) {\n  const layer = state.layers[layerId]\n  if (!layer.visible) continue\n  for (const sprite of layer.sprites) {\n    const img = spriteImageMap.get(sprite.projectId)\n    if (!img) continue\n    const dx = offsetX + sprite.col * cellSize\n    const dy = offsetY + sprite.row * cellSize\n    const dw = (img.width / state.tileSize) * cellSize\n    const dh = (img.height / state.tileSize) * cellSize\n    ctx.drawImage(img, dx, dy, dw, dh)\n  }\n}\n","typescript",[357],{"type":23,"tag":327,"props":358,"children":359},{"__ignoreMap":7},[360,409,457,497,545,601,630,680,727,792,854,921,930],{"type":23,"tag":361,"props":362,"children":364},"span",{"class":363,"line":17},"line",[365,371,377,383,389,394,399,404],{"type":23,"tag":361,"props":366,"children":368},{"style":367},"--shiki-default:#4D9375",[369],{"type":29,"value":370},"for",{"type":23,"tag":361,"props":372,"children":374},{"style":373},"--shiki-default:#666666",[375],{"type":29,"value":376}," (",{"type":23,"tag":361,"props":378,"children":380},{"style":379},"--shiki-default:#CB7676",[381],{"type":29,"value":382},"const ",{"type":23,"tag":361,"props":384,"children":386},{"style":385},"--shiki-default:#BD976A",[387],{"type":29,"value":388},"layerId",{"type":23,"tag":361,"props":390,"children":391},{"style":379},[392],{"type":29,"value":393}," of",{"type":23,"tag":361,"props":395,"children":396},{"style":385},[397],{"type":29,"value":398}," LAYER_IDS",{"type":23,"tag":361,"props":400,"children":401},{"style":373},[402],{"type":29,"value":403},")",{"type":23,"tag":361,"props":405,"children":406},{"style":373},[407],{"type":29,"value":408}," {\n",{"type":23,"tag":361,"props":410,"children":412},{"class":363,"line":411},2,[413,418,423,428,433,438,443,448,452],{"type":23,"tag":361,"props":414,"children":415},{"style":379},[416],{"type":29,"value":417},"  const ",{"type":23,"tag":361,"props":419,"children":420},{"style":385},[421],{"type":29,"value":422},"layer",{"type":23,"tag":361,"props":424,"children":425},{"style":373},[426],{"type":29,"value":427}," =",{"type":23,"tag":361,"props":429,"children":430},{"style":385},[431],{"type":29,"value":432}," state",{"type":23,"tag":361,"props":434,"children":435},{"style":373},[436],{"type":29,"value":437},".",{"type":23,"tag":361,"props":439,"children":440},{"style":385},[441],{"type":29,"value":442},"layers",{"type":23,"tag":361,"props":444,"children":445},{"style":373},[446],{"type":29,"value":447},"[",{"type":23,"tag":361,"props":449,"children":450},{"style":385},[451],{"type":29,"value":388},{"type":23,"tag":361,"props":453,"children":454},{"style":373},[455],{"type":29,"value":456},"]\n",{"type":23,"tag":361,"props":458,"children":460},{"class":363,"line":459},3,[461,466,470,475,479,483,488,492],{"type":23,"tag":361,"props":462,"children":463},{"style":367},[464],{"type":29,"value":465},"  if",{"type":23,"tag":361,"props":467,"children":468},{"style":373},[469],{"type":29,"value":376},{"type":23,"tag":361,"props":471,"children":472},{"style":379},[473],{"type":29,"value":474},"!",{"type":23,"tag":361,"props":476,"children":477},{"style":385},[478],{"type":29,"value":422},{"type":23,"tag":361,"props":480,"children":481},{"style":373},[482],{"type":29,"value":437},{"type":23,"tag":361,"props":484,"children":485},{"style":385},[486],{"type":29,"value":487},"visible",{"type":23,"tag":361,"props":489,"children":490},{"style":373},[491],{"type":29,"value":403},{"type":23,"tag":361,"props":493,"children":494},{"style":367},[495],{"type":29,"value":496}," continue\n",{"type":23,"tag":361,"props":498,"children":500},{"class":363,"line":499},4,[501,506,510,514,519,523,528,532,537,541],{"type":23,"tag":361,"props":502,"children":503},{"style":367},[504],{"type":29,"value":505},"  for",{"type":23,"tag":361,"props":507,"children":508},{"style":373},[509],{"type":29,"value":376},{"type":23,"tag":361,"props":511,"children":512},{"style":379},[513],{"type":29,"value":382},{"type":23,"tag":361,"props":515,"children":516},{"style":385},[517],{"type":29,"value":518},"sprite",{"type":23,"tag":361,"props":520,"children":521},{"style":379},[522],{"type":29,"value":393},{"type":23,"tag":361,"props":524,"children":525},{"style":385},[526],{"type":29,"value":527}," layer",{"type":23,"tag":361,"props":529,"children":530},{"style":373},[531],{"type":29,"value":437},{"type":23,"tag":361,"props":533,"children":534},{"style":385},[535],{"type":29,"value":536},"sprites",{"type":23,"tag":361,"props":538,"children":539},{"style":373},[540],{"type":29,"value":403},{"type":23,"tag":361,"props":542,"children":543},{"style":373},[544],{"type":29,"value":408},{"type":23,"tag":361,"props":546,"children":548},{"class":363,"line":547},5,[549,554,559,563,568,572,578,583,587,591,596],{"type":23,"tag":361,"props":550,"children":551},{"style":379},[552],{"type":29,"value":553},"    const ",{"type":23,"tag":361,"props":555,"children":556},{"style":385},[557],{"type":29,"value":558},"img",{"type":23,"tag":361,"props":560,"children":561},{"style":373},[562],{"type":29,"value":427},{"type":23,"tag":361,"props":564,"children":565},{"style":385},[566],{"type":29,"value":567}," spriteImageMap",{"type":23,"tag":361,"props":569,"children":570},{"style":373},[571],{"type":29,"value":437},{"type":23,"tag":361,"props":573,"children":575},{"style":574},"--shiki-default:#80A665",[576],{"type":29,"value":577},"get",{"type":23,"tag":361,"props":579,"children":580},{"style":373},[581],{"type":29,"value":582},"(",{"type":23,"tag":361,"props":584,"children":585},{"style":385},[586],{"type":29,"value":518},{"type":23,"tag":361,"props":588,"children":589},{"style":373},[590],{"type":29,"value":437},{"type":23,"tag":361,"props":592,"children":593},{"style":385},[594],{"type":29,"value":595},"projectId",{"type":23,"tag":361,"props":597,"children":598},{"style":373},[599],{"type":29,"value":600},")\n",{"type":23,"tag":361,"props":602,"children":604},{"class":363,"line":603},6,[605,610,614,618,622,626],{"type":23,"tag":361,"props":606,"children":607},{"style":367},[608],{"type":29,"value":609},"    if",{"type":23,"tag":361,"props":611,"children":612},{"style":373},[613],{"type":29,"value":376},{"type":23,"tag":361,"props":615,"children":616},{"style":379},[617],{"type":29,"value":474},{"type":23,"tag":361,"props":619,"children":620},{"style":385},[621],{"type":29,"value":558},{"type":23,"tag":361,"props":623,"children":624},{"style":373},[625],{"type":29,"value":403},{"type":23,"tag":361,"props":627,"children":628},{"style":367},[629],{"type":29,"value":496},{"type":23,"tag":361,"props":631,"children":633},{"class":363,"line":632},7,[634,638,643,647,652,657,661,665,670,675],{"type":23,"tag":361,"props":635,"children":636},{"style":379},[637],{"type":29,"value":553},{"type":23,"tag":361,"props":639,"children":640},{"style":385},[641],{"type":29,"value":642},"dx",{"type":23,"tag":361,"props":644,"children":645},{"style":373},[646],{"type":29,"value":427},{"type":23,"tag":361,"props":648,"children":649},{"style":385},[650],{"type":29,"value":651}," offsetX",{"type":23,"tag":361,"props":653,"children":654},{"style":379},[655],{"type":29,"value":656}," + ",{"type":23,"tag":361,"props":658,"children":659},{"style":385},[660],{"type":29,"value":518},{"type":23,"tag":361,"props":662,"children":663},{"style":373},[664],{"type":29,"value":437},{"type":23,"tag":361,"props":666,"children":667},{"style":385},[668],{"type":29,"value":669},"col",{"type":23,"tag":361,"props":671,"children":672},{"style":379},[673],{"type":29,"value":674}," * ",{"type":23,"tag":361,"props":676,"children":677},{"style":385},[678],{"type":29,"value":679},"cellSize\n",{"type":23,"tag":361,"props":681,"children":683},{"class":363,"line":682},8,[684,688,693,697,702,706,710,714,719,723],{"type":23,"tag":361,"props":685,"children":686},{"style":379},[687],{"type":29,"value":553},{"type":23,"tag":361,"props":689,"children":690},{"style":385},[691],{"type":29,"value":692},"dy",{"type":23,"tag":361,"props":694,"children":695},{"style":373},[696],{"type":29,"value":427},{"type":23,"tag":361,"props":698,"children":699},{"style":385},[700],{"type":29,"value":701}," offsetY",{"type":23,"tag":361,"props":703,"children":704},{"style":379},[705],{"type":29,"value":656},{"type":23,"tag":361,"props":707,"children":708},{"style":385},[709],{"type":29,"value":518},{"type":23,"tag":361,"props":711,"children":712},{"style":373},[713],{"type":29,"value":437},{"type":23,"tag":361,"props":715,"children":716},{"style":385},[717],{"type":29,"value":718},"row",{"type":23,"tag":361,"props":720,"children":721},{"style":379},[722],{"type":29,"value":674},{"type":23,"tag":361,"props":724,"children":725},{"style":385},[726],{"type":29,"value":679},{"type":23,"tag":361,"props":728,"children":730},{"class":363,"line":729},9,[731,735,740,744,748,752,756,761,766,771,775,780,784,788],{"type":23,"tag":361,"props":732,"children":733},{"style":379},[734],{"type":29,"value":553},{"type":23,"tag":361,"props":736,"children":737},{"style":385},[738],{"type":29,"value":739},"dw",{"type":23,"tag":361,"props":741,"children":742},{"style":373},[743],{"type":29,"value":427},{"type":23,"tag":361,"props":745,"children":746},{"style":373},[747],{"type":29,"value":376},{"type":23,"tag":361,"props":749,"children":750},{"style":385},[751],{"type":29,"value":558},{"type":23,"tag":361,"props":753,"children":754},{"style":373},[755],{"type":29,"value":437},{"type":23,"tag":361,"props":757,"children":758},{"style":385},[759],{"type":29,"value":760},"width",{"type":23,"tag":361,"props":762,"children":763},{"style":379},[764],{"type":29,"value":765}," / ",{"type":23,"tag":361,"props":767,"children":768},{"style":385},[769],{"type":29,"value":770},"state",{"type":23,"tag":361,"props":772,"children":773},{"style":373},[774],{"type":29,"value":437},{"type":23,"tag":361,"props":776,"children":777},{"style":385},[778],{"type":29,"value":779},"tileSize",{"type":23,"tag":361,"props":781,"children":782},{"style":373},[783],{"type":29,"value":403},{"type":23,"tag":361,"props":785,"children":786},{"style":379},[787],{"type":29,"value":674},{"type":23,"tag":361,"props":789,"children":790},{"style":385},[791],{"type":29,"value":679},{"type":23,"tag":361,"props":793,"children":795},{"class":363,"line":794},10,[796,800,805,809,813,817,821,826,830,834,838,842,846,850],{"type":23,"tag":361,"props":797,"children":798},{"style":379},[799],{"type":29,"value":553},{"type":23,"tag":361,"props":801,"children":802},{"style":385},[803],{"type":29,"value":804},"dh",{"type":23,"tag":361,"props":806,"children":807},{"style":373},[808],{"type":29,"value":427},{"type":23,"tag":361,"props":810,"children":811},{"style":373},[812],{"type":29,"value":376},{"type":23,"tag":361,"props":814,"children":815},{"style":385},[816],{"type":29,"value":558},{"type":23,"tag":361,"props":818,"children":819},{"style":373},[820],{"type":29,"value":437},{"type":23,"tag":361,"props":822,"children":823},{"style":385},[824],{"type":29,"value":825},"height",{"type":23,"tag":361,"props":827,"children":828},{"style":379},[829],{"type":29,"value":765},{"type":23,"tag":361,"props":831,"children":832},{"style":385},[833],{"type":29,"value":770},{"type":23,"tag":361,"props":835,"children":836},{"style":373},[837],{"type":29,"value":437},{"type":23,"tag":361,"props":839,"children":840},{"style":385},[841],{"type":29,"value":779},{"type":23,"tag":361,"props":843,"children":844},{"style":373},[845],{"type":29,"value":403},{"type":23,"tag":361,"props":847,"children":848},{"style":379},[849],{"type":29,"value":674},{"type":23,"tag":361,"props":851,"children":852},{"style":385},[853],{"type":29,"value":679},{"type":23,"tag":361,"props":855,"children":857},{"class":363,"line":856},11,[858,863,867,872,876,880,885,890,894,899,903,908,912,917],{"type":23,"tag":361,"props":859,"children":860},{"style":385},[861],{"type":29,"value":862},"    ctx",{"type":23,"tag":361,"props":864,"children":865},{"style":373},[866],{"type":29,"value":437},{"type":23,"tag":361,"props":868,"children":869},{"style":574},[870],{"type":29,"value":871},"drawImage",{"type":23,"tag":361,"props":873,"children":874},{"style":373},[875],{"type":29,"value":582},{"type":23,"tag":361,"props":877,"children":878},{"style":385},[879],{"type":29,"value":558},{"type":23,"tag":361,"props":881,"children":882},{"style":373},[883],{"type":29,"value":884},",",{"type":23,"tag":361,"props":886,"children":887},{"style":385},[888],{"type":29,"value":889}," dx",{"type":23,"tag":361,"props":891,"children":892},{"style":373},[893],{"type":29,"value":884},{"type":23,"tag":361,"props":895,"children":896},{"style":385},[897],{"type":29,"value":898}," dy",{"type":23,"tag":361,"props":900,"children":901},{"style":373},[902],{"type":29,"value":884},{"type":23,"tag":361,"props":904,"children":905},{"style":385},[906],{"type":29,"value":907}," dw",{"type":23,"tag":361,"props":909,"children":910},{"style":373},[911],{"type":29,"value":884},{"type":23,"tag":361,"props":913,"children":914},{"style":385},[915],{"type":29,"value":916}," dh",{"type":23,"tag":361,"props":918,"children":919},{"style":373},[920],{"type":29,"value":600},{"type":23,"tag":361,"props":922,"children":924},{"class":363,"line":923},12,[925],{"type":23,"tag":361,"props":926,"children":927},{"style":373},[928],{"type":29,"value":929},"  }\n",{"type":23,"tag":361,"props":931,"children":933},{"class":363,"line":932},13,[934],{"type":23,"tag":361,"props":935,"children":936},{"style":373},[937],{"type":29,"value":938},"}\n",{"type":23,"tag":31,"props":940,"children":941},{},[942,948,950,956],{"type":23,"tag":327,"props":943,"children":945},{"className":944},[],[946],{"type":29,"value":947},"LAYER_IDS",{"type":29,"value":949}," は ",{"type":23,"tag":327,"props":951,"children":953},{"className":952},[],[954],{"type":29,"value":955},"['background', 'middle', 'foreground']",{"type":29,"value":957}," の固定配列です。動的なレイヤー管理が不要なので、レイヤーの追加・削除・並べ替えに関するコードが一切ありません。",{"type":23,"tag":959,"props":960,"children":961},"tradeoff-box",{},[962,974],{"type":23,"tag":963,"props":964,"children":965},"template",{"v-slot:cons":7},[966],{"type":23,"tag":317,"props":967,"children":968},{},[969],{"type":23,"tag":321,"props":970,"children":971},{},[972],{"type":29,"value":973},"3枚では足りないユーザー（例: 複雑なパララックスを組みたい人）には対応できない",{"type":23,"tag":963,"props":975,"children":976},{"v-slot:pros":7},[977],{"type":23,"tag":317,"props":978,"children":979},{},[980,985,990],{"type":23,"tag":321,"props":981,"children":982},{},[983],{"type":29,"value":984},"Z-index 管理コードが不要で、描画順のバグが原理的に発生しない",{"type":23,"tag":321,"props":986,"children":987},{},[988],{"type":29,"value":989},"UI が常に3タブ固定で、初見のユーザーでも迷わない",{"type":23,"tag":321,"props":991,"children":992},{},[993],{"type":29,"value":994},"レイヤーの CRUD 操作を実装しなくて済む",{"type":23,"tag":31,"props":996,"children":997},{},[998],{"type":29,"value":999},"「3枚では足りない」ケースは確かに存在します。しかし Yomogi の対象は「ちょっとしたドット絵を描きたい人」であり、複雑なマップエディタを求めるユーザーには別のツールがあります。ターゲットを絞ったからこそ、この制約が成り立ちます。",{"type":23,"tag":24,"props":1001,"children":1003},{"id":1002},"実例２-キャンバスタイルマップのサイズ上限",[1004],{"type":29,"value":1005},"実例２ キャンバス・タイルマップのサイズ上限",{"type":23,"tag":31,"props":1007,"children":1008},{},[1009],{"type":29,"value":1010},"キャンバスの上限を 128×128 ピクセル、タイルマップの上限を 64×64 セルに設定しています。",{"type":23,"tag":31,"props":1012,"children":1013},{},[1014],{"type":29,"value":1015},"この制約には実用上の根拠があります。",{"type":23,"tag":31,"props":1017,"children":1018},{},[1019],{"type":29,"value":1020},"ピクセルアートは本質的に小さな画像です。昔のゲームのスプライトは 8×8や16×16、32×32が基本でした。128×128でもピクセルアートとしてはかなり大きい部類に入ります。",{"type":23,"tag":31,"props":1022,"children":1023},{},[1024,1026,1032],{"type":29,"value":1025},"上限を決めたことで、データ構造は ",{"type":23,"tag":327,"props":1027,"children":1029},{"className":1028},[],[1030],{"type":29,"value":1031},"Uint32Array(128 * 128)",{"type":29,"value":1033}," で済みます。チャンク分割や仮想スクロールのような大規模データ向けの仕組みは不要です。Canvas 2D のパフォーマンスもこの範囲なら問題になりません。",{"type":23,"tag":31,"props":1035,"children":1036},{},[1037],{"type":29,"value":1038},"上限がなければ「1000×1000 のキャンバスで描画が遅い」というバグ報告に対応する羽目になります。上限を設けることで、そのカテゴリの問題を丸ごと排除できます。",{"type":23,"tag":24,"props":1040,"children":1042},{"id":1041},"実例３-タイルサイズのプリセット値",[1043],{"type":29,"value":1044},"実例３ タイルサイズのプリセット値",{"type":23,"tag":31,"props":1046,"children":1047},{},[1048,1050,1056],{"type":29,"value":1049},"タイルサイズは自由入力ではなく、",{"type":23,"tag":327,"props":1051,"children":1053},{"className":1052},[],[1054],{"type":29,"value":1055},"[8, 16, 24, 32, 48, 64]",{"type":29,"value":1057}," のプリセットから選ぶ方式にしました。",{"type":23,"tag":31,"props":1059,"children":1060},{},[1061],{"type":29,"value":1062},"自由入力にすると「3」や「7」のような半端な値が入力される可能性があります。すると、タイルの境界線がピクセルの中間に来てにじむ、大きなスプライトとの整数比が崩れるなど、エッジケースの対応が必要になります。",{"type":23,"tag":31,"props":1064,"children":1065},{},[1066],{"type":29,"value":1067},"プリセットにしたことで得られたものは明確です。",{"type":23,"tag":317,"props":1069,"children":1070},{},[1071,1076,1081],{"type":23,"tag":321,"props":1072,"children":1073},{},[1074],{"type":29,"value":1075},"入力バリデーションが「配列に含まれるか」の一行で済む",{"type":23,"tag":321,"props":1077,"children":1078},{},[1079],{"type":29,"value":1080},"すべてのプリセット値が 8 の倍数なので、スプライトとの整数比が保証される",{"type":23,"tag":321,"props":1082,"children":1083},{},[1084],{"type":29,"value":1085},"UI がドロップダウン1つで完結し、数値入力フィールドのエラーハンドリングが不要",{"type":23,"tag":24,"props":1087,"children":1089},{"id":1088},"制約を決めるときの判断基準",[1090],{"type":29,"value":1088},{"type":23,"tag":31,"props":1092,"children":1093},{},[1094],{"type":29,"value":1095},"Yomogi の各制約を振り返ると、判断の軸は3つに整理できます。",{"type":23,"tag":1097,"props":1098,"children":1100},"h3",{"id":1099},"ターゲットユーザーの用途に合っているか",[1101],{"type":29,"value":1099},{"type":23,"tag":31,"props":1103,"children":1104},{},[1105],{"type":29,"value":1106},"Yomogi は「ちょっとしたドット絵を描いてみたい人」向けのツールです。プロ向けの機能セットは最初から目指していません。ターゲットが明確であれば、「この人には不要」と言い切れる機能が見えてきます。",{"type":23,"tag":31,"props":1108,"children":1109},{},[1110],{"type":29,"value":1111},"Yomogiを最初に作ろうと思ったきっかけ自体、私が個人開発で必要なツールだったことが理由なので、最小限の機能でも実用に足るという判断をしました。",{"type":23,"tag":1097,"props":1113,"children":1115},{"id":1114},"制約によってどれだけの複雑さを排除できるか",[1116],{"type":29,"value":1114},{"type":23,"tag":31,"props":1118,"children":1119},{},[1120],{"type":29,"value":1121},"レイヤーを3枚に固定することで Z-index 管理が消え、キャンバスに上限を設けることでパフォーマンス問題のカテゴリごと消えました。制約1つで排除できるエッジケースや実装コストが大きいほど、その制約の価値は高いです。",{"type":23,"tag":1097,"props":1123,"children":1125},{"id":1124},"後から緩められるか",[1126],{"type":29,"value":1124},{"type":23,"tag":31,"props":1128,"children":1129},{},[1130],{"type":29,"value":1131},"制約は後から緩めることができます。レイヤーを3枚から5枚に増やすのは、5枚から3枚に減らすより遥かに簡単です。迷ったら厳しい方を選び、ユーザーのフィードバックを見て緩めるかどうかを判断すれば十分です。",{"type":23,"tag":1133,"props":1134,"children":1135},"caution-box",{},[1136],{"type":23,"tag":31,"props":1137,"children":1138},{},[1139],{"type":29,"value":1140},"「制約」と「手抜き」は違います。制約は考えた結果として「やらない」と決めること。考えずにやらなかったのは単なる未実装です。判断の根拠、特に設計の意図・目的を言語化できるようにすることが大事です。",{"type":23,"tag":24,"props":1142,"children":1144},{"id":1143},"まとめ",[1145],{"type":29,"value":1143},{"type":23,"tag":317,"props":1147,"children":1148},{},[1149,1154,1159,1164,1169],{"type":23,"tag":321,"props":1150,"children":1151},{},[1152],{"type":29,"value":1153},"軽量ツールでは「何をしないか」を決めることが設計の中心になる",{"type":23,"tag":321,"props":1155,"children":1156},{},[1157],{"type":29,"value":1158},"Yomogi ではレイヤー数・キャンバスサイズ・タイルサイズ・エクスポート方式のすべてに意図的な上限を設けた",{"type":23,"tag":321,"props":1160,"children":1161},{},[1162],{"type":29,"value":1163},"制約はコードの単純さ・UI のわかりやすさ・パフォーマンスの安定を同時にもたらす",{"type":23,"tag":321,"props":1165,"children":1166},{},[1167],{"type":29,"value":1168},"拡張性を重視する設計と制約を重視する設計は、目的が違うだけでどちらも「設計」である",{"type":23,"tag":321,"props":1170,"children":1171},{},[1172],{"type":29,"value":1173},"迷ったら厳しい方を選び、後からフィードバックを見て緩める",{"type":23,"tag":31,"props":1175,"children":1176},{},[1177],{"type":29,"value":1178},"制約を決めるのは地味な作業ですが、軽量ツールにとってはそれが一番クリエイティブな瞬間だと思います。",{"type":23,"tag":1180,"props":1181,"children":1182},"style",{},[1183],{"type":29,"value":1184},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":411,"depth":411,"links":1186},[1187,1188,1189,1190,1191,1192,1193,1198],{"id":26,"depth":411,"text":26},{"id":73,"depth":411,"text":76},{"id":117,"depth":411,"text":120},{"id":290,"depth":411,"text":293},{"id":1002,"depth":411,"text":1005},{"id":1041,"depth":411,"text":1044},{"id":1088,"depth":411,"text":1088,"children":1194},[1195,1196,1197],{"id":1099,"depth":459,"text":1099},{"id":1114,"depth":459,"text":1114},{"id":1124,"depth":459,"text":1124},{"id":1143,"depth":411,"text":1143},"markdown","content:articles:tech:development:yomogi-constraint-driven-design.md","content","articles/tech/development/yomogi-constraint-driven-design.md","articles/tech/development/yomogi-constraint-driven-design","md",{"title":1206,"description":1207},"銀の弾丸を求めて迷走した私の失敗談。個人開発でオーバーエンジニアリングして気づいた「技術のコスト」の話","本や記事で学んだ「理想の設計」を試すと思ったようにいかないことが多いです。実務で失敗すると多大なコストを支払うことになりますが、個人開発であれば安心して試せます。安心して試すことで技術の限界を学ぶことができ、結果的に実務で活かせる経験となります。",1776570487466]