NiVE愛用者スレ4 【Ni ..
416:名無しさん@お腹いっぱい。
08/10/29 11:40:48 B96igq8s0
//sm5018535さん支援 光源自動移動
//全角スペースを半角スペースに直してから
//nShineのエクスプレッションに貼ってね
int no;
for (no = 0; Property.TimelineTracks[no].TimelineName != "筆の先端抽出"; no++)
;
Bitmap image = Property.TimelineTracks[no].GetImage(Property.Index, false).Image;
int lx = image.Width;
int ly = image.Height;
int x = 0;
int y = 0;
Color c;
double ax = 0;
double ay = 0;
int ct = 0;
// アルファの分布を元に重心を計算
for (y = 0; y < ly; y++) {
for (x = 0; x < lx; x++) {
c = image.GetPixel(x,y);
if (c.A != 0) {
ax += x;
ay += y;
ct++;
}
}
}
ax /= ct;
ay /= ct;
image.Dispose();
PointProperty light = (PointProperty)ExpressionUtils.GetProperty(Property.ThisProperty, "光源");
light.X = (int)ax;
light.Y = (int)ay;
//デバック表示
StringProperty dbg = new StringProperty("Debug","");
MonitorProperty.Add(dbg);
dbg.TypeSafeValue = "["+light.X+","+light.Y+"]";
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4344日前に更新/191 KB
担当:undef