use of pythagoras.f.Point in project playn by threerings.
the class HtmlPointer method eventFromTouch.
private Event.Impl eventFromTouch(final Element rootElement, Touch touch) {
float x = touch.getRelativeX(rootElement), y = touch.getRelativeY(rootElement);
Point xy = platform.graphics().transformMouse(x, y);
return new Event.Impl(new Events.Flags.Impl(), PlayN.currentTime(), xy.x, xy.y, true);
}
use of pythagoras.f.Point in project playn by threerings.
the class HtmlPointer method eventFromMouse.
private Event.Impl eventFromMouse(final Element rootElement, NativeEvent nativeEvent) {
float x = HtmlInput.getRelativeX(nativeEvent, rootElement);
float y = HtmlInput.getRelativeY(nativeEvent, rootElement);
Point xy = platform.graphics().transformMouse(x, y);
return new Event.Impl(new Events.Flags.Impl(), PlayN.currentTime(), xy.x, xy.y, false);
}
use of pythagoras.f.Point in project playn by threerings.
the class HtmlTouch method toEvents.
private Event.Impl[] toEvents(NativeEvent nativeEvent, Events.Flags flags) {
// Convert the JsArray<Native Touch> to an array of Touch.Events
JsArray<com.google.gwt.dom.client.Touch> nativeTouches = nativeEvent.getChangedTouches();
int nativeTouchesLen = nativeTouches.length();
Event.Impl[] touches = new Event.Impl[nativeTouchesLen];
for (int t = 0; t < nativeTouchesLen; t++) {
com.google.gwt.dom.client.Touch touch = nativeTouches.get(t);
float x = touch.getRelativeX(rootElement);
float y = touch.getRelativeY(rootElement);
Point xy = platform.graphics().transformMouse(x, y);
int id = getTouchIdentifier(nativeEvent, t);
touches[t] = new Event.Impl(flags, PlayN.currentTime(), xy.x, xy.y, id);
}
return touches;
}
use of pythagoras.f.Point in project playn by threerings.
the class LayerUtilTest method testTransformWithScale.
@Test
public void testTransformWithScale() {
TestGroupLayer root = new TestGroupLayer();
TestGroupLayer middle = new TestGroupLayer();
TestLayer child = new TestLayer();
root.add(middle);
middle.add(child);
middle.setScale(2f, 0.1f);
Point point = new Point(100f, 100f);
Point pointOnChild = new Point(0f, 0f);
Layer.Util.screenToLayer(child, point, pointOnChild);
assertEquals(point.x() * 0.5, pointOnChild.x(), tol);
assertEquals(point.y() * 10, pointOnChild.y(), tol);
Point pointOnParent = new Point(0f, 0f);
Layer.Util.layerToScreen(child, pointOnChild, pointOnParent);
assertEquals(point.x(), pointOnParent.x(), tol);
assertEquals(point.y(), pointOnParent.y(), tol);
root.clear();
}
Aggregations