public override void OnGotContext(RenderContext context) { base.OnGotContext(context); NotesImage = D2DHelper.LoadBitmap(Definitions.NotesBitmapFilePath, context.RenderTarget); var size = context.ClientSize; var props = new LinearGradientBrushProperties { StartPoint = new RawVector2(size.Height, 0), EndPoint = new RawVector2(0, size.Height) }; var gradientStops = new List <GradientStop>(); var colorCount = RibbonColors.Length; for (var i = 0; i < colorCount; ++i) { gradientStops.Add(new GradientStop { Color = RibbonColors[i].ColorToRC4(), Position = (float)i / (colorCount - 1) }); } var collection = new GradientStopCollection(context.RenderTarget, gradientStops.ToArray(), ExtendMode.Wrap); RibbonBrush = new LinearGradientBrushEx(context.RenderTarget, props, collection); SyncLinePen = new Pen(Color.White, 3, context); }
private static Color GetRibbonVertexColor(float f, SongColor songColor, bool simple) { var n1 = (int)f; var n2 = n1 + 1; f %= 1; Color[] colors; if (simple) { colors = SimpleWhiteColors; } else { switch (songColor) { case SongColor.All: colors = RainbowColors; break; case SongColor.Cute: colors = CuteColors; break; case SongColor.Cool: colors = CoolColors; break; case SongColor.Passion: colors = PassionColors; break; default: throw new ArgumentOutOfRangeException(nameof(songColor)); } } n1 %= colors.Length; n2 %= colors.Length; var color1 = colors[n1]; var color2 = colors[n2]; return(D2DHelper.Lerp(color1, color2, f)); }
public override void OnGotContext(RenderContext context) { base.OnGotContext(context); _avatarTop = D2DHelper.LoadBitmap(Definitions.TopAvatarsFileName, context.RenderTarget); _avatarBottom = D2DHelper.LoadBitmap(Definitions.BottomAvatarsFileName, context.RenderTarget); }
private void Initialize() { var startTiming = StartNote.HitTiming; var endTiming = EndNote.HitTiming; var finishPosition = EndNote.FinishPosition; var now = Now; var context = RenderContext; var xs = new float[JointCount]; var ys = new float[JointCount]; var rs = new float[JointCount]; var rawConnection = ConnectionType & ConnectionType.RawMask; switch (rawConnection) { case ConnectionType.Hold: for (var i = 0; i < JointCount; ++i) { var timing = (endTiming - startTiming) / (JointCount - 1) * i + startTiming; xs[i] = NotesLayerUtils.GetNoteXPosition(context, now, timing, finishPosition, true, true); ys[i] = NotesLayerUtils.GetNoteYPosition(context, now, timing, true, true); rs[i] = NotesLayerUtils.GetNoteRadius(now, timing); } break; case ConnectionType.Flick: var x1 = NotesLayerUtils.GetNoteXPosition(context, now, StartNote, true, true); var x2 = NotesLayerUtils.GetNoteXPosition(context, now, EndNote, true, true); var y1 = NotesLayerUtils.GetNoteYPosition(context, now, StartNote, true, true); var y2 = NotesLayerUtils.GetNoteYPosition(context, now, EndNote, true, true); var r1 = NotesLayerUtils.GetNoteRadius(now, StartNote); var r2 = NotesLayerUtils.GetNoteRadius(now, EndNote); for (var i = 0; i < JointCount; ++i) { var t = (float)i / (JointCount - 1); xs[i] = D2DHelper.Lerp(x1, x2, t); ys[i] = D2DHelper.Lerp(y1, y2, t); rs[i] = D2DHelper.Lerp(r1, r2, t); } break; default: throw new ArgumentOutOfRangeException(nameof(rawConnection)); } for (var i = 0; i < JointCount; ++i) { var x = xs[i]; var y = ys[i]; var r = rs[i]; RawVector2 vertex1, vertex2; switch (rawConnection) { case ConnectionType.Hold: vertex1 = new RawVector2(x - r, y); vertex2 = new RawVector2(x + r, y); break; case ConnectionType.Flick: float ydif, xdif; if (i == JointCount - 1) { ydif = y - ys[i - 1]; xdif = x - xs[i - 1]; } else { ydif = ys[i + 1] - y; xdif = xs[i + 1] - x; } var rad = (float)Math.Atan2(ydif, xdif); var cos = (float)Math.Cos(rad); var sin = (float)Math.Sin(rad); vertex1 = new RawVector2(x - r * sin, y - r * cos); vertex2 = new RawVector2(x + r * sin, y + r * cos); break; default: throw new ArgumentOutOfRangeException(nameof(rawConnection)); } Vertices[i * 2] = vertex1; Vertices[i * 2 + 1] = vertex2; } }