コード例 #1
0
 // OnProcess
 protected unsafe override void OnProcess(FontSpriteList list)
 {
     fixed(FontSprite *pSpriteStart = &list.Sprites[0])
     for (int i = list.RenderStart; i < list.RenderEnd; ++i)
     {
         (pSpriteStart + i)->Colors.MultA((byte)(Lerp.Adjust(SpriteTimes01[i], LerpType) * 255.0f));
     }
 }
コード例 #2
0
        // CopyTo
        public void CopyTo( FontSpriteList o )
        {
            o.RenderPass = RenderPass;
            o.Layer = Layer;

            for ( int i = 0; i < Sprites.Length; ++i )
            o.Sprites[ i ] = Sprites[ i ];

            o.RenderStart = RenderStart;
            o.RenderEnd = RenderEnd;
        }
コード例 #3
0
        // OnProcess
        protected unsafe override void OnProcess(FontSpriteList list)
        {
            list.RenderEnd = list.RenderStart + CurrentSprite;

            FontData fontData = Widget.FontStyle.Font.FontData;

            float scale = Widget.RenderSizeY / fontData.FontHeight;
            float multY = Widget.UpY;

            fixed(FontDataChar *pCharDataStart = &fontData.Characters[0])
            fixed(FontSprite * pSpriteStart = &list.Sprites[0])
            {
                for (int i = list.RenderStart; i < list.RenderEnd; ++i)
                {
                    FontSprite *pSprite = (pSpriteStart + i);

                    if (pSprite->IconIndex != -1)
                    {
                        continue;
                    }

                    float time01 = SpriteTimes01[i];

                    if (time01 == 1.0f)
                    {
                        continue;
                    }

                    char c = (char)Rand.Next(97, 123);

                    int           characterIndex = fontData.GetCharacterIndex(pSprite->Character);
                    FontDataChar *pCharData      = (pCharDataStart + characterIndex);

                    int           characterIndexRandom = fontData.GetCharacterIndex(c);
                    FontDataChar *pCharDataRandom      = (pCharDataStart + characterIndexRandom);

                    pSprite->Position.X -= (pCharData->OffsetX * scale);
                    pSprite->Position.Y -= (pCharData->OffsetY * scale) * multY;

                    pSprite->Position.X += (pCharDataRandom->OffsetX * scale);
                    pSprite->Position.Y += (pCharDataRandom->OffsetY * scale) * multY;

                    pSprite->Size.X = pCharDataRandom->Width * scale;
                    pSprite->Size.Y = pCharDataRandom->Height * scale;

                    pSprite->Texture.PUV.X = (float)pCharDataRandom->X / fontData.TextureWidth;
                    pSprite->Texture.PUV.Y = (float)pCharDataRandom->Y / fontData.TextureHeight;
                    pSprite->Texture.SUV.X = (float)pCharDataRandom->Width / fontData.TextureWidth;
                    pSprite->Texture.SUV.Y = (float)pCharDataRandom->Height / fontData.TextureHeight;
                }
            }
        }
コード例 #4
0
ファイル: FontSprite.cs プロジェクト: swiercc/SpacebarClicker
        // CopyTo
        public void CopyTo(FontSpriteList o)
        {
            o.RenderPass = RenderPass;
            o.Layer      = Layer;

            for (int i = 0; i < Sprites.Length; ++i)
            {
                o.Sprites[i] = Sprites[i];
            }

            o.RenderStart = RenderStart;
            o.RenderEnd   = RenderEnd;
        }
コード例 #5
0
        // OnProcess
        protected unsafe override void OnProcess(FontSpriteList list)
        {
            fixed(FontSprite *pSpriteStart = &list.Sprites[0])
            {
                for (int i = list.RenderStart; i < list.RenderEnd; ++i)
                {
                    FontSprite *pSprite = (pSpriteStart + i);

                    SpriteColors c = Colors;
                    c.MultA(ref pSprite->Colors);

                    if (pSprite->Colors.PreMultipliedAlpha)
                    {
                        c.ToPremultiplied();
                    }

                    pSprite->Colors.Lerp(ref pSprite->Colors, ref c, Lerp.Adjust(SpriteTimes01[i], LerpType));
                }
            }
        }
コード例 #6
0
ファイル: Text.cs プロジェクト: swiercc/SpacebarClicker
        // OnInit
        protected override void OnInit()
        {
            RenderState.BlendState = E_BlendState.NonPremultiplied;     // handled in the FontStyle

            RenderSizeX = Size.X;
            RenderSizeY = Size.Y;

            if (FontStyleName != null)
            {
                FontStyle = _UI.Store_FontStyle.Get(FontStyleName);
            }

            for (int i = 0; i < FontEffects.Count; ++i)
            {
                FontEffects[i].Bind(this);
            }

            if (Cache && (SpriteListCache == null))
            {
                SpriteListCache = new FontSpriteList();
            }
        }
