public void SetNormalSweepMode(RotateDirection direction) //切换成正常扫描模式 { StopSectionSweep(); StartSwitchToDirection(direction); NotifySweepModeChange(); //通知观察者扫描状态改变 }
public bool isRotateTo(RotateDirection dir) { int t1 = (int)direction; int t2 = (int)dir; return((t1 & t2) == t2); }
//TODO if needed void Rotate(RotateDirection direction) { return; if (!canRotate(direction)) { return; } float xRotation = 0.0f; float zRotation = 0.0f; float yRotation = 0.0f; switch (direction) { case RotateDirection.PLUS_X: xRotation += Constants.ROTATION_STEP; break; case RotateDirection.MINUS_X: xRotation -= Constants.ROTATION_STEP; break; case RotateDirection.PLUS_Z: zRotation += Constants.ROTATION_STEP; break; case RotateDirection.MINUS_Z: zRotation -= Constants.ROTATION_STEP; break; } currentFigure.transform.Rotate(xRotation, currentFigure.transform.rotation.y, zRotation); }
public void AddRotateZ(float angleZ, RotateDirection dir = RotateDirection.ClockWise) { /* * //BgToRotate.transform.localEulerAngles.z + * if (angleZ > 0) * { * * * //BgToRotate.transform.Rotate(Vector3.forward, angleZ); * //ChapterToRotate.transform.Rotate(Vector3.forward, angleZ); * } * else * { * BgToRotate.transform.Rotate(Vector3.back, 180f - angleZ); * ChapterToRotate.transform.Rotate(Vector3.back, 180f - angleZ); * //BgToRotate.transform.Rotate(Vector3.forward, angleZ); * //ChapterToRotate.transform.Rotate(Vector3.forward, angleZ); * }*/ Quaternion rotate; if (dir == RotateDirection.CounterClockWise) { rotate = Quaternion.AngleAxis(angleZ, Vector3.back); } else { rotate = Quaternion.AngleAxis(angleZ, Vector3.forward); } //if (dir == RotateDirection.CounterClockWise) Quaternion.Inverse(rotate); BgToRotate.transform.rotation = rotate * BgToRotate.transform.rotation; ChapterToRotate.transform.rotation = rotate * ChapterToRotate.transform.rotation; }
/// <summary> /// /// </summary> /// <param name="axPlayer"></param> /// <param name="direction">0-Counterclockwise 1-Clockwise</param> private void SetVideoRotation(AxAPlayer3Lib.AxPlayer axPlayer, RotateDirection direction) { var angle = GetPlayerConfig(axPlayer, PlayerConfig.ImageRotate); var nAngle = 0; if (int.TryParse(angle, out nAngle)) { if (direction == RotateDirection.Counterclockwise) { nAngle -= 90; } else { nAngle += 90; } if (Math.Abs(nAngle) == 360) { nAngle = 0; } SetPlayerConfig(player, PlayerConfig.ImageRotate, nAngle.ToString()); } }
public Coord[] GetRotatedPattern(RotateDirection rotateDirection) { switch (rotateDirection) { case RotateDirection.Clockwise: { CurrentRotatePatternNumber++; if (CurrentRotatePatternNumber >= _patterns.Count) { CurrentRotatePatternNumber = 0; } } break; case RotateDirection.Counterclockwise: { CurrentRotatePatternNumber--; if (CurrentRotatePatternNumber < 0) { CurrentRotatePatternNumber = _patterns.Count - 1; } } break; } return(GetCurrentPattern()); }
public bool AssertValidTetrominoRotation(Transform tetromino, RotateDirection direction) { // start by rotating the parent tetromino.RotateInDirection(direction); // check validity of each block bool isValid = true; foreach (Transform block in tetromino) { if (AssertValidPosition(block.position)) { continue; } isValid = false; } // reset block tetromino RotateDirection opposite = direction == RotateDirection.Left ? RotateDirection.Right : RotateDirection.Left; tetromino.RotateInDirection(opposite); return(isValid); }
/// <inheritdoc /> public Bitmap RotateImage(Bitmap original, RectangleCoords resultCoords, RotateDirection dir) { if (dir != RotateDirection.Left && dir != RotateDirection.Right) { // если добавляются новые направления поворота, вычисление границ поменяется throw new NotImplementedException(); } // При повороте поменяется высота с шириной. if (!resultCoords.IntersectWith(original.Height, original.Width)) { return(null); } resultCoords.Intersect(original.Height, original.Width); switch (dir) { case RotateDirection.Left: original.RotateFlip(RotateFlipType.Rotate270FlipNone); break; case RotateDirection.Right: original.RotateFlip(RotateFlipType.Rotate90FlipNone); break; } return(original.Clone( new Rectangle( resultCoords.X, resultCoords.Y, resultCoords.Width, resultCoords.Height), original.PixelFormat)); }
public RotateOperation(IBrowsableItem item, RotateDirection direction) { this.item = item; this.direction = direction; version_index = 0; done = false; }
private Quaternion GetMatrix(RotateDirection direction) { var angle = Vector3.zero; switch (direction) { case RotateDirection.HorizontalNegative: angle = new Vector3(0, 90, 0); break; case RotateDirection.HorizontalPositive: angle = new Vector3(0, -90, 0); break; case RotateDirection.VerticalPositive: angle = new Vector3(90, 0, 0); break; case RotateDirection.VerticalNegative: angle = new Vector3(-90, 0, 0); break; } return(Quaternion.Euler(angle));//Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(angle), Vector3.one)); }
public void Rotate(RotateDirection dir) { System.Diagnostics.Debug.Assert(NumColumns == 2 && NumRows == 2); var cells = DropPieceSimple.Cells; if (dir == RotateDirection.Left) { var first = cells[0][0]; cells[0][0] = cells[0][1]; cells[0][1] = cells[1][1]; cells[1][1] = cells[1][0]; cells[1][0] = first; } else { var first = cells[0][0]; cells[0][0] = cells[1][0]; cells[1][0] = cells[1][1]; cells[1][1] = cells[0][1]; cells[0][1] = first; } Rotated?.Invoke(this, new RotateEventArgs(dir)); }
private void RotateImageByButton(RotateDirection rd) { Image bm_dest; try { if (rd == RotateDirection.Left) { bm_dest = RotateImage(_img, -90); } else { bm_dest = RotateImage(_img, 90); } pbSelectArea.Image = bm_dest; pbSelectArea.Width = bm_dest.Width; pbSelectArea.Height = bm_dest.Height; pbSelectArea.Refresh(); _img = bm_dest; tBSize.Value = 0; } catch (Exception ex) { MessageBox.Show("Error occur in RotateImageByButton." + ex.Message); } }
/// <summary> /// Gets the new facing direction /// </summary> /// <param name="RotateDirection"></param> /// <param name="facingDirection"></param> /// <returns></returns> public static FacingDirection GetFacingDirection(RotateDirection RotateDirection, FacingDirection facingDirection) { if (RotateDirection == RotateDirection.Left) { if (facingDirection == FacingDirection.East) facingDirection = FacingDirection.North; else if (facingDirection == FacingDirection.North) facingDirection = FacingDirection.West; else if (facingDirection == FacingDirection.West) facingDirection = FacingDirection.South; else if (facingDirection == FacingDirection.South) facingDirection = FacingDirection.East; } else if (RotateDirection == RotateDirection.Right) { if (facingDirection == FacingDirection.East) facingDirection = FacingDirection.South; else if (facingDirection == FacingDirection.North) facingDirection = FacingDirection.East; else if (facingDirection == FacingDirection.West) facingDirection = FacingDirection.North; else if (facingDirection == FacingDirection.South) facingDirection = FacingDirection.West; } return facingDirection; }
public static byte AsAngularVelocity(this byte speed, RotateDirection direction) { var rotationalSpeed = Math.Min(Math.Max(speed, (byte)0), (byte)100); sbyte angularVelocity = Convert.ToSByte(rotationalSpeed * (sbyte)direction); return(unchecked ((byte)angularVelocity)); }
public void Rotate(RotateDirection rotation) { int oldRows = _map.size.y; int oldCols = _map.size.x; TileBase[] old = Tiles; TileBase[] aux = new TileBase[oldRows * oldCols]; for (int rowIdx = 0; rowIdx < oldCols; ++rowIdx) { int currentRowBase = rowIdx * oldRows; for (int colIdx = 0; colIdx < oldRows; ++colIdx) { int oldIdx = 0; if (rotation == RotateDirection.Left) { oldIdx = rowIdx + oldCols * (oldRows - colIdx - 1); } else if (rotation == RotateDirection.Right) { oldIdx = oldCols * colIdx + oldCols - rowIdx - 1; } aux[currentRowBase + colIdx] = old[oldIdx]; } } _map.ClearAllTiles(); var newBounds = new BoundsInt(new Vector3Int(0, 0, 0), new Vector3Int(oldRows, oldCols, 1)); _map.SetTilesBlock(newBounds, aux); RefreshBounds(); }
public static T[] ElementsAt <T>(this T[] source, IEnumerable <int> indexes, RotateDirection rotateDirection, int n) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (indexes == null) { throw new ArgumentNullException(nameof(indexes)); } if (n < 0) { throw new ArgumentOutOfRangeException(nameof(n)); } T[] destination = new T[source.Length]; int i = -1; foreach (int index in indexes) { i++; destination[i] = source.ElementAt(index, rotateDirection, n); } return(destination); }
public void Rotate(RotateDirection direction) { if (_onRotate) { return; } _onRotate = true; PlayerController.RePosition(); PlayerController.Disable(); Vector3 target = this.gameObject.transform.rotation.eulerAngles; switch (direction) { case RotateDirection.Left: target = new Vector3(0, target.y + 90, 0); break; case RotateDirection.Right: target = new Vector3(0, target.y - 90, 0); break; } this.gameObject.transform.DORotate(target, Duration) .OnComplete(() => OnRotateComplete()); }
public RotateOperation (IBrowsableItem item, RotateDirection direction) { this.item = item; this.direction = direction; version_index = 0; done = false; }
public static T ElementAt <T>(this T[] source, int index, RotateDirection rotateDirection, int n) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (index < 0) { throw new ArgumentOutOfRangeException(nameof(index)); } if (n < 0) { throw new ArgumentOutOfRangeException(nameof(n)); } if (rotateDirection == RotateDirection.Left) { int length = source.Length; return(source[(index + n) % length]); } else if (rotateDirection == RotateDirection.Right) { int length = source.Count(); return(source[(index + length - n) % length]); } else { throw new NotImplementedException(); } }
/// <summary> /// 转角标注 /// </summary> /// <param name="worker">工作数据库</param> /// <param name="direction">方向</param> /// <param name="start">起始点</param> /// <param name="end">终止点</param> /// <param name="dimDistance">偏移距离</param> /// <returns></returns> public static RotatedDimension RotatedDimension(this DatabaseWorker worker, RotateDirection direction, Point3d start, Point3d end, double dimDistance) { var dim = RotatedDimension(worker, direction, start, end, dimDistance, string.Empty); //dim.DimensionStyle=worker. return(dim); }
void ExecuteInput(Entity piece, RotateDirection direction) { if (piece.hasPieceRotation) { return; } piece.AddPieceRotation(direction, 0); }
public void Reset() { Direction = MoveDirection.None; Rotation = RotateDirection.None; Confirmed = false; Cancelled = false; AnyPressed = false; }
/// <summary> /// Rotate the sprite by the offset. /// </summary> /// <param name="dir">Direction to rotate.</param> public bool Rotate(RotateDirection dir) { if (PixelWidth == PixelHeight) { return(RotateSquareInPlace(dir)); } if (dir == RotateDirection.Clockwise180) { return(RotateRect180InPlace()); } // Rotate rect sprite: int newX = TileHeight; int newY = TileWidth; int num_tiles = newX * newY; // Allocate the new tiles. Tile[] newTiles = new Tile[num_tiles]; for (int i = 0; i < num_tiles; i++) { newTiles[i] = new Tile(this, m_ss.NextTileId++); } // Rotate/copy data into new tiles. int pxOldWidth = PixelWidth; int pxOldHeight = PixelHeight; for (int ix = 0; ix < pxOldWidth; ix++) { for (int iy = 0; iy < pxOldHeight; iy++) { int y = iy; if (dir == RotateDirection.Clockwise90) { y = pxOldHeight - 1 - iy; } // Calc tile/pixel index for rotated sprite. // Note that x,y are reversed for the rotated sprite. int tileNewX = y / Tile.TileSize; int pxNewX = y % Tile.TileSize; int tileNewY = ix / Tile.TileSize; int pxNewY = ix % Tile.TileSize; int nTileIndex = (tileNewY * TileHeight) + tileNewX; newTiles[nTileIndex].SetPixel(pxNewX, pxNewY, GetPixel(ix, iy)); } } // Switch over to the newly created tile data. m_tileWidth = newX; m_tileHeight = newY; m_Tiles = newTiles; return(true); }
// Call On user Right or Down Swipe....... public void RotateClockWise(float time) { shouldRotate = true; rotateDuration = time; rotateDirection = RotateDirection.CLOCKWISE; rpmValue = (rotateDuration) / circumference; rpmValue *= 60; // convert into minutes........ //transform.Rotate(0 ,0 , -rotationSpeed); }
private static void RotateCoefficients (string original_path, RotateDirection direction) { string temporary_path = original_path + ".tmp"; // FIXME make it unique JpegUtils.Transform (original_path, temporary_path, direction == RotateDirection.Clockwise ? JpegUtils.TransformType.Rotate90 : JpegUtils.TransformType.Rotate270); Unix.Rename (temporary_path, original_path); }
public async Task <bool> Rotate(RotateDirection rotateDirection, int degree) { if (degree < 1 || degree > 3600) { throw new ArgumentOutOfRangeException(nameof(degree), "Degree should be between 1 and 3600"); } return(await _telloUpdClient.SendActionAsync($"{GetCommand(rotateDirection)} {degree}")); }
private void SetAntennaSweepState(RotateDirection direction, uint countPerMinute) { lock (this) { _rotationRate = countPerMinute; //保存当前设置的转速 var rate = GetRotationRate(direction, countPerMinute); _servoController.SetRotationRate(rate); } }
void MoveRotate(uint time, RotateDirection direction) { if (time == 0) { return; } StartMovement(new RotateMovementGenerator(time, direction), MovementSlot.Active); }
/// <summary> /// Raises rotate gesture event to subscribers. /// </summary> /// <param name="direction">Rotate direction.</param> private void OnRotate(RotateDirection direction) { var func = Rotate; if (func != null) { func(this, new RotateEventArgs(direction)); } }
public void RotateRobot( IRobot robot, RotateDirection rotateDirection) { Debug.WriteLine("Rotating robot " + robot + " " + rotateDirection); robot.Direction = DirectionHelper.GetRotatedDirection(robot.Direction, rotateDirection); FireRenderRequested(); }
public bool Execute(RotateDirection direction, IPhoto[] items) { ProgressDialog progress_dialog = null; if (items.Length > 1) { progress_dialog = new ProgressDialog(Strings.RotatingPhotos, ProgressDialog.CancelButtonType.Stop, items.Length, parentWindow); } var op = new RotateMultiple(items, direction); int readonly_count = 0; bool done = false; int index = 0; while (!done) { if (progress_dialog != null && op.Index != -1 && index < items.Length) { if (progress_dialog.Update(Strings.RotatingPhotoX(op.Items[op.Index].Name))) { break; } } try { done = !op.Step(); } catch (RotateException re) { if (!re.ReadOnly) { RunGenericError(re, re.Path, re.Message); } else { readonly_count++; } } catch (GLib.GException) { readonly_count++; } catch (DirectoryNotFoundException e) { RunGenericError(e, op.Items[op.Index].DefaultVersion.Uri.LocalPath, Strings.DirectoryNotFound); } catch (FileNotFoundException e) { RunGenericError(e, op.Items[op.Index].DefaultVersion.Uri.LocalPath, Strings.FileNotFound); } catch (Exception e) { RunGenericError(e, op.Items[op.Index].DefaultVersion.Uri.LocalPath); } index++; } progress_dialog?.Destroy(); if (readonly_count > 0) { RunReadonlyError(readonly_count); } return(true); }
/// <summary> /// 转角标注 /// </summary> /// <param name="worker">工作数据库</param> /// <param name="direction">方向</param> /// <param name="start">起始点</param> /// <param name="end">终止点</param> /// <param name="dimDistance">偏移距离</param> /// <param name="textReplace">文字替代</param> /// <returns></returns> public static RotatedDimension RotatedDimension(this DatabaseWorker worker, RotateDirection direction, Point3d start, Point3d end, double dimDistance, string textReplace = "") { //根据位置计算参照其中一点移动指定距离 var x = Math.Abs(start.X - end.X); //水平差值 var y = Math.Abs(start.Y - end.Y); //竖直差值 var radian = 0.0; var dimLinePoint = new Point3d(); switch (direction) { case RotateDirection.PX: radian = -GRadian.Radians90; dimLinePoint = start.X > end.X ? start + new Vector3d(dimDistance, y, 0) : end + new Vector3d(dimDistance, y, 0); break; case RotateDirection.NY: radian = GRadian.Radians270; dimLinePoint = start.X > end.X ? start + new Vector3d(x, -dimDistance, 0) : end + new Vector3d(x, -dimDistance, 0); break; case RotateDirection.NX: radian = GRadian.Radians180; dimLinePoint = start.X > end.X ? start + new Vector3d(-dimDistance, y, 0) : end + new Vector3d(-dimDistance, y, 0); break; case RotateDirection.PY: radian = GRadian.Radians90; dimLinePoint = start.X > end.X ? start + new Vector3d(x, dimDistance, 0) : end + new Vector3d(x, dimDistance, 0); break; } var result = new RotatedDimension(); if (textReplace == string.Empty) { textReplace = result.Measurement.ToString(); } result.Rotation = radian; result.XLine1Point = start; result.XLine2Point = end; result.DimLinePoint = dimLinePoint; result.DimensionText = textReplace; //result.DimensionStyle=worker. return(result); }
public IPolar Rotate(AngularUnit value, RotateDirection direction) { double tempValue = (int)direction * (int)Handedness * value.ChangeTo <TAngular>().Value; LinearCollection <TLinear> newRadius = (LinearCollection <TLinear>) this.Radius.Clone(); AngularCollection <TAngular> newAngle = (AngularCollection <TAngular>) this.Angle.AddAllValuesWith(tempValue); return(new Polar <TLinear, TAngular>(newRadius, newAngle, this.Handedness)); }
public RotateAction (BrowsablePointer pointer, RotateDirection direction, string name, string label, string tooltip, string stock_id) : base (pointer, name, label, tooltip, stock_id) { this.direction = direction; }
public override void Rotate(RotateDirection direction) { switch (direction) { case RotateDirection.Horizontal: img.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX); break; case RotateDirection.Vertical: img.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY); break; } }
private static void RotateOrientation (string original_path, RotateDirection direction) { using (FSpot.ImageFile img = FSpot.ImageFile.Create (original_path)) { if (img is JpegFile) { FSpot.JpegFile jimg = img as FSpot.JpegFile; PixbufOrientation orientation = direction == RotateDirection.Clockwise ? PixbufUtils.Rotate90 (img.Orientation) : PixbufUtils.Rotate270 (img.Orientation); jimg.SetOrientation (orientation); jimg.SaveMetaData (original_path); } else if (img is PngFile) { PngFile png = img as PngFile; bool supported = false; //FIXME there isn't much png specific here except the check //the pixbuf is an accurate representation of the real file //by checking the depth. The check should be abstracted and //this code made generic. foreach (PngFile.Chunk c in png.Chunks) { PngFile.IhdrChunk ihdr = c as PngFile.IhdrChunk; if (ihdr != null && ihdr.Depth == 8) supported = true; } if (! supported) { throw new RotateException ("Unable to rotate photo type", original_path); } string backup = ImageFile.TempPath (original_path); using (Stream stream = File.Open (backup, FileMode.Truncate, FileAccess.Write)) { using (Pixbuf pixbuf = img.Load ()) { PixbufOrientation fake = (direction == RotateDirection.Clockwise) ? PixbufOrientation.RightTop : PixbufOrientation.LeftBottom; using (Pixbuf rotated = PixbufUtils.TransformOrientation (pixbuf, fake)) { img.Save (rotated, stream); } } } File.Copy (backup, original_path, true); File.Delete (backup); } else { throw new RotateException ("Unable to rotate photo type", original_path); } } }
public Coord[] GetRotatedPattern(RotateDirection rotateDirection) { switch (rotateDirection) { case RotateDirection.Clockwise: { CurrentRotatePatternNumber++; if (CurrentRotatePatternNumber >= _patterns.Count) CurrentRotatePatternNumber = 0; } break; case RotateDirection.Counterclockwise: { CurrentRotatePatternNumber--; if (CurrentRotatePatternNumber < 0) CurrentRotatePatternNumber = _patterns.Count - 1; } break; } return GetCurrentPattern(); }
private static void RotateOrientation (string original_path, RotateDirection direction) { try { var uri = new SafeUri (original_path); using (var metadata = Metadata.Parse (uri)) { metadata.EnsureAvailableTags (); var tag = metadata.ImageTag; var orientation = direction == RotateDirection.Clockwise ? FSpot.Utils.PixbufUtils.Rotate90 (tag.Orientation) : FSpot.Utils.PixbufUtils.Rotate270 (tag.Orientation); tag.Orientation = orientation; var always_sidecar = Preferences.Get<bool> (Preferences.METADATA_ALWAYS_USE_SIDECAR); metadata.SaveSafely (uri, always_sidecar); App.Instance.Container.Resolve<IThumbnailService> ().DeleteThumbnails (uri); } } catch (Exception e) { Log.DebugException (e); throw new RotateException (Catalog.GetString ("Unable to rotate this type of photo"), original_path); } }
// Constructs quaternion for rotation around one of the coordinate axis by an angle. public void AxisAngle(Axis A, float angle, RotateDirection d, HandedSystem s) { float sinHalfAngle = (float)((int)s * (int)d * System.Math.Sin(angle * (float)(0.5))); float[] v = new float[3]; v[0] = v[1] = v[2] = (float)(0); v[(int)A] = sinHalfAngle; w = (float)System.Math.Cos(angle * (float)(0.5)); x = v[0]; y = v[1]; z = v[2]; }
public static Bitmap Rotate(this Bitmap bmp, RotateDirection rotatedirection, ref PointD center) { switch (rotatedirection) { case RotateDirection.Left: return bmp.Rotate_Left(ref center); case RotateDirection.Right: return bmp.Rotate_Right(ref center); case RotateDirection.Twice: return bmp.Rotate_Twice(ref center); default: throw new ArgumentException("Can't handle the parameter : rotatedirection"); } }
public void RotateShape(RotateDirection rotateDirection) { var shape = _currentShape.Rotate(rotateDirection); if (_board.CheckShapeOffset(shape, new Point(0, 0))) { _currentShape = shape; if (RotateDone != null) RotateDone(this, EventArgs.Empty); } }
public RotateMultiple(IBrowsableItem [] items, RotateDirection direction) { this.direction = direction; this.items = items; index = 0; }
// // Commands // void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction) { RotateCommand command = new RotateCommand (parent); int[] selected_ids = SelectedIds (); if (command.Execute (direction, SelectedPhotos (selected_ids))) query.MarkChanged (selected_ids, InvalidateData.Instance); }
/// <summary> /// Display words given a word offset /// </summary> /// <param name="words">list of words to display</param> /// <param name="selectable">Make sure that selectable word is fully visible on the display</param> /// <param name="rotateDirection"></param> private int DisplayWords(string[] words, int selectable, RotateDirection rotateDirection) { var str = new StringBuilder(32); for (int i = 0; i < words.Length; i++) { str.Append(words[i]); } string text = str.ToString(); // If first word, always allign left if (selectable == 0) { _display.PrintStringAt(1, 0, text, true); return 0; } // if last word always alligng right if (selectable == words.Length - 1) { _display.PrintStringAt(1, 0, text.Substring(text.Length - 16, 16)); return 16 - words[words.Length - 1].Length; } int idx; if (rotateDirection == RotateDirection.Left) { // Right aling selected word, maar zorg dat eerste word niet op > 0 begint idx = (text.IndexOf(words[selectable]) + words[selectable].Length) - 16; if (idx < 0) { idx = 0; _display.PrintStringAt(1, 0, text.Substring(idx, text.Length - idx), true); return text.IndexOf(words[selectable]); } _display.PrintStringAt(1, 0, text.Substring(idx, text.Length - idx), true); return 16 - words[selectable].Length; } // right align next word idx = (text.IndexOf(words[selectable + 1]) + words[selectable + 1].Length) - 16; if (idx < 0) { idx = 0; _display.PrintStringAt(1, 0, text.Substring(idx), true); return text.IndexOf(words[selectable]); } _display.PrintStringAt(1, 0, text.Substring(idx), true); return 16 - (words[selectable].Length + words[selectable + 1].Length); }
void RotateObject(float x) { //Obrot _currentDirection = x < 0.0f ? RotateDirection.Right : RotateDirection.Left; if (_currentObject != null) { //Space.World - obrot o os (0,1,0) w przestrzeni swiata, nie obiektu (wazne, ladnie sie teraz obraca) _currentObject.transform.Rotate(Vector3.up * x * Time.deltaTime, Space.World); } }
public RotateMultiple(IPhoto [] items, RotateDirection direction) { this.direction = direction; Items = items; Index = 0; }
public void Rotate(RotateDirection rotateDirection, uint degrees, int speed = DefaultRotateSpeed) { //var leftSpeed = LeftMotorSpeed; //var rightSpeed = RightMotorSpeed; var direction = rotateDirection== RotateDirection.Left ? 1 : -1; Moving = true; //LeftMotorSpeed = 67; //RightMotorSpeed = -67; _myMotors.BothMotors(direction * speed, -direction * speed); //depends on degrees var duration = degrees/360d*RotateDuration360; Thread.Sleep((int)duration); //_myMotors.BothMotors(leftSpeed, rightSpeed); Stop(); }
// // Commands // private void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction) { RotateCommand command = new RotateCommand (parent); int [] selected_ids = SelectedIds (); if (command.Execute (direction, SelectedPhotos (selected_ids))) #if MONO_1_9_0 query.MarkChanged (selected_ids, new PhotoChanges () {DataChanged = true}); #else { PhotoChanges changes = new PhotoChanges (); changes.DataChanged = true; query.MarkChanged (selected_ids, changes); } #endif }
public abstract void Rotate(RotateDirection direction);
public void Rotate(RotateDirection rotateDirection) { var currentPattern = _rotatePatternManager.GetRotatedPattern(rotateDirection); for (int i = 0; i < _blocks.Count; i++) { _blocks[i].LocationInTheGroup = currentPattern[i]; } SetLocation(Location); }
/// <summary> /// Creates a new Image containing the same image only rotated /// </summary> /// <param name="image">The <see cref="System.Drawing.Image"/> to rotate</param> /// <param name="angle">The amount to rotate the image, clockwise, in degrees</param> /// <returns>A new <see cref="System.Drawing.Bitmap"/> that is just large enough /// to contain the rotated image without cutting any corners off.</returns> /// <exception cref="System.ArgumentNullException">Thrown if <see cref="image"/> is null.</exception> public static Bitmap RotateImage(Image image, RotateDirection direction) { float angle = (direction == RotateDirection.Left) ? -90 : 90; if (image == null) throw new ArgumentNullException("image"); const double pi2 = Math.PI / 2.0; // Why can't C# allow these to be const, or at least readonly // *sigh* I'm starting to talk like Christian Graus :omg: double oldWidth = (double)image.Width; double oldHeight = (double)image.Height; // Convert degrees to radians double theta = ((double)angle) * Math.PI / 180.0; double locked_theta = theta; // Ensure theta is now [0, 2pi) while (locked_theta < 0.0) locked_theta += 2 * Math.PI; double newWidth, newHeight; int nWidth, nHeight; // The newWidth/newHeight expressed as ints #region Explaination of the calculations /* * The trig involved in calculating the new width and height * is fairly simple; the hard part was remembering that when * PI/2 <= theta <= PI and 3PI/2 <= theta < 2PI the width and * height are switched. * * When you rotate a rectangle, r, the bounding box surrounding r * contains for right-triangles of empty space. Each of the * triangles hypotenuse's are a known length, either the width or * the height of r. Because we know the length of the hypotenuse * and we have a known angle of rotation, we can use the trig * function identities to find the length of the other two sides. * * sine = opposite/hypotenuse * cosine = adjacent/hypotenuse * * solving for the unknown we get * * opposite = sine * hypotenuse * adjacent = cosine * hypotenuse * * Another interesting point about these triangles is that there * are only two different triangles. The proof for which is easy * to see, but its been too long since I've written a proof that * I can't explain it well enough to want to publish it. * * Just trust me when I say the triangles formed by the lengths * width are always the same (for a given theta) and the same * goes for the height of r. * * Rather than associate the opposite/adjacent sides with the * width and height of the original bitmap, I'll associate them * based on their position. * * adjacent/oppositeTop will refer to the triangles making up the * upper right and lower left corners * * adjacent/oppositeBottom will refer to the triangles making up * the upper left and lower right corners * * The names are based on the right side corners, because thats * where I did my work on paper (the right side). * * Now if you draw this out, you will see that the width of the * bounding box is calculated by adding together adjacentTop and * oppositeBottom while the height is calculate by adding * together adjacentBottom and oppositeTop. */ #endregion double adjacentTop, oppositeTop; double adjacentBottom, oppositeBottom; // We need to calculate the sides of the triangles based // on how much rotation is being done to the bitmap. // Refer to the first paragraph in the explaination above for // reasons why. if ((locked_theta >= 0.0 && locked_theta < pi2) || (locked_theta >= Math.PI && locked_theta < (Math.PI + pi2))) { adjacentTop = Math.Abs(Math.Cos(locked_theta)) * oldWidth; oppositeTop = Math.Abs(Math.Sin(locked_theta)) * oldWidth; adjacentBottom = Math.Abs(Math.Cos(locked_theta)) * oldHeight; oppositeBottom = Math.Abs(Math.Sin(locked_theta)) * oldHeight; } else { adjacentTop = Math.Abs(Math.Sin(locked_theta)) * oldHeight; oppositeTop = Math.Abs(Math.Cos(locked_theta)) * oldHeight; adjacentBottom = Math.Abs(Math.Sin(locked_theta)) * oldWidth; oppositeBottom = Math.Abs(Math.Cos(locked_theta)) * oldWidth; } newWidth = adjacentTop + oppositeBottom; newHeight = adjacentBottom + oppositeTop; nWidth = (int)Math.Ceiling(newWidth); nHeight = (int)Math.Ceiling(newHeight); Bitmap rotatedBmp = new Bitmap(nWidth, nHeight); using (Graphics g = Graphics.FromImage(rotatedBmp)) { // This array will be used to pass in the three points that // make up the rotated image Point[] points; /* * The values of opposite/adjacentTop/Bottom are referring to * fixed locations instead of in relation to the * rotating image so I need to change which values are used * based on the how much the image is rotating. * * For each point, one of the coordinates will always be 0, * nWidth, or nHeight. This because the Bitmap we are drawing on * is the bounding box for the rotated bitmap. If both of the * corrdinates for any of the given points wasn't in the set above * then the bitmap we are drawing on WOULDN'T be the bounding box * as required. */ if (locked_theta >= 0.0 && locked_theta < pi2) { points = new Point[] { new Point( (int) oppositeBottom, 0 ), new Point( nWidth, (int) oppositeTop ), new Point( 0, (int) adjacentBottom ) }; } else if (locked_theta >= pi2 && locked_theta < Math.PI) { points = new Point[] { new Point( nWidth, (int) oppositeTop ), new Point( (int) adjacentTop, nHeight ), new Point( (int) oppositeBottom, 0 ) }; } else if (locked_theta >= Math.PI && locked_theta < (Math.PI + pi2)) { points = new Point[] { new Point( (int) adjacentTop, nHeight ), new Point( 0, (int) adjacentBottom ), new Point( nWidth, (int) oppositeTop ) }; } else { points = new Point[] { new Point( 0, (int) adjacentBottom ), new Point( (int) oppositeBottom, 0 ), new Point( (int) adjacentTop, nHeight ) }; } g.DrawImage(image, points); } return rotatedBmp; }
public void RotateTrigger(RotateDirection rotateDirection) { if (!_model.IsOnPause) _model.RotateShape(rotateDirection); }
/// <summary> /// Rotate the sprite by the offset. /// </summary> /// <param name="dir">Direction to rotate.</param> public bool Rotate(RotateDirection dir) { if (PixelWidth == PixelHeight) return RotateSquareInPlace(dir); if (dir == RotateDirection.Clockwise180) return RotateRect180InPlace(); // Rotate rect sprite: int newX = TileHeight; int newY = TileWidth; int num_tiles = newX * newY; // Allocate the new tiles. Tile[] newTiles = new Tile[num_tiles]; for (int i = 0; i < num_tiles; i++) newTiles[i] = new Tile(this, m_ss.NextTileId++); // Rotate/copy data into new tiles. int pxOldWidth = PixelWidth; int pxOldHeight = PixelHeight; for (int ix = 0; ix < pxOldWidth; ix++) { for (int iy = 0; iy < pxOldHeight; iy++) { int y = iy; if (dir == RotateDirection.Clockwise90) y = pxOldHeight-1 - iy; // Calc tile/pixel index for rotated sprite. // Note that x,y are reversed for the rotated sprite. int tileNewX = y / Tile.TileSize; int pxNewX = y % Tile.TileSize; int tileNewY = ix / Tile.TileSize; int pxNewY = ix % Tile.TileSize; int nTileIndex = (tileNewY * TileHeight) + tileNewX; newTiles[nTileIndex].SetPixel(pxNewX, pxNewY, GetPixel(ix,iy)); } } // Switch over to the newly created tile data. m_tileWidth = newX; m_tileHeight = newY; m_Tiles = newTiles; return true; }
private void Rotate(string original_path, RotateDirection dir) { RotateOrientation (original_path, dir); }
public bool Execute(RotateDirection direction, IBrowsableItem [] items) { ProgressDialog progress_dialog = null; if (items.Length > 1) progress_dialog = new ProgressDialog (Catalog.GetString ("Rotating photos"), ProgressDialog.CancelButtonType.Stop, items.Length, parent_window); RotateMultiple op = new RotateMultiple (items, direction); int readonly_count = 0; bool done = false; int index = 0; while (!done) { if (progress_dialog != null && op.Index != -1 && index < items.Length) if (progress_dialog.Update (String.Format (Catalog.GetString ("Rotating photo \"{0}\""), op.Items [op.Index].Name))) break; try { done = !op.Step (); } catch (RotateException re) { if (!re.ReadOnly) RunGenericError (re, re.Path, re.Message); else readonly_count++; } catch (GLib.GException) { readonly_count++; } catch (DirectoryNotFoundException e) { RunGenericError (e, op.Items [op.Index].DefaultVersionUri.LocalPath, Catalog.GetString ("Directory not found")); } catch (FileNotFoundException e) { RunGenericError (e, op.Items [op.Index].DefaultVersionUri.LocalPath, Catalog.GetString ("File not found")); } catch (Exception e) { RunGenericError (e, op.Items [op.Index].DefaultVersionUri.LocalPath); } index ++; } if (progress_dialog != null) progress_dialog.Destroy (); if (readonly_count > 0) RunReadonlyError (readonly_count); return true; }
public RotateOperation(IPhoto item, RotateDirection direction) { this.item = item; this.direction = direction; done = false; }
public bool Execute (RotateDirection direction, IBrowsableItem [] items) { ProgressDialog progress_dialog = null; if (items.Length > 1) progress_dialog = new ProgressDialog (Catalog.GetString ("Rotating photos"), ProgressDialog.CancelButtonType.Stop, items.Length, parent_window); RotateMultiple op = new RotateMultiple (items, direction); int readonly_count = 0; bool done = false; int index = -1; while (!done) { if (progress_dialog != null && index != op.Index) progress_dialog.Update (String.Format (Catalog.GetString ("Rotating photo \"{0}\""), op.Items [op.Index].Name)); try { done = !op.Step (); } catch (RotateException re) { if (re.Message == "Unable to rotate photo type") RunTypeError (re); else readonly_count ++; } catch (Exception e) { RunGenericError (e, op.Items [op.Index].DefaultVersionUri.LocalPath); } } if (progress_dialog != null) progress_dialog.Destroy (); if (readonly_count > 0) RunReadonlyError (readonly_count); return true; }
// // Commands // private void RotateSelectedPictures (Gtk.Window parent, RotateDirection direction) { RotateCommand command = new RotateCommand (parent); int [] selected_ids = SelectedIds (); if (command.Execute (direction, SelectedPhotos (selected_ids))) { foreach (int num in selected_ids) query.MarkChanged (num); } }
// Rotate the square sprite in place (without reallocating new tiles). private bool RotateSquareInPlace(RotateDirection dir) { int offset = (int)dir; // Rotate the sprite from the outer ring of pixels to the inner ring. // E.g.: aaaaaaaa First the 'a' ring is processed // abbbbbba Then the 'b' ring // abccccba Then 'c' // abcddcba And finally 'd' // abcddcba // abccccba // abbbbbba // aaaaaaaa // // For each ring, we process as follows: // 012340 First, we record the 4 orig pixels at '0' // 4 1 Then we rotate these pixels and write them to the // 3 2 new location. E.g., for clockwise rotation, the // 2 3 upper-left '0' is written to the upper-right '0', // 1 4 upper-right '0' -> lower-right '0', and so on. // 043210 This continues for the 4 '1's, the 4 '2's, ... // int[] vals = new int[4]; int pxSize = PixelWidth; int rings = pxSize / 2; for (int ring = 0; ring < rings; ring++) { int pxFirst = ring; int pxLast = pxSize - ring - 1; int pxCount = pxLast - pxFirst; for (int px = 0; px < pxCount; px++) { // Record the original values of the pixels to be rotated. vals[0] = GetPixel(pxFirst + px, pxFirst); vals[1] = GetPixel(pxLast, pxFirst + px); vals[2] = GetPixel(pxLast - px, pxLast); vals[3] = GetPixel(pxFirst, pxLast - px); // Rotate the pixels SetPixel(pxFirst + px, pxFirst, vals[(4 + offset) % 4]); SetPixel(pxLast, pxFirst + px, vals[(5 + offset) % 4]); SetPixel(pxLast - px, pxLast, vals[(6 + offset) % 4]); SetPixel(pxFirst, pxLast - px, vals[(7 + offset) % 4]); } } return true; }
// // Commands // private void RotateSelectedPictures(Gtk.Window parent, RotateDirection direction) { RotateCommand command = new RotateCommand (parent); int [] selected_ids = SelectedIds (); if (command.Execute (direction, SelectedPhotos (selected_ids))) query.MarkChanged (selected_ids, new PhotoChanges () {DataChanged = true}); }