本文整理汇总了C++中LLColor4::calcHSL方法的典型用法代码示例。如果您正苦于以下问题:C++ LLColor4::calcHSL方法的具体用法?C++ LLColor4::calcHSL怎么用?C++ LLColor4::calcHSL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LLColor4
的用法示例。
在下文中一共展示了LLColor4::calcHSL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
S32 LLFontGL::render(const LLWString &wstr,
const S32 begin_offset,
const F32 x, const F32 y,
const LLColor4 &color,
const HAlign halign, const VAlign valign,
U8 style,
const S32 max_chars, S32 max_pixels,
F32* right_x,
BOOL use_embedded,
BOOL use_ellipses) const
{
if(!sDisplayFont) //do not display texts
{
return wstr.length() ;
}
if (wstr.empty())
{
return 0;
}
gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX);
// Strip off any style bits that are already accounted for by the font.
style = style & (~getFontDesc().getStyle());
F32 drop_shadow_strength = 0.f;
if (style & (DROP_SHADOW | DROP_SHADOW_SOFT))
{
F32 luminance;
color.calcHSL(NULL, NULL, &luminance);
drop_shadow_strength = clamp_rescale(luminance, 0.35f, 0.6f, 0.f, 1.f);
if (luminance < 0.35f)
{
style = style & ~(DROP_SHADOW | DROP_SHADOW_SOFT);
}
}
gGL.pushMatrix();
glLoadIdentity();
gGL.translatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
// this code snaps the text origin to a pixel grid to start with
F32 pixel_offset_x = llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
F32 pixel_offset_y = llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
gGL.translatef(-pixel_offset_x, -pixel_offset_y, 0.f);
LLFastTimer t(LLFastTimer::FTM_RENDER_FONTS);
gGL.color4fv( color.mV );
S32 chars_drawn = 0;
S32 i;
S32 length;
if (-1 == max_chars)
{
length = (S32)wstr.length() - begin_offset;
}
else
{
length = llmin((S32)wstr.length() - begin_offset, max_chars );
}
F32 cur_x, cur_y, cur_render_x, cur_render_y;
// Not guaranteed to be set correctly
gGL.setSceneBlendType(LLRender::BT_ALPHA);
cur_x = ((F32)x * sScaleX);
cur_y = ((F32)y * sScaleY);
// Offset y by vertical alignment.
switch (valign)
{
case TOP:
cur_y -= mAscender;
break;
case BOTTOM:
cur_y += mDescender;
break;
case VCENTER:
cur_y -= ((mAscender - mDescender)/2.f);
break;
case BASELINE:
// Baseline, do nothing.
break;
default:
break;
}
switch (halign)
{
case LEFT:
break;
case RIGHT:
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), 0, length) * sScaleX));
break;
//.........这里部分代码省略.........
示例2: render
S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style,
ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_ellipses) const
{
LLFastTimer _(FTM_RENDER_FONTS);
if(!sDisplayFont) //do not display texts
{
return wstr.length() ;
}
if (wstr.empty())
{
return 0;
}
gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX);
// determine which style flags need to be added programmatically by stripping off the
// style bits that are drawn by the underlying Freetype font
U8 style_to_add = (style | mFontDescriptor.getStyle()) & ~mFontFreetype->getStyle();
F32 drop_shadow_strength = 0.f;
if (shadow != NO_SHADOW)
{
F32 luminance;
color.calcHSL(NULL, NULL, &luminance);
drop_shadow_strength = clamp_rescale(luminance, 0.35f, 0.6f, 0.f, 1.f);
if (luminance < 0.35f)
{
shadow = NO_SHADOW;
}
}
gGL.pushUIMatrix();
gGL.loadUIIdentity();
//gGL.translateUI(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
// this code snaps the text origin to a pixel grid to start with
//F32 pixel_offset_x = llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
//F32 pixel_offset_y = llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
//gGL.translateUI(-pixel_offset_x, -pixel_offset_y, 0.f);
LLVector2 origin(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY));
// snap the text origin to a pixel grid to start with
origin.mV[VX] -= llround((F32)sCurOrigin.mX) - (sCurOrigin.mX);
origin.mV[VY] -= llround((F32)sCurOrigin.mY) - (sCurOrigin.mY);
S32 chars_drawn = 0;
S32 i;
S32 length;
if (-1 == max_chars)
{
length = (S32)wstr.length() - begin_offset;
}
else
{
length = llmin((S32)wstr.length() - begin_offset, max_chars );
}
F32 cur_x, cur_y, cur_render_x, cur_render_y;
// Not guaranteed to be set correctly
gGL.setSceneBlendType(LLRender::BT_ALPHA);
cur_x = ((F32)x * sScaleX) + origin.mV[VX];
cur_y = ((F32)y * sScaleY) + origin.mV[VY];
// Offset y by vertical alignment.
switch (valign)
{
case TOP:
cur_y -= mFontFreetype->getAscenderHeight();
break;
case BOTTOM:
cur_y += mFontFreetype->getDescenderHeight();
break;
case VCENTER:
cur_y -= (mFontFreetype->getAscenderHeight() - mFontFreetype->getDescenderHeight()) / 2.f;
break;
case BASELINE:
// Baseline, do nothing.
break;
default:
break;
}
switch (halign)
{
case LEFT:
break;
case RIGHT:
cur_x -= llmin(scaled_max_pixels, llround(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX));
break;
case HCENTER:
//.........这里部分代码省略.........
示例3: render
S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, F32 x, F32 y, const LLColor4 &color, HAlign halign, VAlign valign, U8 style,
ShadowType shadow, S32 max_chars, S32 max_pixels, F32* right_x, BOOL use_embedded, BOOL use_ellipses) const
{
LLFastTimer _(FTM_RENDER_FONTS);
if(!sDisplayFont) //do not display texts
{
return wstr.length() ;
}
if (wstr.empty() || !max_pixels)
{
return 0;
}
if (max_chars == -1)
max_chars = S32_MAX;
const S32 max_index = llmin(llmax(max_chars, begin_offset + max_chars), S32(wstr.length()));
if (max_index <= 0 || begin_offset >= max_index || max_pixels <= 0)
return 0;
gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX);
// Strip off any style bits that are already accounted for by the font.
style = style & (~getFontDesc().getStyle());
F32 drop_shadow_strength = 0.f;
if (shadow != NO_SHADOW)
{
F32 luminance;
color.calcHSL(NULL, NULL, &luminance);
drop_shadow_strength = clamp_rescale(luminance, 0.35f, 0.6f, 0.f, 1.f);
if (luminance < 0.35f)
{
shadow = NO_SHADOW;
}
}
gGL.pushUIMatrix();
gGL.loadUIIdentity();
LLVector2 origin(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY));
// Depth translation, so that floating text appears 'in-world'
// and is correctly occluded.
gGL.translatef(0.f,0.f,sCurDepth);
S32 chars_drawn = 0;
S32 i;
S32 length = max_index - begin_offset;
F32 cur_x, cur_y, cur_render_x, cur_render_y;
// Not guaranteed to be set correctly
gGL.setSceneBlendType(LLRender::BT_ALPHA);
cur_x = ((F32)x * sScaleX) + origin.mV[VX];
cur_y = ((F32)y * sScaleY) + origin.mV[VY];
// Offset y by vertical alignment.
// use unscaled font metrics here
switch (valign)
{
case TOP:
cur_y -= llceil(mFontFreetype->getAscenderHeight());
break;
case BOTTOM:
cur_y += llceil(mFontFreetype->getDescenderHeight());
break;
case VCENTER:
cur_y -= llceil((llceil(mFontFreetype->getAscenderHeight()) - llceil(mFontFreetype->getDescenderHeight())) / 2.f);
break;
case BASELINE:
// Baseline, do nothing.
break;
default:
break;
}
switch (halign)
{
case LEFT:
break;
case RIGHT:
cur_x -= llmin(scaled_max_pixels, ll_round(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX));
break;
case HCENTER:
cur_x -= llmin(scaled_max_pixels, ll_round(getWidthF32(wstr.c_str(), begin_offset, length) * sScaleX)) / 2;
break;
default:
break;
}
cur_render_y = cur_y;
cur_render_x = cur_x;
//.........这里部分代码省略.........
示例4: render
S32 LLFontGL::render(const LLWString &wstr,
const S32 begin_offset,
const F32 x, const F32 y,
const LLColor4 &color,
const HAlign halign, const VAlign valign,
U8 style,
const S32 max_chars, S32 max_pixels,
F32* right_x,
BOOL use_embedded,
BOOL use_ellipses) const
{
if(!sDisplayFont) //do not display texts
{
return wstr.length() ;
}
LLGLEnable tex(GL_TEXTURE_2D);
if (wstr.empty())
{
return 0;
}
S32 scaled_max_pixels = max_pixels == S32_MAX ? S32_MAX : llceil((F32)max_pixels * sScaleX);
// HACK for better bolding
if (style & BOLD)
{
if (this == LLFontGL::sSansSerif)
{
return LLFontGL::sSansSerifBold->render(
wstr, begin_offset,
x, y,
color,
halign, valign,
(style & ~BOLD),
max_chars, max_pixels,
right_x, use_embedded);
}
}
F32 drop_shadow_strength = 0.f;
if (style & (DROP_SHADOW | DROP_SHADOW_SOFT))
{
F32 luminance;
color.calcHSL(NULL, NULL, &luminance);
drop_shadow_strength = clamp_rescale(luminance, 0.35f, 0.6f, 0.f, 1.f);
if (luminance < 0.35f)
{
style = style & ~(DROP_SHADOW | DROP_SHADOW_SOFT);
}
}
gGL.pushMatrix();
glLoadIdentity();
gGL.translatef(floorf(sCurOrigin.mX*sScaleX), floorf(sCurOrigin.mY*sScaleY), sCurOrigin.mZ);
//glScalef(sScaleX, sScaleY, 1.0f);
// avoid half pixels
// RN: if we're going to this trouble, might as well snap to nearest pixel all the time
// but the plan is to get rid of this so that fonts "just work"
//F32 half_pixel_distance = llabs(fmodf(sCurOrigin.mX * sScaleX, 1.f) - 0.5f);
//if (half_pixel_distance < PIXEL_BORDER_THRESHOLD)
//{
gGL.translatef(PIXEL_CORRECTION_DISTANCE*sScaleX, 0.f, 0.f);
//}
// this code would just snap to pixel grid, although it seems to introduce more jitter
//F32 pixel_offset_x = llround(sCurOrigin.mX * sScaleX) - (sCurOrigin.mX * sScaleX);
//F32 pixel_offset_y = llround(sCurOrigin.mY * sScaleY) - (sCurOrigin.mY * sScaleY);
//gGL.translatef(-pixel_offset_x, -pixel_offset_y, 0.f);
// scale back to native pixel size
//glScalef(1.f / sScaleX, 1.f / sScaleY, 1.f);
//glScaled(1.0 / (F64) sScaleX, 1.0 / (F64) sScaleY, 1.0f);
LLFastTimer t(LLFastTimer::FTM_RENDER_FONTS);
gGL.color4fv( color.mV );
S32 chars_drawn = 0;
S32 i;
S32 length;
if (-1 == max_chars)
{
length = (S32)wstr.length() - begin_offset;
}
else
{
length = llmin((S32)wstr.length() - begin_offset, max_chars );
}
F32 cur_x, cur_y, cur_render_x, cur_render_y;
// Bind the font texture
mImageGLp->bind(0);
// Not guaranteed to be set correctly
gGL.setSceneBlendType(LLRender::BT_ALPHA);
//.........这里部分代码省略.........