コード例 #7
0
        // OnProcess
        protected unsafe override void OnProcess(FontSpriteList list)
        {
            float multY = Widget.UpY;

            fixed(FontSprite *pSpriteStart = &list.Sprites[0])
            {
                for (int i = list.RenderStart; i < list.RenderEnd; ++i)
                {
                    FontSprite *pSprite = (pSpriteStart + i);

                    float time01 = Lerp.Adjust(SpriteTimes01[i], LerpType);

                    float scaleX = ScaleFromX + (ScaleToX - ScaleFromX) * time01;
                    float scaleY = ScaleFromY + (ScaleToY - ScaleFromY) * time01;

                    pSprite->Position.X -= (pSprite->Size.X * (scaleX - 1.0f) * 0.5f);
                    pSprite->Position.Y -= (pSprite->Size.Y * (scaleY - 1.0f) * 0.5f) * multY;

                    pSprite->Size.X *= scaleX;
                    pSprite->Size.Y *= scaleY;
                }
            }
        }
コード例 #8
0
ファイル: FontStyle.cs プロジェクト: JacobNorlin/project-duck
        // Render
        public unsafe void Render( FontSpriteList list, float height )
        {
            fixed ( FontSprite *pSpriteStart = &list.Sprites[ 0 ] )
            {
            for ( int i = 0; i < RenderPasses.Count; ++i )
            {
                FontStyleRenderPass renderPass = RenderPasses[ i ];

                FontSprite *pSprite = ( pSpriteStart + list.RenderStart );

                for ( int j = list.RenderStart; j < list.RenderEnd; ++j, ++pSprite )
                {
                    bool isIcon = ( pSprite->IconIndex != -1 );

                    SpriteColors colors;

                    if ( !renderPass.ColorOverride.HasValue )
                        colors = pSprite->Colors;
                    else
                    {
                        colors = renderPass.ColorOverride.Value;
                        colors.MultA( ref pSprite->Colors );

                        if ( pSprite->Colors.PreMultipliedAlpha )
                            colors.ToPremultiplied();
                    }

                    if ( renderPass.AlphaMult != 1.0f )
                        colors.MultA( (byte)( renderPass.AlphaMult * 255.0f ) );

                    // should this be auto-adjusted for 3d? I'm not convinced atm ...
                    Vector3 position = pSprite->Position + ( renderPass.OffsetProportional ? ( renderPass.Offset * height ) : renderPass.Offset );

                    if ( isIcon )
                    {
                        FontIcon fontIcon = _UI.Store_FontIcon.Get( pSprite->IconIndex );
                        _UI.Sprite.AddSprite( list.RenderPass, list.Layer + fontIcon.LayerOffset, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref fontIcon.RenderState );
                    }
                    else
                        _UI.Sprite.AddSprite( list.RenderPass, list.Layer, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref RenderState );

                    _UI.Sprite.AddTexture( 0, ref pSprite->Texture );

                    if ( !isIcon && ( renderPass.TextureIndex != -1 ) )
                    {
                        Vector2 puv = new Vector2();
                        Vector2 suv = new Vector2( 1.0f );

                        switch ( renderPass.TextureMode )
                        {
                            case E_FontStyleTextureMode.Character:
                            {
                                puv.X = pSprite->Texture.PUV.X;
                                puv.Y = pSprite->Texture.PUV.Y;
                                suv.X = pSprite->Texture.SUV.X;
                                suv.Y = pSprite->Texture.SUV.Y;
                                break;
                            }
                            case E_FontStyleTextureMode.Shift:
                            {
                                puv.X = pSprite->Texture.PUV.X;
                                suv.X = pSprite->Size.X / pSprite->Size.Y;
                                break;
                            }
                            case E_FontStyleTextureMode.PositionShift:
                            {
                                puv.X = pSprite->Texture.PUV.X + ( pSprite->Position.X * 0.5f );
                                suv.X = pSprite->Size.X / pSprite->Size.Y;
                                break;
                            }
                        }

                        _UI.Sprite.AddTexture( 1, renderPass.TextureIndex, ref puv, ref suv );
                    }
                }
            }
            }
        }
コード例 #9
0
ファイル: FontEffect.cs プロジェクト: tuannsofta/kinect4bag
 // OnProcess
 protected unsafe override void OnProcess( FontSpriteList list )
 {
     fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] )
     for ( int i = list.RenderStart; i < list.RenderEnd; ++i )
         ( pSpriteStart + i )->Colors.MultA( (byte)( Lerp.Adjust( SpriteTimes01[ i ], LerpType ) * 255.0f ) );
 }
