Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RainbowRodDrawer.cs
Go to the documentation of this file.
4
5namespace Terraria.Graphics;
6
7[StructLayout(LayoutKind.Sequential, Size = 1)]
8public struct RainbowRodDrawer
9{
10 private static VertexStrip _vertexStrip = new VertexStrip();
11
12 public void Draw(Projectile proj)
13 {
14 MiscShaderData miscShaderData = GameShaders.Misc["RainbowRod"];
15 miscShaderData.UseSaturation(-2.8f);
16 miscShaderData.UseOpacity(4f);
17 miscShaderData.Apply();
18 _vertexStrip.PrepareStripWithProceduralPadding(proj.oldPos, proj.oldRot, StripColors, StripWidth, -Main.screenPosition + proj.Size / 2f);
19 _vertexStrip.DrawTrail();
20 Main.pixelShader.CurrentTechnique.Passes[0].Apply();
21 }
22
23 private Color StripColors(float progressOnStrip)
24 {
25 Color value = Main.hslToRgb((progressOnStrip * 1.6f - Main.GlobalTimeWrappedHourly) % 1f, 1f, 0.5f);
26 Color result = Color.Lerp(Color.White, value, Utils.GetLerpValue(-0.2f, 0.5f, progressOnStrip, clamped: true)) * (1f - Utils.GetLerpValue(0f, 0.98f, progressOnStrip));
27 result.A = 0;
28 return result;
29 }
30
31 private float StripWidth(float progressOnStrip)
32 {
33 float num = 1f;
34 float lerpValue = Utils.GetLerpValue(0f, 0.2f, progressOnStrip, clamped: true);
35 num *= 1f - (1f - lerpValue) * (1f - lerpValue);
36 return MathHelper.Lerp(0f, 32f, num);
37 }
38}
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
Vector2 Size
Definition Entity.cs:151
static Dictionary< string, MiscShaderData > Misc
virtual void Apply(DrawData? drawData=null)
MiscShaderData UseSaturation(float saturation)
MiscShaderData UseOpacity(float alpha)
static Effect pixelShader
Definition Main.cs:2764
static Vector2 screenPosition
Definition Main.cs:1715
static Microsoft.Xna.Framework.Color hslToRgb(Vector3 hslVector)
Definition Main.cs:44913
static float GlobalTimeWrappedHourly
Definition Main.cs:405
static float GetLerpValue(float from, float to, float t, bool clamped=false)
Definition Utils.cs:203
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491
Color StripColors(float progressOnStrip)
float StripWidth(float progressOnStrip)