@@ -1097,6 +1097,11 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
10971097 ItemRainbow *item_rainbow = static_cast <ItemRainbow *>(item_fx);
10981098
10991099 font_color = font_color.from_hsv (item_rainbow->frequency * (item_rainbow->elapsed_time + ((p_ofs.x + gloff.x ) / 50 )), item_rainbow->saturation , item_rainbow->value , font_color.a );
1100+ } else if (item_fx->type == ITEM_PULSE ) {
1101+ ItemPulse *item_pulse = static_cast <ItemPulse *>(item_fx);
1102+
1103+ const float sined_time = (Math::ease (Math::pingpong (item_pulse->elapsed_time , 1.0 / item_pulse->frequency ) * item_pulse->frequency , item_pulse->ease ));
1104+ font_color = font_color.lerp (font_color * item_pulse->color , sined_time);
11001105 }
11011106 }
11021107
@@ -1315,6 +1320,11 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
13151320 ItemRainbow *item_rainbow = static_cast <ItemRainbow *>(item_fx);
13161321
13171322 font_color = font_color.from_hsv (item_rainbow->frequency * (item_rainbow->elapsed_time + ((p_ofs.x + off.x ) / 50 )), item_rainbow->saturation , item_rainbow->value , font_color.a );
1323+ } else if (item_fx->type == ITEM_PULSE ) {
1324+ ItemPulse *item_pulse = static_cast <ItemPulse *>(item_fx);
1325+
1326+ const float sined_time = (Math::ease (Math::pingpong (item_pulse->elapsed_time , 1.0 / item_pulse->frequency ) * item_pulse->frequency , item_pulse->ease ));
1327+ font_color = font_color.lerp (font_color * item_pulse->color , sined_time);
13181328 }
13191329 }
13201330
@@ -1675,7 +1685,7 @@ void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, double p_delta
16751685 while (it) {
16761686 ItemFX *ifx = nullptr ;
16771687
1678- if (it->type == ITEM_CUSTOMFX || it->type == ITEM_SHAKE || it->type == ITEM_WAVE || it->type == ITEM_TORNADO || it->type == ITEM_RAINBOW ) {
1688+ if (it->type == ITEM_CUSTOMFX || it->type == ITEM_SHAKE || it->type == ITEM_WAVE || it->type == ITEM_TORNADO || it->type == ITEM_RAINBOW || it-> type == ITEM_PULSE ) {
16791689 ifx = static_cast <ItemFX *>(it);
16801690 }
16811691
@@ -2616,7 +2626,7 @@ bool RichTextLabel::_find_strikethrough(Item *p_item) {
26162626void RichTextLabel::_fetch_item_fx_stack (Item *p_item, Vector<ItemFX *> &r_stack) {
26172627 Item *item = p_item;
26182628 while (item) {
2619- if (item->type == ITEM_CUSTOMFX || item->type == ITEM_SHAKE || item->type == ITEM_WAVE || item->type == ITEM_TORNADO || item->type == ITEM_RAINBOW ) {
2629+ if (item->type == ITEM_CUSTOMFX || item->type == ITEM_SHAKE || item->type == ITEM_WAVE || item->type == ITEM_TORNADO || item->type == ITEM_RAINBOW || item-> type == ITEM_PULSE ) {
26202630 r_stack.push_back (static_cast <ItemFX *>(item));
26212631 }
26222632
@@ -3480,6 +3490,17 @@ void RichTextLabel::push_rainbow(float p_saturation, float p_value, float p_freq
34803490 _add_item (item, true );
34813491}
34823492
3493+ void RichTextLabel::push_pulse (const Color &p_color, float p_frequency, float p_ease) {
3494+ _stop_thread ();
3495+ MutexLock data_lock (data_mutex);
3496+
3497+ ItemPulse *item = memnew (ItemPulse);
3498+ item->color = p_color;
3499+ item->frequency = p_frequency;
3500+ item->ease = p_ease;
3501+ _add_item (item, true );
3502+ }
3503+
34833504void RichTextLabel::push_bgcolor (const Color &p_color) {
34843505 _stop_thread ();
34853506 MutexLock data_lock (data_mutex);
@@ -4663,7 +4684,29 @@ void RichTextLabel::append_text(const String &p_bbcode) {
46634684 pos = brk_end + 1 ;
46644685 tag_stack.push_front (" rainbow" );
46654686 set_process_internal (true );
4687+ } else if (bbcode_name == " pulse" ) {
4688+ Color color = Color (1 , 1 , 1 , 0.25 );
4689+ OptionMap::Iterator color_option = bbcode_options.find (" color" );
4690+ if (color_option) {
4691+ color = Color::from_string (color_option->value , color);
4692+ }
4693+
4694+ float frequency = 1.0 ;
4695+ OptionMap::Iterator freq_option = bbcode_options.find (" freq" );
4696+ if (freq_option) {
4697+ frequency = freq_option->value .to_float ();
4698+ }
46664699
4700+ float ease = -2.0 ;
4701+ OptionMap::Iterator ease_option = bbcode_options.find (" ease" );
4702+ if (ease_option) {
4703+ ease = ease_option->value .to_float ();
4704+ }
4705+
4706+ push_pulse (color, frequency, ease);
4707+ pos = brk_end + 1 ;
4708+ tag_stack.push_front (" pulse" );
4709+ set_process_internal (true );
46674710 } else if (tag.begins_with (" bgcolor=" )) {
46684711 String color_str = tag.substr (8 , tag.length ()).unquote ();
46694712 Color color = Color::from_string (color_str, theme_cache.default_color );
0 commit comments