コード例 #10
0
ファイル: FontEffect.cs プロジェクト: tuannsofta/kinect4bag
        // OnProcess
        protected unsafe override void OnProcess( FontSpriteList list )
        {
            fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] )
            {
            for ( int i = list.RenderStart; i < list.RenderEnd; ++i )
            {
                FontSprite* pSprite = ( pSpriteStart + i );

                SpriteColors c = Colors;
                c.MultA( ref pSprite->Colors );

                if ( pSprite->Colors.PreMultipliedAlpha )
                    c.ToPremultiplied();

                pSprite->Colors.Lerp( ref pSprite->Colors, ref c, Lerp.Adjust( SpriteTimes01[ i ], LerpType ) );
            }
            }
        }
コード例 #11
0
ファイル: FontEffect.cs プロジェクト: tuannsofta/kinect4bag
        // OnProcess
        protected unsafe override void OnProcess( FontSpriteList list )
        {
            float multY = Widget.UpY;

            fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] )
            {
            for ( int i = list.RenderStart; i < list.RenderEnd; ++i )
            {
                FontSprite* pSprite = ( pSpriteStart + i );

                float time01 = Lerp.Adjust( SpriteTimes01[ i ], LerpType );

                float scaleX = ScaleFromX + ( ScaleToX - ScaleFromX ) * time01;
                float scaleY = ScaleFromY + ( ScaleToY - ScaleFromY ) * time01;

                pSprite->Position.X -= ( pSprite->Size.X * ( scaleX - 1.0f ) * 0.5f );
                pSprite->Position.Y -= ( pSprite->Size.Y * ( scaleY - 1.0f ) * 0.5f ) * multY;

                pSprite->Size.X *= scaleX;
                pSprite->Size.Y *= scaleY;
            }
            }
        }
コード例 #12
0
 // OnProcess
 protected override void OnProcess(FontSpriteList list)
 {
     list.RenderEnd = list.RenderStart + CurrentSprite;
 }
コード例 #13
0
 // OnProcess
 protected virtual void OnProcess(FontSpriteList list)
 {
     //
 }
コード例 #14
0
ファイル: FontEffect.cs プロジェクト: tuannsofta/kinect4bag
 // OnProcess
 protected virtual void OnProcess( FontSpriteList list )
 {
     //
 }
コード例 #15
0
        // Process
        public void Process(FontSpriteList list)
        {
            SpriteCount = list.RenderEnd - list.RenderStart;

            OnProcess(list);
        }
コード例 #16
0
ファイル: Text.cs プロジェクト: tuannsofta/kinect4bag
        // OnInit
        protected override void OnInit()
        {
            RenderState.BlendState = E_BlendState.NonPremultiplied; // handled in the FontStyle

            RenderSizeX = Size.X;
            RenderSizeY = Size.Y;

            if ( FontStyleName != null )
            FontStyle = _UI.Store_FontStyle.Get( FontStyleName );

            for ( int i = 0; i < FontEffects.Count; ++i )
            FontEffects[ i ].Bind( this );

            if ( Cache && ( SpriteListCache == null ) )
            SpriteListCache = new FontSpriteList();
        }
コード例 #17
0
ファイル: FontEffect.cs プロジェクト: tuannsofta/kinect4bag
 // OnProcess
 protected override void OnProcess( FontSpriteList list )
 {
     list.RenderEnd = list.RenderStart + CurrentSprite;
 }
コード例 #18
0
 // FontManager
 public FontManager()
 {
     Fonts = new List< Font >();
     SpriteList = new FontSpriteList();
     StringUI = new StringUI( 16 );
 }
コード例 #19
0
ファイル: FontEffect.cs プロジェクト: tuannsofta/kinect4bag
        // Process
        public void Process( FontSpriteList list )
        {
            SpriteCount = list.RenderEnd - list.RenderStart;

            OnProcess( list );
        }
