| 1444 | } |
| 1445 | |
| 1446 | void Label::enableOutline(const Color4B& outlineColor, float outlineSize /* = -1 */) |
| 1447 | { |
| 1448 | AXASSERT(_currentLabelType == LabelType::STRING_TEXTURE || _currentLabelType == LabelType::TTF, |
| 1449 | "Only supported system font and TTF!"); |
| 1450 | |
| 1451 | if (outlineSize > 0 || _currLabelEffect == LabelEffect::OUTLINE) |
| 1452 | { |
| 1453 | if (_currentLabelType == LabelType::TTF) |
| 1454 | { |
| 1455 | _effectColorF.r = outlineColor.r / 255.0f; |
| 1456 | _effectColorF.g = outlineColor.g / 255.0f; |
| 1457 | _effectColorF.b = outlineColor.b / 255.0f; |
| 1458 | _effectColorF.a = outlineColor.a / 255.0f; |
| 1459 | |
| 1460 | if (outlineSize > 0 && _fontConfig.outlineSize != outlineSize) |
| 1461 | { |
| 1462 | |
| 1463 | _fontConfig.outlineSize = static_cast<int>(outlineSize); |
| 1464 | setTTFConfig(_fontConfig); |
| 1465 | } |
| 1466 | if (_useDistanceField && outlineSize > 0) |
| 1467 | { |
| 1468 | _currLabelEffect = LabelEffect::OUTLINE; |
| 1469 | updateShaderProgram(); |
| 1470 | } |
| 1471 | } |
| 1472 | else if (_effectColorF != outlineColor || _outlineSize != outlineSize) |
| 1473 | { |
| 1474 | _effectColorF.r = outlineColor.r / 255.f; |
| 1475 | _effectColorF.g = outlineColor.g / 255.f; |
| 1476 | _effectColorF.b = outlineColor.b / 255.f; |
| 1477 | _effectColorF.a = outlineColor.a / 255.f; |
| 1478 | _currLabelEffect = LabelEffect::OUTLINE; |
| 1479 | _contentDirty = true; |
| 1480 | } |
| 1481 | _outlineSize = outlineSize; |
| 1482 | } |
| 1483 | } |
| 1484 | |
| 1485 | void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */, |
| 1486 | const Vec2& offset /* = Vec2(2 ,-2)*/, |
no outgoing calls