/** * Default constructor. */ public Icon() { size = new Vector2f(); }
public void correctPosition(AABB box2, Collision data) { Vector2f correctionDistance = box2.center.sub(center, new Vector2f()); if (data.distance.x > data.distance.y) { if (correctionDistance.x > 0) { center.add(data.distance.x, 0); } else { center.add(-data.distance.x, 0); } } else { if (correctionDistance.y > 0) { center.add(0, data.distance.y); } else { center.add(0, -data.distance.y); } } }
public float lengthSquared() { return lengthSquared(x, y); }
/** * Set the x and y components to the supplied value. * * @param d * the value of both components * @return this */ public Vector2f set(float d) { return set(d, d); }
@Override public void process(MouseDragEvent event) { widget.getPosition().add(event.getDelta()); }
/** * Returns absolute component position. * * @return position vector. */ public Vector2f getAbsolutePosition() { Vector2f screenPos = new Vector2f(this.position); for (Component parent = this.getParent(); parent != null; parent = parent.getParent()) { screenPos.add(parent.getPosition()); } return screenPos; }
/** * Set this vector to be one of its perpendicular vectors. * * @return this */ public Vector2f perpendicular() { return set(y, x * -1); }
public MouseInput() { previousPos = new Vector2d(-1, -1); currentPos = new Vector2d(0, 0); displVec = new Vector2f(); }
/** * Creates scissor by provided component and it's parent components. * * @param context nanovg context. * @param parent parent component. */ public static void createScissorByParent(long context, Component parent) { List<Component> parents = new ArrayList<>(); while (parent != null) { parents.add(parent); parent = parent.getParent(); } Vector2f pos = new Vector2f(); int size = parents.size(); if (size > 0) { parent = parents.get(size - 1); pos.add(parent.getPosition()); Vector2f s = parent.getSize(); createScissor(context, new Vector4f(pos, s.x, s.y)); if (size > 1) { for (int i = size - 2; i >= 0; i--) { parent = parents.get(i); s = parent.getSize(); pos.add(parent.getPosition()); nvgIntersectScissor(context, pos.x, pos.y, s.x, s.y); } } } }
public Collision getCollision(AABB box2) { Vector2f distance = box2.center.sub(center, new Vector2f()); distance.x = Math.abs(distance.x); distance.y = Math.abs(distance.y); distance.sub(half_extent.add(box2.half_extent, new Vector2f())); return new Collision(distance, distance.x < 0 && distance.y < 0); }
/** * Set the x and y components to the supplied value. * * @param d * the value of both components * @return this */ public Vector2f set(float d) { return set(d, d); }
public float lengthSquared() { return lengthSquared(x, y); }
public MouseInput() { previousPos = new Vector2d(-1, -1); currentPos = new Vector2d(0, 0); displVec = new Vector2f(); }