コード例 #20
0
ファイル: FontEffect.cs プロジェクト: tuannsofta/kinect4bag
        // OnProcess
        protected unsafe override void OnProcess( FontSpriteList list )
        {
            list.RenderEnd = list.RenderStart + CurrentSprite;

            FontData fontData = Widget.FontStyle.Font.FontData;

            float scale = Widget.RenderSizeY / fontData.FontHeight;
            float multY = Widget.UpY;

            fixed ( FontDataChar* pCharDataStart = &fontData.Characters[ 0 ] )
            fixed ( FontSprite* pSpriteStart = &list.Sprites[ 0 ] )
            {
            for ( int i = list.RenderStart; i < list.RenderEnd; ++i )
            {
                FontSprite* pSprite = ( pSpriteStart + i );

                if ( pSprite->IconIndex != -1 )
                    continue;

                float time01 = SpriteTimes01[ i ];

                if ( time01 == 1.0f )
                    continue;

                char c = (char)Rand.Next( 97, 123 );

                int characterIndex = fontData.GetCharacterIndex( pSprite->Character );
                FontDataChar* pCharData = ( pCharDataStart + characterIndex );

                int characterIndexRandom = fontData.GetCharacterIndex( c );
                FontDataChar* pCharDataRandom = ( pCharDataStart + characterIndexRandom );

                pSprite->Position.X -= ( pCharData->OffsetX * scale );
                pSprite->Position.Y -= ( pCharData->OffsetY * scale ) * multY;

                pSprite->Position.X += ( pCharDataRandom->OffsetX * scale );
                pSprite->Position.Y += ( pCharDataRandom->OffsetY * scale ) * multY;

                pSprite->Size.X = pCharDataRandom->Width * scale;
                pSprite->Size.Y = pCharDataRandom->Height * scale;

                pSprite->Texture.PUV.X = (float)pCharDataRandom->X / fontData.TextureWidth;
                pSprite->Texture.PUV.Y = (float)pCharDataRandom->Y / fontData.TextureHeight;
                pSprite->Texture.SUV.X = (float)pCharDataRandom->Width / fontData.TextureWidth;
                pSprite->Texture.SUV.Y = (float)pCharDataRandom->Height / fontData.TextureHeight;
            }
            }
        }
コード例 #21
0
ファイル: FontStyle.cs プロジェクト: swiercc/SpacebarClicker
	// Render
	public unsafe void Render( FontSpriteList list, float height )
	{
		fixed ( FontSprite *pSpriteStart = &list.Sprites[ 0 ] )
		{
			for ( int i = 0; i < RenderPasses.Count; ++i )
			{
				FontStyleRenderPass renderPass = RenderPasses[ i ];

				FontSprite *pSprite = ( pSpriteStart + list.RenderStart );

				for ( int j = list.RenderStart; j < list.RenderEnd; ++j, ++pSprite )
				{
					bool isIcon = ( pSprite->IconIndex != -1 );

					SpriteColors colors;
				
					if ( !renderPass.ColorOverride.HasValue )
						colors = pSprite->Colors;
					else
					{
						colors = renderPass.ColorOverride.Value;
						colors.MultA( ref pSprite->Colors );

						if ( pSprite->Colors.PreMultipliedAlpha )
							colors.ToPremultiplied();
					}

					if ( renderPass.AlphaMult != 1.0f )
						colors.MultA( (byte)( renderPass.AlphaMult * 255.0f ) );

					// should this be auto-adjusted for 3d? I'm not convinced atm ...
					Vector3 position = pSprite->Position + ( renderPass.OffsetProportional ? ( renderPass.Offset * height ) : renderPass.Offset );

					if ( isIcon )
					{
						FontIcon fontIcon = _UI.Store_FontIcon.Get( pSprite->IconIndex );
						_UI.Sprite.AddSprite( list.RenderPass, list.Layer + fontIcon.LayerOffset, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref fontIcon.RenderState );
					}
					else
						_UI.Sprite.AddSprite( list.RenderPass, list.Layer, ref position, pSprite->Size.X, pSprite->Size.Y, E_Align.TopLeft, ref colors, ref RenderState );

					_UI.Sprite.AddTexture( 0, ref pSprite->Texture );

					if ( !isIcon && ( renderPass.TextureIndex != -1 ) )
					{
						Vector2 puv = new Vector2();
						Vector2 suv = new Vector2( 1.0f );

						switch ( renderPass.TextureMode )
						{
							case E_FontStyleTextureMode.Character:
							{
								puv.X = pSprite->Texture.PUV.X;
								puv.Y = pSprite->Texture.PUV.Y;
								suv.X = pSprite->Texture.SUV.X;
								suv.Y = pSprite->Texture.SUV.Y;
								break;
							}
							case E_FontStyleTextureMode.Shift:
							{
								puv.X = pSprite->Texture.PUV.X;
								suv.X = pSprite->Size.X / pSprite->Size.Y;
								break;
							}
							case E_FontStyleTextureMode.PositionShift:
							{
								puv.X = pSprite->Texture.PUV.X + ( pSprite->Position.X * 0.5f );
								suv.X = pSprite->Size.X / pSprite->Size.Y;
								break;
							}
						}

						_UI.Sprite.AddTexture( 1, renderPass.TextureIndex, ref puv, ref suv );
					}
				}
			}
		}
	}
コード例 #22
0
 // FontManager
 public FontManager()
 {
     Fonts      = new List <Font>();
     SpriteList = new FontSpriteList();
     StringUI   = new StringUI(16);
 }