From 7aafd590f699efcd53863e18c304240207ab64bb Mon Sep 17 00:00:00 2001 From: yugecin Date: Sun, 25 Dec 2016 14:19:22 +0100 Subject: [PATCH] QuadraticStoryboardMover --- .../sbv2/movers/QuadraticStoryboardMover.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/yugecin/opsudance/sbv2/movers/QuadraticStoryboardMover.java diff --git a/src/yugecin/opsudance/sbv2/movers/QuadraticStoryboardMover.java b/src/yugecin/opsudance/sbv2/movers/QuadraticStoryboardMover.java new file mode 100644 index 00000000..769f209b --- /dev/null +++ b/src/yugecin/opsudance/sbv2/movers/QuadraticStoryboardMover.java @@ -0,0 +1,49 @@ +/* + * opsu!dance - fork of opsu! with cursordance auto + * Copyright (C) 2016 yugecin + * + * opsu!dance is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * opsu!dance is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with opsu!dance. If not, see . + */ +package yugecin.opsudance.sbv2.movers; + +import itdelatrisu.opsu.objects.curves.Vec2f; +import org.newdawn.slick.Color; + +public class QuadraticStoryboardMover extends StoryboardMultipointMover { + + public QuadraticStoryboardMover() { + super(Color.magenta, Color.blue); + } + + @Override + public void setInitialStart(Vec2f start) { + super.setInitialStart(start); + super.addPoint(new Vec2f((start.x + end.x) / 2, (start.y + end.y) / 2)); + } + + @Override + public float[] getPointAt(float t) { + float ct = 1f - t; + return new float[] { + ct * ct * start.x + ct * 2 * t * getPoint(0).x + t * t * end.x, + ct * ct * start.y + ct * 2 * t * getPoint(0).y + t * t * end.y, + }; + } + + @Override + public float getLength() { + return length; + } + +}