public void UpdateOptionLabels() { slider_coplanar_angle.ValueText = m_coplanar_tol.ToString(); slider_extrude_length.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_extrude_length); slider_inset_bevel.ValueText = m_inset_pct.ToString(); slider_inset_length.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_inset_length); slider_bevel_width.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_bevel_width); slider_sizex.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_size_x); slider_sizey.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_size_y); slider_sizeheight.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_size_height); slider_sizesegments.ValueText = m_size_segments.ToString(); label_editmode.Text = "Mode: " + m_edit_mode.ToString(); label_pivotmode.Text = "Pivot: " + m_pivot_mode.ToString(); label_scalemode.Text = "Scale: " + m_scale_mode.ToString(); slider_grid_spacing.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_grid_spacing); slider_grid_snap.ValueText = Utility.ConvertFloatTo1Thru3Dec(m_grid_snap); slider_grid_width.ValueText = m_grid_width.ToString(); label_grid_display.Text = "Display: " + m_grid_display.ToString(); label_view_layout.Text = "Layout: " + m_view_layout.ToString(); label_view_persp.Text = "Persp: " + m_view_mode_persp.ToString(); label_view_ortho.Text = "Ortho: " + m_view_mode_ortho.ToString(); label_view_dark.Text = "Background: " + m_bg_color.ToString(); label_gimbal.Text = "Gimbal: " + m_gimbal_display.ToString(); label_lighting.Text = "Lighting: " + m_lighting_type.ToString(); label_vert_display.Text = "Vert Normals: " + m_vert_display.ToString(); label_poly_filter.Text = "PolyFilter: " + m_vis_type.ToString(); slider_smooth_angle_diff.ValueText = m_dmesh.smooth_angle_diff.ToString(); slider_smooth_angle_same.ValueText = m_dmesh.smooth_angle_same.ToString(); }
/// <summary> /// Fits the specified image to the supplied max width and height. /// </summary> /// <param name="image">The image.</param> /// <param name="maxWidth">Width of the max.</param> /// <param name="maxHeight">Height of the max.</param> /// <param name="fitMode">The fit mode.</param> /// <param name="scaleMode">The scale mode.</param> /// <param name="alignMode">The align mode.</param> /// <param name="format">The format.</param> /// <param name="quality">The quality.</param> /// <param name="colors">The colors.</param> /// <param name="bgColor">Color of the background.</param> /// <returns></returns> public static IFilteredImage Fit(this IFilteredImage image, int maxWidth, int maxHeight, FitMode fitMode = FitMode.Pad, ScaleMode scaleMode = ScaleMode.Down, AlignMode alignMode = AlignMode.MiddleCenter, ImageFormat format = ImageFormat.Auto, int quality = 90, int colors = 256, string bgColor = "") { image.Filters.Add("w", maxWidth); image.Filters.Add("h", maxHeight); if (fitMode != FitMode.Pad) { image.Filters.Add("mode", fitMode.ToString().ToLower()); } if (scaleMode != ScaleMode.Down) { image.Filters.Add("scale", scaleMode.ToString().ToLower()); } if (alignMode != AlignMode.MiddleCenter) { image.Filters.Add("anchor", alignMode.ToString().ToLower()); } if (format != ImageFormat.Auto) { image.Filters.Add("format", format.ToString().ToLower()); } if (quality != 90) { image.Filters.Add("quality", Math.Min(100, Math.Max(0, quality))); } if (colors != 256) { image.Filters.Add("colors", Math.Min(256, Math.Max(2, quality))); } if (!string.IsNullOrEmpty(bgColor)) { image.Filters.Add("bgcolor", bgColor); } return(image); }
public static string writeScale(ScaleMode value) { if (value == ScaleMode.Both) { return("both"); } if (value == ScaleMode.DownscaleOnly) { return("downscaleonly"); } if (value == ScaleMode.UpscaleCanvas) { return("upscalecanvas"); } if (value == ScaleMode.UpscaleOnly) { return("upscaleonly"); } throw new NotImplementedException("Unrecognized ScaleMode value: " + value.ToString()); }
/** * <summary> * Returns the scaling vector needed to go from one vector to another vector. Optionally provide a ScaleMode to determine * how the scaling should be performed. If attempting to find the scale results in an infinity or NAN result, Vector3.zero * will be returned. * </summary> */ public static Vector3 ScaleFromTo(Vector3 from, Vector3 to, ScaleMode scaleMode = ScaleMode.StretchToFill) { Vector3 scale = Vector3.one; scale.x = to.x / from.x; scale.y = to.y / from.y; scale.z = to.z / from.z; Func <float, bool> isInvalid = (value) => { return(float.IsInfinity(value) || float.IsNaN(value)); }; if (isInvalid(scale.x) || isInvalid(scale.y) || isInvalid(scale.z)) { return(Vector3.zero); } switch (scaleMode) { case ScaleMode.ScaleAndCrop: scale.x = scale.y = scale.z = Mathf.Max(scale.x, scale.y); break; case ScaleMode.ScaleToFit: scale.x = scale.y = scale.z = Mathf.Min(scale.x, scale.y); break; case ScaleMode.StretchToFill: //Do nothing break; default: Debug.LogException(new System.NotImplementedException("The Received ScaleMode." + scaleMode.ToString() + " is not implemented.")); break; } return(scale); }
public static Vector2 ScaleFromTo(Vector2 from, Vector2 to, ScaleMode scaleMode = ScaleMode.StretchToFill) { Vector2 scale = Vector2.one; scale.x = to.x / from.x; scale.y = to.y / from.y; switch (scaleMode) { case ScaleMode.ScaleAndCrop: scale.x = scale.y = Mathf.Max(scale.x, scale.y); break; case ScaleMode.ScaleToFit: scale.x = scale.y = Mathf.Min(scale.x, scale.y); break; case ScaleMode.StretchToFill: //Do nothing break; default: Debug.LogException(new System.NotImplementedException("The Received ScaleMode." + scaleMode.ToString() + " is not implemented.")); break; } return(scale); }
public static Vector2 ScaleFromTo(Vector2 from, Vector2 to, ScaleMode scaleMode = ScaleMode.StretchToFill) { Vector2 scale = Vector2.one; scale.x = to.x / from.x; scale.y = to.y / from.y; switch (scaleMode) { case ScaleMode.ScaleAndCrop: scale.x = scale.y = Mathf.Max(scale.x, scale.y); break; case ScaleMode.ScaleToFit: scale.x = scale.y = Mathf.Min(scale.x, scale.y); break; case ScaleMode.StretchToFill: //Do nothing break; default: Debug.LogException(new System.NotImplementedException("The Received ScaleMode." + scaleMode.ToString() + " is not implemented.")); break; } return scale; }
/** * <summary> * Returns the scaling vector needed to go from one vector to another vector. Optionally provide a ScaleMode to determine * how the scaling should be performed. If attempting to find the scale results in an infinity or NAN result, Vector3.zero * will be returned. * </summary> */ public static Vector3 ScaleFromTo(Vector3 from, Vector3 to, ScaleMode scaleMode = ScaleMode.StretchToFill) { Vector3 scale = Vector3.one; scale.x = to.x / from.x; scale.y = to.y / from.y; scale.z = to.z / from.z; Func<float, bool> isInvalid = (value) => { return float.IsInfinity(value) || float.IsNaN(value); }; if (isInvalid(scale.x) || isInvalid(scale.y) || isInvalid(scale.z)) return Vector3.zero; switch (scaleMode) { case ScaleMode.ScaleAndCrop: scale.x = scale.y = scale.z = Mathf.Max(scale.x, scale.y); break; case ScaleMode.ScaleToFit: scale.x = scale.y = scale.z = Mathf.Min(scale.x, scale.y); break; case ScaleMode.StretchToFill: //Do nothing break; default: Debug.LogException(new System.NotImplementedException("The Received ScaleMode." + scaleMode.ToString() + " is not implemented.")); break; } return scale; }
public static UrlBuilder Mode(this UrlBuilder target, ScaleMode mode) { if (mode == ScaleMode.Default) return target; return target.Add("mode", mode.ToString().ToLowerInvariant()); }
/// <summary> /// Fits the specified image to the supplied max width and height. /// </summary> /// <param name="image">The image.</param> /// <param name="maxWidth">Width of the max.</param> /// <param name="maxHeight">Height of the max.</param> /// <param name="fitMode">The fit mode.</param> /// <param name="scaleMode">The scale mode.</param> /// <param name="alignMode">The align mode.</param> /// <param name="format">The format.</param> /// <param name="quality">The quality.</param> /// <param name="colors">The colors.</param> /// <param name="bgColor">Color of the background.</param> /// <returns></returns> public static IFilteredImage Fit(this IFilteredImage image, int maxWidth, int maxHeight, FitMode fitMode = FitMode.Pad, ScaleMode scaleMode = ScaleMode.Down, AlignMode alignMode = AlignMode.MiddleCenter, ImageFormat format = ImageFormat.Auto, int quality = 90, int colors = 256, string bgColor = "") { image.Filters.Add("w", maxWidth); image.Filters.Add("h", maxHeight); if(fitMode != FitMode.Pad) image.Filters.Add("mode", fitMode.ToString().ToLower()); if(scaleMode != ScaleMode.Down) image.Filters.Add("scale", scaleMode.ToString().ToLower()); if(alignMode != AlignMode.MiddleCenter) image.Filters.Add("anchor", alignMode.ToString().ToLower()); if(format != ImageFormat.Auto) image.Filters.Add("format", format.ToString().ToLower()); if(quality != 90) image.Filters.Add("quality", Math.Min(100, Math.Max(0, quality))); if (colors != 256) image.Filters.Add("colors", Math.Min(256, Math.Max(2, quality))); if (!string.IsNullOrEmpty(bgColor)) image.Filters.Add("bgcolor", bgColor); return image; }