public void Color(OsbEasing easing, double startTime, double endTime, Color4 startColor, Color4 endColor, int offset = 0, int count = -1) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].Color(easing, startTime, endTime, startColor, endColor); } }
public void Fade(OsbEasing easing, double startTime, double endTime, double startOpacity, double endOpacity, int offset = 0, int count = -1) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].Fade(easing, startTime, endTime, startOpacity, endOpacity); } }
public void Fade(OsbEasing easing, Func <int, double> startTimes, Func <int, double> endTimes, Func <int, double> startOpacities, Func <int, double> endOpacities, int offset = 0, int count = -1) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].Fade(easing, startTimes(i), endTimes(i), startOpacities(i), endOpacities(i)); } }
// so 1.0 refers to the original scales of the sprites in the spriteset public void Scale(OsbEasing easing, double startTime, double endTime, double relativeStartScale, double relativeEndScale, Vector2 origin, double delta = 1000.0 / 60) { foreach (var sprite in Sprites) { Movement movement = new Movement( easing, startTime, endTime, Vector2.Lerp(origin, sprite.PositionAt(startTime), (float)relativeStartScale), Vector2.Lerp(origin, sprite.PositionAt(startTime), (float)relativeEndScale) ); Vector2 originalScale = sprite.ScaleAt(startTime); if (originalScale.X == originalScale.Y) { sprite.Scale(easing, startTime, endTime, originalScale.X * relativeStartScale, originalScale.X * relativeEndScale); } else { sprite.ScaleVec(easing, startTime, endTime, originalScale * (float)relativeStartScale, originalScale * (float)relativeEndScale); } sprite.Move(movement); } }
public OsbSprite SwipePaneNoFade(StoryboardLayer layer, OsbEasing easing, SwipeDirection direction, string file, double start, double end, Vector2 Postion, Vector2 ScaleFrom, Vector2 ScaleTo) { var Origin = OsbOrigin.TopCentre; switch (direction) { case SwipeDirection.Top: Origin = OsbOrigin.BottomCentre; break; case SwipeDirection.Bottom: Origin = OsbOrigin.TopCentre; break; case SwipeDirection.Left: Origin = OsbOrigin.CentreRight; break; case SwipeDirection.Right: Origin = OsbOrigin.CentreLeft; break; } var sprite = layer.CreateSprite(file, Origin); sprite.ScaleVec(easing, start, end, ScaleFrom, ScaleTo); sprite.Move(start, Postion); return(sprite); }
public void ScaleVec(OsbEasing easing, double startTime, double endTime, Vector2 startScale, Vector2 endScale, int offset = 0, int count = -1) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].ScaleVec(easing, startTime, endTime, startScale, endScale); } }
public void Rotate(OsbEasing easing, double startTime, double endTime, Func <int, double> startRotations, Func <int, double> endRotations, int offset = 0, int count = -1) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].Rotate(easing, startTime, endTime, startRotations(i), endRotations(i)); } }
public ParticleParamaters( double start, double end, ParticleDirection particleDir, Vector2Range pos, OsbEasing ease, double dur, int partAmmount, bool randX = false, bool randY = true, bool sameYEnd = false, bool randomYEnd = false, Vector2?scale = null, bool randomScale = false, Vector2?rotation = null, bool randomRotation = false, double fade = 1 ) { this.direction = particleDir; this.Positions = pos; this.easing = ease; this.duration = dur; this.particleAmmount = partAmmount; this.randomX = randX; this.randomY = randY; this.startTime = start; this.endTime = end; this.scale = ((Vector2)scale).Equals(null) ? (Vector2)scale : new Vector2(1, 1); this.rotation = ((Vector2)rotation).Equals(null) ? (Vector2)rotation : new Vector2(0, 0); this.randomRotation = randomRotation; this.randomScale = randomScale; this.sameYEnd = sameYEnd; this.fade = fade; this.randomYEnd = randomYEnd; }
public void MoveTo(OsbEasing easing, double startTime, double endTime, Func <int, Vector2> positions, int offset = 0, int count = -1) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].Move(easing, startTime, endTime, sprites[i].PositionAt(startTime), positions(i)); } }
public void Move(OsbEasing easing, double startTime, double endTime, Vector2 startPosition, Vector2 endPosition, int offset = 0, int count = -1) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].Move(easing, startTime, endTime, startPosition, endPosition); } }
/// <summary> /// Returns the Fast Fourier Transform of the song at a certain time, with the specified amount of magnitudes. /// Useful to make spectrum effets. /// </summary> public float[] GetFft(double time, int magnitudes, string path = null, OsbEasing easing = OsbEasing.None) { var fft = GetFft(time, path); if (magnitudes == fft.Length && easing == OsbEasing.None) { return(fft); } var resultFft = new float[magnitudes]; var baseIndex = 0; for (var i = 0; i < magnitudes; i++) { var progress = EasingFunctions.Ease(easing, (double)i / magnitudes); var index = Math.Min(Math.Max(baseIndex + 1, (int)(progress * fft.Length)), fft.Length - 1); var value = 0f; for (var v = baseIndex; v < index; v++) { value = Math.Max(value, fft[index]); } resultFft[i] = value; baseIndex = index; } return(resultFft); }
protected Command(string identifier, OsbEasing easing, double startTime, double endTime, TValue startValue, TValue endValue) { Identifier = identifier; Easing = easing; StartTime = startTime; EndTime = endTime; StartValue = startValue; EndValue = endValue; }
private void Move(OsbEasing easing, int startTime, int endTime, int startY, int endY) { var offsetY = 0; foreach (var background in backgroundList) { background.MoveY(easing, startTime, endTime, startY + offsetY, endY + offsetY); offsetY -= 480; } }
private void sdScroll(double startTime, string path, double duration, OsbEasing easing) { float sdScale = 0.65f; var sprite = GetLayer("").CreateSprite(path, OsbOrigin.Centre); sprite.Fade(OsbEasing.InExpo, startTime, startTime + 114, 0, 1); sprite.MoveX(OsbEasing.OutCirc, startTime, startTime + 227, 1067, 320); sprite.Scale(OsbEasing.OutBack, startTime, startTime + 227, sdScale * 0.2, sdScale); sprite.MoveX(easing, startTime + 227, startTime + duration, 320, -427); sprite.Fade(startTime + duration, 0); }
public void Move3D( OsbEasing easing, double startTime, double endTime, Func <int, Vector3> startPositions, Func <int, Vector3> endPositions, float fov, Action <OsbSprite, Vectors.ProjectionResult, Vectors.ProjectionResult> secondaryAction = null, int offset = 0, int count = -1 ) { for (int i = offset; i < (count < 0 ? Sprites.Count() : count + offset); i++) { sprites[i].Move3D(easing, startTime, endTime, startPositions(i), endPositions(i), fov, secondaryAction); } }
public void ScaleAndRotate(OsbEasing easing, double startTime, double endTime, double scaleFactor, Vector2 origin, double rotation = 0, double delta = 1000.0 / 60) { if (endTime - startTime <= 0 || (scaleFactor == 1 && rotation == 0) || delta == 0) { return; } foreach (var sprite in Sprites) { Movement movement = new Movement( easing, startTime, endTime, sprite.PositionAt(startTime), Vector2.Lerp(origin, sprite.PositionAt(startTime), (float)scaleFactor) ); if (scaleFactor != 1) { Vector2 originalScale = sprite.ScaleAt(startTime); if (originalScale.X == originalScale.Y) { sprite.Scale(easing, startTime, endTime, originalScale.X, originalScale.X * scaleFactor); } else { sprite.ScaleVec(easing, startTime, endTime, originalScale, originalScale * (float)scaleFactor); } } if (rotation != 0) { Movement split = movement.ResampledSection(startTime, endTime, delta); foreach (var command in split.Commands) { var ease = easing.ToEasingFunction(); command.StartValue = ((Vector2)command.StartValue) .rotated(rotation * ease((command.StartTime - startTime) / (endTime - startTime)), origin); command.EndValue = ((Vector2)command.EndValue) .rotated(rotation * ease((command.EndTime - startTime) / (endTime - startTime)), origin); } sprite.Move(split); sprite.Rotate(easing, startTime, endTime, sprite.RotationAt(startTime), sprite.RotationAt(startTime) + rotation); continue; } sprite.Move(movement); } }
/// <summary> /// Creates litle particles that dispirse from the hitobject and ease into the centre location /// </summary> public void PPHitLight(OsbSpritePool pool, List <intRange> ranges, intRange particleAmmount, Vector2 CentreLocation, OsbEasing easing = OsbEasing.None, int duration = 1000) { // Only effect hti object start positions. using (pool) { foreach (var hitobject in MainStoryboard.Instance.Beatmap.HitObjects) { foreach (var range in ranges) { if (InTime((int)hitobject.StartTime, range.from, range.to, 5) || InTime((int)hitobject.EndTime, range.from, range.to, 5)) { for (int i = 0; i < Random(particleAmmount.from, particleAmmount.to); i++) { var angle = Random(0, Math.PI * 2); var radius = Random(50, 200); var position = new Vector2( hitobject.Position.X + (float)Math.Cos(angle) * radius, hitobject.Position.Y + (float)Math.Sin(angle) * radius ); var sprite = pool.Get(hitobject.StartTime - 100, hitobject.StartTime + duration * 1.5); sprite.Fade(hitobject.StartTime, 1); sprite.Move(OsbEasing.OutExpo, hitobject.StartTime, hitobject.StartTime + duration, hitobject.Position, position); sprite.Move(OsbEasing.None, hitobject.StartTime + duration, hitobject.StartTime + duration * 1.5, position, CentreLocation); if ((hitobject.StartTime + duration * 1.5) > range.to) { sprite.Fade(hitobject.StartTime + 100, range.to, 1, 0); } else { sprite.Fade(hitobject.StartTime + duration * 1.5, 0); } } } } } } }
public static void Move3D( this OsbSprite sprite, OsbEasing easing, double startTime, double endTime, Vector3 startPosition, Vector3 endPosition, float fovInDegrees, Action <OsbSprite, Vectors.ProjectionResult, Vectors.ProjectionResult> secondaryAction = null ) { Vectors.ProjectionResult p1 = Vectors.project(startPosition, Vectors.ScreenSize, Vectors.Centre, fovInDegrees); Vectors.ProjectionResult p2 = Vectors.project(endPosition, Vectors.ScreenSize, Vectors.Centre, fovInDegrees); if (p1.screenSpaceVector != p2.screenSpaceVector) { sprite.Move(easing, startTime, endTime, p1.screenSpaceVector, p2.screenSpaceVector); } if (secondaryAction != null) { secondaryAction(sprite, p1, p2); // for handling scale, fade, colour, etc. based on coordinates, distance to camera, etc. } }
public void Glitter(float startTime, float duration, int loopCount) { // Individual triangles glitter a random color. // Original color -> glitter color -> original color // This loops for some time, specified by loopCount. // TODO: Add param for glitter colors. for (int x = 0; x < GridWidth; x++) { for (int y = 0; y < GridHeight; y++) { var s = grid[x, y]; OsbEasing randomEnum = (OsbEasing)(Random(0, 32)); var baseColor = s.ColorAt(startTime); var baseHSV = ToHSB(baseColor); var glitterColor = new Vector3(Random(180, 240), (float)(Random(40, 100) * 0.01), (float)(Random(1, 10) * 0.1)); s.StartLoopGroup(startTime, loopCount); s.ColorHsb(randomEnum, 0, duration / 2, baseHSV.X, baseHSV.Y, baseHSV.Z, glitterColor.X, glitterColor.Y, glitterColor.Z); s.ColorHsb(randomEnum, duration / 2, duration, glitterColor.X, glitterColor.Y, glitterColor.Z, baseHSV.X, baseHSV.Y, baseHSV.Z); s.EndGroup(); } } }
public void click(int time, string notePlayed) { body.ColorHsb(2526, 0, 0, 1); top.ColorHsb(2526, 0, 0, 1); bottom.ColorHsb(2526, 0, 0, 1); float decalage = (float)(25 * scale / 0.1); OsbEasing easeOut = OsbEasing.OutExpo; OsbEasing easeIn = OsbEasing.None; if (notePlayed.Contains('4')) { body.ColorHsb(time, time + 350, 0, 1, 1, 0, 0, 1); top.ColorHsb(time, time + 350, 0, 1, 1, 0, 0, 1); bottom.ColorHsb(time, time + 350, 0, 1, 1, 0, 0, 1); } if (notePlayed.Contains('2')) { body.ColorHsb(time, time + 350, 120, 1, 1, 120, 0, 1); top.ColorHsb(time, time + 350, 120, 1, 1, 120, 0, 1); bottom.ColorHsb(time, time + 350, 120, 1, 1, 120, 0, 1); } if (up) { top.Move(easeOut, time, time + 100, position - new Vector2(0, scale * 100), position - new Vector2(0, scale * 100) - new Vector2(0, decalage)); top.Move(easeIn, time + 100, time + 250, position - new Vector2(0, decalage) - new Vector2(0, scale * 100), position - new Vector2(0, scale * 100)); body.ScaleVec(easeOut, time, time + 100, scale, scale / 2, scale, (decalage + scale * 100) / 200.0); body.ScaleVec(easeIn, time + 100, time + 250, scale, (decalage + scale * 100) / 200.0, scale, scale / 2); } else { bottom.Move(easeOut, time, time + 100, position + new Vector2(0, scale * 100), position + new Vector2(0, scale * 100) + new Vector2(0, decalage)); bottom.Move(easeIn, time + 100, time + 250, position + new Vector2(0, decalage) + new Vector2(0, scale * 100), position + new Vector2(0, scale * 100)); body.ScaleVec(easeOut, time, time + 100, scale, scale / 2, scale, (decalage + scale * 100) / 200.0); body.ScaleVec(easeIn, time + 100, time + 250, scale, (decalage + scale * 100) / 200.0, scale, scale / 2); } }
public void ScaleVec(OsbEasing easing, double startTime, double endTime, double startX, double startY, double endX, double endY) => ScaleVec(easing, startTime, endTime, new CommandScale(startX, startY), new CommandScale(endX, endY));
public void Parameter(OsbEasing easing, double startTime, double endTime, CommandParameter parameter) => addCommand(new ParameterCommand(easing, startTime, endTime, parameter));
public void ColorHsb(OsbEasing easing, double startTime, double endTime, double startHue, double startSaturation, double startBrightness, double endHue, double endSaturation, double endBrightness) => Color(easing, startTime, endTime, CommandColor.FromHsb(startHue, startSaturation, startBrightness), CommandColor.FromHsb(endHue, endSaturation, endBrightness));
public void Color(OsbEasing easing, double startTime, double endTime, double startRed, double startGreen, double startBlue, double endRed, double endGreen, double endBlue) => Color(easing, startTime, endTime, new CommandColor(startRed, startGreen, startBlue), new CommandColor(endRed, endGreen, endBlue));
public void Color(OsbEasing easing, double startTime, double endTime, CommandColor startColor, double endRed, double endGreen, double endBlue) => Color(easing, startTime, endTime, startColor, new CommandColor(endRed, endGreen, endBlue));
public void Color(OsbEasing easing, double startTime, double endTime, CommandColor startColor, CommandColor endColor) => addCommand(new ColorCommand(easing, startTime, endTime, startColor, endColor));
public void Fade(OsbEasing easing, double startTime, double endTime, CommandDecimal startOpacity, CommandDecimal endOpacity) => addCommand(new FadeCommand(easing, startTime, endTime, startOpacity, endOpacity));
public void Rotate(OsbEasing easing, double startTime, double endTime, CommandDecimal startRotation, CommandDecimal endRotation) => addCommand(new RotateCommand(easing, startTime, endTime, startRotation, endRotation));
public void ScaleVec(OsbEasing easing, double startTime, double endTime, CommandScale startScale, CommandScale endScale) => addCommand(new VScaleCommand(easing, startTime, endTime, startScale, endScale));
public void Scale(OsbEasing easing, double startTime, double endTime, CommandDecimal startScale, CommandDecimal endScale) => addCommand(new ScaleCommand(easing, startTime, endTime, startScale, endScale));