public override void Paint(Surface <T> surface, float weight, VectorF2 point) { int left = (int)point.x; int bottom = (int)point.y; float right_width = point.x - left; float left_width = 1.0f - right_width; float top_height = point.y - bottom; float bottom_height = 1.0f - top_height; int right = left + 1; int top = bottom + 1; float left_bottom_area = left_width * bottom_height; float right_bottom_area = right_width * bottom_height; float left_top_area = left_width * top_height; float right_top_area = right_width * top_height; PaintInternal(surface, left, bottom, left_bottom_area * weight, pigment_mixer); PaintInternal(surface, right, bottom, right_bottom_area * weight, pigment_mixer); PaintInternal(surface, left, top, left_top_area * weight, pigment_mixer); PaintInternal(surface, right, top, right_top_area * weight, pigment_mixer); }
static public bool TryCreateStrictMinMaxRectF(VectorF2 min, VectorF2 max, out RectF output) { bool result = true; float x = min.x; float y = min.y; float width = max.x - min.x; float height = max.y - min.y; if (width < 0.0f) { x = (min.x + max.x) * 0.5f; width = 0.0f; result = false; } if (height < 0.0f) { y = (min.y + max.y) * 0.5f; height = 0.0f; result = false; } output = new RectF(x, y, x + width, y + height); return(result); }
static public RectF CreateStrictMinMaxRectF(VectorF2 min, VectorF2 max) { RectF rect; TryCreateStrictMinMaxRectF(min, max, out rect); return(rect); }
static public void PushPopTransform(this Canvas item, VectorF2 position, float angle, VectorF2 scale, Process process) { item.Save(); item.Transform(position, angle, scale); process(); item.Restore(); }
public VectorI2 GetRawValue() { VectorF2 vector = stick.GetRawValue(); return(new VectorI2( (vector.x > threshold).ConvertBool(1) + (vector.x < -threshold).ConvertBool(-1), (vector.y > threshold).ConvertBool(1) + (vector.y < -threshold).ConvertBool(-1) )); }
public GamepadComponent_Stick(GamepadStickId i, InputAtomLockType l) : base(i, l) { value = VectorF2.ZERO; magnitude = 0.0f; angle_in_degrees = 0.0f; frozen_value = VectorF2.ZERO; frozen_magnitude = 0.0f; frozen_angle_in_degrees = 0.0f; stick_zones = new GamepadEventLog <GamepadStickZone>(64); }
protected override void MarkLineInternal(Surface <T> surface, Utensil <T> utensil, VectorF2 point1, VectorF2 point2) { VectorF2 diff = point2 - point1; VectorF2 step_diff = diff; Marker_Stroker <T> stroker = new Marker_Stroker <T>(surface, utensil, point1, internal_tool_line); while (diff.IsComplyingDirection(step_diff)) { VectorF2 point = stroker.Stroke(step_diff.GetJitteredDirectionAngleInRadians(angle_delta) * stroke_length); step_diff = point2 - point; } }
protected override void MarkLineInternal(Surface <T> surface, Utensil <T> utensil, VectorF2 point1, VectorF2 point2) { float distance; float spacing = spacing_in_brush_width_percent * utensil.GetWidth(); VectorF2 step = point1.GetDirection(point2, out distance) * spacing; VectorF2 point = point1; int number_steps = (int)(distance / spacing); utensil.Mark(surface, point); for (int i = 1; i < number_steps; i++) { point += step; utensil.Mark(surface, point); } }
static public void AddRectangle <T>(this SurfaceSelection <T> item, VectorF2 point1, VectorF2 point2) { VectorF2 lower; VectorF2 upper; point1.Order(point2, out lower, out upper); lower = lower.BindBetween(VectorF2.ZERO, item.GetDimensions()); upper = upper.BindBetween(VectorF2.ZERO, item.GetDimensions()); for (float y = lower.y; y <= upper.y; y++) { for (float x = lower.x; x <= upper.x; x++) { item.Add(new VectorF2(x, y)); } } }
static public void Shrinkwrap(this Sprite item) { Texture2D texture = item.texture.Sideload(); RectI2 original = item.rect.GetRectI2(); RectI2 shrunk = texture.ShrinkwrapRect(original); VectorF2 original_pixel_pivot = original.ConvertPercentPointToRangePoint(item.GetNormalizedPivot().GetVectorF2()); VectorF2 shrunk_normalized_pivot = shrunk.ConvertRangePointToPercentPoint(original_pixel_pivot); Rect new_rect = shrunk.GetRect(); Vector2 new_pivot = shrunk_normalized_pivot.GetVector2(); item.ModifySprite(delegate(SerializedProperty property) { property.ForceProperty("m_Rect").rectValue = new_rect; property.ForceProperty("m_Pivot").vector2Value = new_pivot; property.ForceProperty("m_Alignment").intValue = (int)new_pivot.GetSpriteAlignment(); }); }
protected override void UpdateInternal() { value = stick.GetRawValue(); magnitude = value.GetMagnitude(); if (magnitude != 0.0f) { angle_in_degrees = value.GetAngleInDegrees(); } if (magnitude < 0.5f) { stick_zones.LogValue(GamepadStickZone.Center); } else { stick_zones.LogValue( angle_in_degrees.GetDegreeAngleClosestCardinalOrdinalDirection().GetGamepadStickZone() ); } }
static public void DrawCircle(this Canvas item, VectorF2 center, float radius, Paint paint) { item.DrawCircle(center.x, center.y, radius, paint); }
static public bool Add <T>(this SurfaceSelection <T> item, VectorF2 point) { return(item.Add(point.GetVectorI2())); }
public abstract void Mark(Surface <T> surface, VectorF2 point);
public override void Paint(Surface <T> surface, Ink <T> ink, VectorF2 point) { ink.Paint(surface, 1.0f, point); }
static public void DrawCenterSquare(this Canvas item, VectorF2 center, float size, Paint paint) { item.DrawCenterRect(center, new VectorF2(size), paint); }
static public void PushPopTransform(this Canvas item, VectorF2 position, Process process) { item.PushPopTransform(position, 0.0f, process); }
static public void Transform(this Canvas item, VectorF2 position, float angle, VectorF2 scale) { item.Translate(position); item.Rotate(angle); item.Scale(scale); }
static public void DrawArc(this Canvas item, VectorF2 center, VectorF2 size, float angle1, float angle2, bool use_center, Paint paint) { item.DrawArc(RectFExtensions.CreateCenterRectF(center, size), angle1, angle2 - angle1, use_center, paint); }
static public RectF CreateCenterRectF(VectorF2 center, float size) { return(CreateCenterRectF(center, new VectorF2(size))); }
static public Vector2Int GetVector2Int(this VectorF2 item) { return(new Vector2Int((int)item.x, (int)item.y)); }
public abstract void Paint(Surface <T> surface, float weight, VectorF2 point);
static public RectF CreateMinMaxRectF(VectorF2 min, VectorF2 max) { min.Order(max, out min, out max); return(CreateStrictMinMaxRectF(min, max)); }
public override void Mark(Surface <T> surface, VectorF2 point) { brush.Paint(surface, ink, point); }
static public void LineTo(this Path item, VectorF2 point) { item.LineTo(point.x, point.y); }
static public void DrawOval(this Canvas item, VectorF2 center, VectorF2 size, Paint paint) { item.DrawOval(RectFExtensions.CreateCenterRectF(center, size), paint); }
static public void DrawLine(this Canvas item, VectorF2 point1, VectorF2 point2, Paint paint) { item.DrawLine(point1.x, point1.y, point2.x, point2.y, paint); }
static public void PushPopTransform(this Canvas item, VectorF2 position, float angle, Process process) { item.PushPopTransform(position, angle, VectorF2.ONE, process); }
static public RectF CreateCenterRectF(VectorF2 center, VectorF2 size) { VectorF2 extent = size * 0.5f; return(CreateMinMaxRectF(center - extent, center + extent)); }
static public void DrawCenterRoundSquare(this Canvas item, VectorF2 center, float size, float radius, Paint paint) { item.DrawCenterRoundRect(center, new VectorF2(size), radius, paint); }