public void ScrollCanvas(int dx, int dy) { Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent; view.Hadjustment.Value = Utility.Clamp(dx + view.Hadjustment.Value, view.Hadjustment.Lower, view.Hadjustment.Upper - view.Hadjustment.PageSize); view.Vadjustment.Value = Utility.Clamp(dy + view.Vadjustment.Value, view.Vadjustment.Lower, view.Vadjustment.Upper - view.Vadjustment.PageSize); }
public ColorBgra Apply(float r, float g, float b) { ColorBgra ret = new ColorBgra(); float[] input = new float[] { b, g, r }; for (int i = 0; i < 3; i++) { float v = (input[i] - colorInLow[i]); if (v < 0) { ret[i] = colorOutLow[i]; } else if (v + colorInLow[i] >= colorInHigh[i]) { ret[i] = colorOutHigh[i]; } else { ret[i] = (byte)Utility.Clamp( colorOutLow[i] + (colorOutHigh[i] - colorOutLow[i]) * Math.Pow(v / (colorInHigh[i] - colorInLow[i]), gamma[i]), 0.0f, 255.0f); } } return(ret); }
public void RecenterView(double x, double y) { Gtk.Viewport view = (Gtk.Viewport)PintaCore.Chrome.Canvas.Parent; view.Hadjustment.Value = Utility.Clamp(x * Scale - view.Hadjustment.PageSize / 2, view.Hadjustment.Lower, view.Hadjustment.Upper); view.Vadjustment.Value = Utility.Clamp(y * Scale - view.Vadjustment.PageSize / 2, view.Vadjustment.Lower, view.Vadjustment.Upper); }
public Gdk.Rectangle ClampToImageSize(Gdk.Rectangle r) { int x = Utility.Clamp(r.X, 0, ImageSize.Width); int y = Utility.Clamp(r.Y, 0, ImageSize.Height); int width = Math.Min(r.Width, ImageSize.Width - x); int height = Math.Min(r.Height, ImageSize.Height - y); return(new Gdk.Rectangle(x, y, width, height)); }
public void SetGamma(int index, float val) { if (index < 0 || index >= 3) { throw new ArgumentOutOfRangeException("index", index, "Index must be between 0 and 2"); } gamma[index] = Utility.Clamp(val, 0.1f, 10.0f); UpdateLookupTable(); }
public double BoundLerp(double t) { if (t > 1) { t -= 2; } else if (t < -1) { t += 2; } return(Utility.Clamp(Math.Abs(t), 0, 1)); }
public static Level AutoFromLoMdHi(ColorBgra lo, ColorBgra md, ColorBgra hi) { float[] gamma = new float[3]; for (int i = 0; i < 3; i++) { if (lo[i] < md[i] && md[i] < hi[i]) { gamma[i] = (float)Utility.Clamp(Math.Log(0.5, (float)(md[i] - lo[i]) / (float)(hi[i] - lo[i])), 0.1, 10.0); } else { gamma[i] = 1.0f; } } return(new Level(lo, hi, gamma, ColorBgra.Black, ColorBgra.White)); }
private static byte BoundLerp(double t) { return((byte)(Utility.Clamp(Math.Abs(t), 0, 1) * 255f)); }
private byte BoundLerp(double t) { return((byte)(Utility.Clamp(t, 0, 1) * 255f)); }