public static void AnimateWithAction(this Label label, Command command = null, ScaleType type = ScaleType.After) { var tapGesture = new TapGestureRecognizer (); tapGesture.Tapped += async (sender, args) => { switch (type) { case ScaleType.First: command?.Execute (null); await label.ScaleTo (0.75, 100, Easing.CubicOut); await label.ScaleTo (1, 100, Easing.CubicIn); break; case ScaleType.Midle: await label.ScaleTo (0.75, 100, Easing.CubicOut); command?.Execute (null); await label.ScaleTo (1, 100, Easing.CubicIn); break; case ScaleType.After: await label.ScaleTo (0.75, 100, Easing.CubicOut); await label.ScaleTo (1, 100, Easing.CubicIn); command?.Execute (null); break; default: break; } }; label.GestureRecognizers.Add (tapGesture); }
public void InitializeScale(ScaleType scale) { var scaleFactor = 1; switch (scale) { case ScaleType.TwoX: case ScaleType.Hq2x: scaleFactor = 2; break; case ScaleType.ThreeX: case ScaleType.Hq3x: scaleFactor = 3; break; case ScaleType.FourX: case ScaleType.Hq4x: scaleFactor = 4; break; default: break; } baseScale = scale; screenBuffer = new WriteableBitmap(baseWidth * scaleFactor, baseHeight * scaleFactor, 96, 96, PixelFormats.Bgra32, null); updateRegion = new Int32Rect(0, 0, screenBuffer.PixelWidth, screenBuffer.PixelHeight); stride = screenBuffer.PixelWidth * 4; backBuffer = new uint[baseWidth * baseHeight]; frontBuffer = new uint[screenBuffer.PixelWidth * screenBuffer.PixelHeight]; renderWindow.Source = screenBuffer; }
public ScaleDecider(MelodyPlayer.Note note, ScaleType scaleType) { currentScale = CreateScale(note, scaleType); currentScaleType = scaleType; towerUnderHP = false; inTransition = false; clickCounter = 0; random = new Random(); SCALE_CHANGE_HP_TRESHOLD = (App.Instance.Model.Tower.MaxHealth - 100) * 0; }
/// <summary> /// Instanciates a SpriteTextbox. AssetName is the Textbox background assest to load. /// </summary> /// <param name="game"></param> /// <param name="assetName">Name of background Image to load</param> /// <param name="fontName"></param> /// <param name="text"></param> /// <param name="wrapText"></param> /// <param name="scale"></param> /// <param name="textScale"></param> /// <param name="formFactor"></param> public SpriteTextBox(Game game, string assetName, string fontName, string text, bool wrapText, Vector2 scale, Vector2 textScale, ScaleType formFactor, SpriteFont a) { this.Text = text; this.WrapText = wrapText; this.TextScale = textScale; this.TextOffset = Vector2.Zero; this.FontName = fontName; this.FormFactor = formFactor; this.Font = a; }
public PhotoViewDroid(Context context) : base(context, null, 0) { base.SetScaleType(ScaleType.Matrix); mAttacher = new PhotoViewDroidAttacher(this); if (null != mPendingScaleType) { SetScaleType(mPendingScaleType); mPendingScaleType = null; } }
public PhotoViewDroid(Context context, IAttributeSet attr, int defStyle) : base(context, attr, defStyle) { base.SetScaleType(ScaleType.Matrix); mAttacher = new PhotoViewDroidAttacher(this); if (null != mPendingScaleType) { SetScaleType(mPendingScaleType); mPendingScaleType = null; } }
public void ScaleToNormal() { if (Time.timeScale >= timeScaleNormal) { Time.timeScale = timeScaleNormal; return; } if (scaleType == ScaleType.ScaleUp) return; StopScalingTime(); ScaleTime(timeScaleNormal, timeScaleUpDuration); scaleType = ScaleType.ScaleUp; }
public void ScaleToSlow() { if (Time.timeScale <= timeScaleSlow) { Time.timeScale = timeScaleSlow; return; } if (scaleType == ScaleType.ScaleDown) return; StopScalingTime(); ScaleTime(timeScaleSlow, timeScaleDownDuration); scaleType = ScaleType.ScaleDown; }
public static Texture2D rescaleCenter(Texture2D srcTexture, Vector2 destSize, ScaleType scaleType) { var srcSize = new Vector2( srcTexture.width, srcTexture.height); var scale = Texture2DHelpers.scaleFactor( srcSize, destSize, scaleType); var scaledSize = srcSize * scale; // Convert float values to int var srcWidth = srcTexture.width; var scaledWidth = (int) scaledSize.x; var scaledHeight = (int) scaledSize.y; var destWidth = (int) destSize.x; var destHeight = (int) destSize.y; var minX = Helpers.clamp((destWidth - scaledWidth) / 2, 0, destWidth - 1); var maxX = destWidth - 1 - minX; var minY = Helpers.clamp((destHeight - scaledHeight) / 2, 0, destHeight - 1); var maxY = destHeight - 1 - minY; var srcPixels = srcTexture.GetPixels(); var destPixels = new Color[destWidth * destHeight]; for (var destX=0; destX < destWidth; ++destX) { for (var destY=0; destY < destHeight; ++destY) { Color destPixel; if (destX >= minX && destX <= maxX && destY >= minY && destY <= maxY) { var scaledX = destX - minX; var scaledY = destY - minY; var srcX = (int) (scaledX / scale); var srcY = (int) (scaledY / scale); var srcOffset = srcY * srcWidth + srcX; destPixel = srcPixels[srcOffset]; } else { destPixel = fillColor; } var destOffset = destY * destWidth + destX; destPixels[destOffset] = destPixel; } } var destTexture = new Texture2D(destWidth, destHeight); destTexture.SetPixels(destPixels); destTexture.Apply(); return destTexture; }
public SpriteFlatData(string name, Texture2D texture, float width, float height, ScaleType scaleType) { this.name = name; float textureWidth = texture.width; float textureHeight = texture.height; switch (scaleType) { case ScaleType.NONE: this.width = textureWidth; this.height = textureHeight; break; case ScaleType.SCALED_WIDTH: this.width = width; this.height = width * textureHeight / textureWidth; break; case ScaleType.SCALED_HEIGHT: this.width = height * textureWidth / textureHeight; this.height = height; break; case ScaleType.SCALED: default: this.width = width; this.height = height; break; } this.regionWidth = textureWidth; this.regionHeight = texture.wrapMode == TextureWrapMode.Repeat ? this.height * textureWidth / this.width : textureHeight ; Rect region = new Rect(0f, 0f, this.regionWidth, this.regionHeight); Vector2 anchor = new Vector2(this.regionWidth / 2, this.regionHeight / 2); tk2dRuntime.SpriteCollectionSize size = tk2dRuntime.SpriteCollectionSize.ForTk2dCamera(); this.data = tk2dRuntime.SpriteCollectionGenerator.CreateFromTexture(texture, size, region, anchor); this.data.gameObject.name = String.Format("DataSpriteFlat{0}", name); }
public static float scaleFactor(Vector2 srcSize, Vector2 destSize, ScaleType scaleType) { var scaleX = destSize.x / srcSize.x; var scaleY = destSize.y / srcSize.y; float scale; switch (scaleType) { case ScaleType.kCrop: scale = Mathf.Max(scaleX, scaleY); break; case ScaleType.kInside: scale = Mathf.Min(scaleX, scaleY); break; default: Debug.LogWarning("unknow scale type"); scale = 1.0f; break; } return scale; }
/// <summary> /// Scales an image size, preserving aspect ratio. /// </summary> /// <param name="sourceSize"></param> /// <param name="width">Min or max allowed width. Min/Max controlled by the method parameter</param> /// <param name="height">Min or max allowed height. Min/Max controlled by the method parameter</param> /// <param name="method"></param> /// <param name="type"></param> /// <returns></returns> public static Size Scale(this Size sourceSize, int width, int height, ScaleMethod method, ScaleType type) { if (type == ScaleType.Expand && sourceSize.Height > height && sourceSize.Width > width) return sourceSize; if (type == ScaleType.Shrink && sourceSize.Height < height && sourceSize.Width < width) return sourceSize; if (height == 0) height = sourceSize.Height; if (width == 0) width = sourceSize.Width; // calculate the two possible scaling factors var wAr = (float)width / sourceSize.Width; var hAr = (float)height / sourceSize.Height; // pick the scaling factor based on the scale method var ar = method == ScaleMethod.ToFit ? Math.Min(wAr, hAr) : Math.Max(wAr, hAr); return sourceSize.Scale(ar); }
internal GridLines_Internal(Panel container, ScaleType scaleType, double[] points, double minimum, double maximum, double thickness, ChartObjectTag tag, Style lineStyle) : base(container, scaleType, tag) { LineStyle = lineStyle; Thickness = thickness; ReInit(scaleType, points, minimum, maximum); }
internal ScalableChartObject(Panel container, ScaleType scaleType, ChartObjectTag tag) : base(container, tag) { ScaleType = scaleType; }
public GridScale(ScaleType scaleType, double min, double max) { _ScaleType = scaleType; _Min = min; _Max = max; }
internal void ReInit(ScaleType scaleTypeX, ScaleType scaleTypeY, double x0, double xN, double y0, double yN, double[,] points) { ScaleTypeX = scaleTypeX; ScaleTypeY = scaleTypeY; X0 = x0; XN = xN; Y0 = y0; YN = yN; DataPoints = points; Draw(); }
public StandardPartScaler(Part prefab, Part part, ScaleType scaleType, TweakScale ts) : base(prefab, part, scaleType, ts) { }
public override void SetScaleType(ScaleType scale){ if (scale != escala) { throw new AndroidException ("Chingado! Que no le muevas a la escala"); } }
internal virtual void ReInit(ScaleType scaleType, Tuple<double, string>[] points, string dataPointsFormat) { if (Container.ActualHeight == 0.0 || Container.ActualWidth == 0.0 || points == null) return; if (scaleType != ScaleType || points != DataPoints || dataPointsFormat != DataPointsFormat) { ScaleType = scaleType; DataPoints = points; DataPointsFormat = dataPointsFormat; MyTBs.Clear(); ClearChartObjectsWithMyTag(); for (int i = 0; i <= DataPoints.GetUpperBound(0); i++) { TextBlock tb = new TextBlock() { Tag = Tag }; MyTBs.Add(tb); Container.Children.Add(tb); } } Draw(); }
void SetSpaceAndType() { if (Input.GetKey(ActionKey)) { return; } if (Input.GetKeyDown(SetMoveType)) { type = TransformType.Move; } else if (Input.GetKeyDown(SetRotateType)) { type = TransformType.Rotate; } else if (Input.GetKeyDown(SetScaleType)) { type = TransformType.Scale; } if (Input.GetKeyDown(SetPivotModeToggle)) { if (pivot == TransformPivot.Pivot) { pivot = TransformPivot.Center; } else if (pivot == TransformPivot.Center) { pivot = TransformPivot.Pivot; } SetPivotPoint(); } if (Input.GetKeyDown(SetCenterTypeToggle)) { if (centerType == CenterType.All) { centerType = CenterType.Solo; } else if (centerType == CenterType.Solo) { centerType = CenterType.All; } SetPivotPoint(); } if (Input.GetKeyDown(SetSpaceToggle)) { if (space == TransformSpace.Global) { space = TransformSpace.Local; } else if (space == TransformSpace.Local) { space = TransformSpace.Global; } } if (Input.GetKeyDown(SetScaleTypeToggle)) { if (scaleType == ScaleType.FromPoint) { scaleType = ScaleType.FromPointOffset; } else if (scaleType == ScaleType.FromPointOffset) { scaleType = ScaleType.FromPoint; } } if (type == TransformType.Scale) { space = TransformSpace.Local; //Only support local scale if (pivot == TransformPivot.Pivot) { scaleType = ScaleType.FromPoint; //FromPointOffset can be inaccurate and should only really be used in Center mode if desired. } } }
public LinePlot(Transform plotOriginTransform, float[] x, float[] y, Material plotAxisMat, Material plotLineMat, float[] plotDrawScale, float plotLineWidth = 0.01f, ScaleType plotScaleType = ScaleType.linear, float[] plotXaxis = null, float[] plotYaxis = null) { scaleType = plotScaleType; if (scaleType == ScaleType.log10) { for (int i = 0; i < y.Length; i++) { if (y[i] > 0.0001) { y[i] = Mathf.Log10(y[i]); } else { y[i] = -1000f; } } } if (plotXaxis == null) { float max = -1e6f; float min = 1e6f; for (int i = 0; i < x.Length; i++) { if (x[i] > max) { max = x[i]; } if (x[i] < min) { min = x[i]; } } xaxis = new float[2] { 0, max *1.2f }; max = -1e6f; min = 1e6f; for (int i = 0; i < y.Length; i++) { if (y[i] > max) { max = y[i]; } if (y[i] < min) { min = y[i]; } } if (min < 0) { yaxis = new float[2] { min *1.2f, max * 1.2f } } ; else { yaxis = new float[2] { 0, max *1.2f } }; } xdata = x; ydata = y; origin = plotOriginTransform; axisMat = plotAxisMat; lineMat = plotLineMat; drawScale = plotDrawScale; lineWidth = plotLineWidth; Redraw(); }
/** * Controls how the image should be resized or moved to match the size * of this ImageView. * * @param scaleType The desired scaling mode. * @attr ref android.R.styleable#ImageView_scaleType */ public override sealed void SetScaleType(ScaleType scaleType) { if (_mScaleType == scaleType) return; _mScaleType = scaleType; if (scaleType.Equals(ScaleType.Center) || scaleType.Equals(ScaleType.CenterCrop) || scaleType.Equals(ScaleType.CenterInside) || scaleType.Equals(ScaleType.FitCenter) || scaleType.Equals(ScaleType.FitStart) || scaleType.Equals(ScaleType.FitEnd) || scaleType.Equals(ScaleType.FitXy)) { base.SetScaleType(ScaleType.FitXy); } else { base.SetScaleType(scaleType); } UpdateDrawableAttrs(); UpdateBackgroundDrawableAttrs(false); Invalidate(); }
public static void ScaleImage(uint[] inputImage, uint[] outputImage, int baseWidth, int baseHeight, ScaleType baseScale) { switch (baseScale) { case ScaleType.Hq2x: { Hq2x.hq2x_32(inputImage, outputImage, baseWidth, baseHeight); break; } case ScaleType.Hq3x: { Hq3x.hq3x_32(inputImage, outputImage, baseWidth, baseHeight); break; } case ScaleType.TwoX: { for (int y = 0; y < baseHeight; y++) { for (int x = 0; x < baseWidth; x++) { outputImage[(((y * 2) + 0) * baseWidth * 2) + (x * 2) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 2) + 0) * baseWidth * 2) + (x * 2) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 2) + 1) * baseWidth * 2) + (x * 2) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 2) + 1) * baseWidth * 2) + (x * 2) + 1] = inputImage[(y * baseWidth) + x]; } } break; } case ScaleType.ThreeX: { for (int y = 0; y < baseHeight; y++) { for (int x = 0; x < baseWidth; x++) { outputImage[(((y * 3) + 0) * baseWidth * 3) + (x * 3) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 0) * baseWidth * 3) + (x * 3) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 0) * baseWidth * 3) + (x * 3) + 2] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 1) * baseWidth * 3) + (x * 3) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 1) * baseWidth * 3) + (x * 3) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 1) * baseWidth * 3) + (x * 3) + 2] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 2) * baseWidth * 3) + (x * 3) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 2) * baseWidth * 3) + (x * 3) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 3) + 2) * baseWidth * 3) + (x * 3) + 2] = inputImage[(y * baseWidth) + x]; } } break; } case ScaleType.FourX: { for (int y = 0; y < baseHeight; y++) { for (int x = 0; x < baseWidth; x++) { outputImage[(((y * 4) + 0) * baseWidth * 4) + (x * 4) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 0) * baseWidth * 4) + (x * 4) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 0) * baseWidth * 4) + (x * 4) + 2] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 0) * baseWidth * 4) + (x * 4) + 3] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 1) * baseWidth * 4) + (x * 4) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 1) * baseWidth * 4) + (x * 4) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 1) * baseWidth * 4) + (x * 4) + 2] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 1) * baseWidth * 4) + (x * 4) + 3] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 2) * baseWidth * 4) + (x * 4) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 2) * baseWidth * 4) + (x * 4) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 2) * baseWidth * 4) + (x * 4) + 2] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 2) * baseWidth * 4) + (x * 4) + 3] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 3) * baseWidth * 4) + (x * 4) + 0] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 3) * baseWidth * 4) + (x * 4) + 1] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 3) * baseWidth * 4) + (x * 4) + 2] = inputImage[(y * baseWidth) + x]; outputImage[(((y * 4) + 3) * baseWidth * 4) + (x * 4) + 3] = inputImage[(y * baseWidth) + x]; } } break; } default: { for (int i = 0; i < inputImage.Length; i++) { outputImage[i] = inputImage[i]; } break; } } }
static public Management.Monitor.Management.Models.ScaleType ConvertNamespace(ScaleType operatorType) { int value = (int)operatorType; return((Management.Monitor.Management.Models.ScaleType)value); }
internal virtual void ReInit(ScaleType scaleType, double[] points, double minimum, double maximum) { if (Container.ActualHeight == 0.0 || Container.ActualWidth == 0.0 || points == null) return; if (scaleType != ScaleType || points != DataPoints || minimum != Minimum || maximum != Maximum) { ScaleType = scaleType; DataPoints = points; Minimum = minimum; Maximum = maximum; MyLines.Clear(); ClearChartObjectsWithMyTag(); for (int i = 0; i <= DataPoints.GetUpperBound(0); i++) { Line line = new Line() { StrokeThickness = Thickness, Tag = Tag, Style = LineStyle };//TEST MyLines.Add(line); Container.Children.Add(line); } } Draw(); }
internal YGridLines_Internal(Panel container, ScaleType scaleType, double[] points, double minimum, double maximum, double thickness, ChartObjectTag tag, Style lineStyle) : base(container, scaleType, points, minimum, maximum, thickness, tag, lineStyle) { }
public static TimeRequestHandle RequestTimeScale(float timeScale, Object context, ScaleType scaleType, float fadeInDuration) { if (context == null) { Debug.LogError("TimeManager:RequestTimeScale: context was null, ignoring request!"); return null; } TimeRequestHandle trh = new TimeRequestHandle(timeScale, context, scaleType, fadeInDuration); requestList.Add(trh); EvaluateRequests(); return trh; }
internal YGridLabels_Internal(LolloChart root, Panel container, ScaleType scaleType, Tuple<double, string>[] points, string dataPointsFormat, ChartObjectTag tag) : base(root, container, scaleType, points, dataPointsFormat, tag) { }
public TimeRequestHandle(float inScale, Object inContext, ScaleType inScaleType, float inFadeInDuration) { scale = inScale; context = inContext; scaleType = inScaleType; fadeDuration = inFadeInDuration; fadingIn = true; }
/// <summary> /// Activates the scale component with all the set variables. /// The objects scale value will be set to the starting scale value by default. /// </summary> /// <param name="typeOfScaleMode">The type of scale mode which should be used. This variable overrides the existing scale mode setting for this component.</param> public void StartScale(ScaleType typeOfScaleMode) { m_elapsedTime = 0.0f; TypeOfScaleMode = typeOfScaleMode; m_isActive = true; }
internal XYDataSeries_Internal(Panel container, ScaleType scaleTypeX, ScaleType scaleTypeY, double x0, double xN, double y0, double yN, double[,] points, ChartObjectTag tag, Style lineStyle, bool isHistogram = false, StrokeDashArrays sda = StrokeDashArrays.Continue) : base(container, tag) { _isHistogram = isHistogram; if (Dashed.Count == 0) { Dashed.Add(2); Dashed.Add(2); } MyPolyline.Style = lineStyle; MyPolyline.StrokeThickness = LolloChart.DataSeriesThickness; switch (sda) { case StrokeDashArrays.Dashed: MyPolyline.StrokeDashArray = Dashed; break; case StrokeDashArrays.Continue: MyPolyline.StrokeDashArray = null; break; default: break; } Container.Children.Add(MyPolyline); Container.Children.Add(CrossCanvas); ReInit(scaleTypeX, scaleTypeY, x0, xN, y0, yN, points); }
// Use this for initialization void Start() { //walls[1].wall.localScale = new Vector3(walls[1].wall.localScale.x, 0.2f, walls[1].wall.localScale.z); for(int c = 0; c < wallCount; c++){ walls[c].wallObjects = walls[c].wall.FindChild("Wall Objects"); if(scale == 0) scaleCall = ChangeScaleX; else if(scale == 1) scaleCall = ChangeScaleY; else if(scale == 2) scaleCall = ChangeScaleZ; } ChangeWallVisibility(turnAngle); }
public static void SetScaleType(DependencyObject obj, ScaleType value) { obj.SetValue(ScaleTypeProperty, value); }
public void StopScalingTime() { scaleType = ScaleType.None; }
public ScaleAnim() { time = 0.2f; scaleType = ScaleType.CenterXY; }