@@ -761,15 +761,26 @@ void InstallAccessors(v8::Isolate* isolate, v8::Local<v8::Object> obj)
761761 Self (info.This ())->state .MEMBER = v->BooleanValue (info.GetIsolate ()); }).Check ()
762762
763763 // fillStyle / strokeStyle: gradient/pattern オブジェクトも受け取り代表色へ解決。
764- // getter は代入した文字列(色)をそのまま返す (player は色正規化に読み戻しを使う)。
764+ // 重要: getter は「代入した色を #rrggbb に正規化して」返す (ブラウザ準拠)。
765+ // player は色文字列の数値化に読み戻しを使う (@next2d/filters の
766+ // $convertColorStringToNumber は `+("0x"+ctx.fillStyle.slice(1))` で解釈するため、
767+ // getter が "rgb(191,255,255)" 等の生文字列を返すと NaN になり、その色を使う
768+ // グラデーション (スライム body 等) が黒くなる)。パース済み RGBA を hex 化して保持する。
765769 obj->SetNativeDataProperty (ctx, Str (isolate, " fillStyle" ),
766770 [](v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) {
767771 info.GetReturnValue ().Set (v8util::Str (info.GetIsolate (), Self (info.This ())->state .fill_style_str ));
768772 },
769773 [](v8::Local<v8::Name>, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void >& info) {
770774 Canvas2D* c = Self (info.This ());
771775 c->state .fill = ColorFromValue (info.GetIsolate (), value);
772- if (value->IsString ()) c->state .fill_style_str = ToStdString (info.GetIsolate (), value);
776+ if (value->IsString ()) {
777+ char hex[8 ];
778+ std::snprintf (hex, sizeof (hex), " #%02x%02x%02x" ,
779+ static_cast <unsigned >(c->state .fill .r ),
780+ static_cast <unsigned >(c->state .fill .g ),
781+ static_cast <unsigned >(c->state .fill .b ));
782+ c->state .fill_style_str = hex;
783+ }
773784 }).Check ();
774785 obj->SetNativeDataProperty (ctx, Str (isolate, " strokeStyle" ),
775786 [](v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>& info) {
@@ -778,7 +789,14 @@ void InstallAccessors(v8::Isolate* isolate, v8::Local<v8::Object> obj)
778789 [](v8::Local<v8::Name>, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void >& info) {
779790 Canvas2D* c = Self (info.This ());
780791 c->state .stroke = ColorFromValue (info.GetIsolate (), value);
781- if (value->IsString ()) c->state .stroke_style_str = ToStdString (info.GetIsolate (), value);
792+ if (value->IsString ()) {
793+ char hex[8 ];
794+ std::snprintf (hex, sizeof (hex), " #%02x%02x%02x" ,
795+ static_cast <unsigned >(c->state .stroke .r ),
796+ static_cast <unsigned >(c->state .stroke .g ),
797+ static_cast <unsigned >(c->state .stroke .b ));
798+ c->state .stroke_style_str = hex;
799+ }
782800 }).Check ();
783801
784802 N2D_STR_PROP (" font" , font);
0 commit comments