-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
塗りつぶしのアルゴリズムを変更 #10
base: main
Are you sure you want to change the base?
塗りつぶしのアルゴリズムを変更 #10
Conversation
40fa14c
to
79f2108
Compare
002bbb7
to
93ecde7
Compare
Deploying nascalay-v2-preview with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
みました
interface Operations { | ||
/** | ||
* キャンバス内の有効な座標かつ targetColor と等しいかどうかを返す | ||
*/ | ||
inside: (x: number, y: number) => boolean; | ||
/** | ||
* キャンバスの座標 (x, y) を塗りつぶす色で塗る | ||
*/ | ||
set: (x: number, y: number) => void; | ||
pushSeed: (seed: Seed) => void; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これもっと上の方にあると助かる
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bucketFill に近接させたかったけどまぁあんま変わんないから一番上にしました
/** | ||
* キャンバスの座標 (x, y) を塗りつぶす色で塗る | ||
*/ | ||
set: (x: number, y: number) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set: (x: number, y: number) => void; | |
draw: (x: number, y: number) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名 wiki からだからあんま変えたくない (wiki 読んだ人がそのまま読めるようにしてるので)
/** | ||
* キャンバス内の有効な座標かつ targetColor と等しいかどうかを返す | ||
*/ | ||
inside: (x: number, y: number) => boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
色判定までするなら
inside: (x: number, y: number) => boolean; | |
canDraw: (x: number, y: number) => boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名 wiki からだからあんま変えたくない (wiki 読んだ人がそのまま読めるようにしてるので)
y < yRange[1] && | ||
likeEqualColor(data[y][x], targetColor); | ||
} | ||
function createSet(data: Color[][], color: Color): Operations["set"] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createInsideもややだけど使うのoperationsの初期化のときだけだしラップするまででもなさそう
好みで
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
しないとしたら bucketFill の関数内にそのまま書くってこと?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そう、pushSeedがそうだからここだけ切り出してるのが気になった
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
処理が長めだったから切ったような記憶がある
差分を見やすくするために canvas 追加のやつに向けてます
ref: https://en.wikipedia.org/wiki/Flood_fill
区間ベースで持つことで見るピクセル数を減少させるように
アルゴリズムが正当か は見なくていいです (コメントちゃんと書いたから見てもいいけど)
https://sslime-change-fill-algorithm.nascalay-v2-preview.pages.dev/tmp2 で試せます