public StrokeRect ( double x, double y, double w, double h ) : void | ||
x | double | |
y | double | |
w | double | |
h | double | |
Résultat | void |
public override void Draw(CanvasRenderingContext2D canv) { base.Draw(canv); if (!Visible) return; if (Palette == null) return; canv.Save(); canv.StrokeStyle = "#000"; canv.LineWidth = 2; var pos = new Point(TotalX, TotalY); var f = (int)Math.Round(Palette.Length / 2.0); if (Wide) { for (var h = 0; h < 2; h++) { for (var w = 0; w < f; w++) { canv.FillStyle = Palette[w + h * f]; canv.FillRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); canv.StrokeRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); } } if (ShowCurrent) { canv.FillStyle = Palette[SelectedIndex]; canv.FillRect(pos.X + f * Scale.X , pos.Y, Scale.X * 2, Scale.Y * 2); canv.StrokeRect(pos.X + f * Scale.X , pos.Y, Scale.X * 2, Scale.Y * 2); } } else { for (var h = 0; h < f; h++) { for (var w = 0; w < 2; w++) { canv.FillStyle = Palette[w + h * 2]; canv.FillRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); canv.StrokeRect(pos.X + w * Scale.X, pos.Y + h * Scale.Y, Scale.X, Scale.Y); } } if (ShowCurrent) { canv.FillStyle = Palette[SelectedIndex]; canv.FillRect(pos.X, pos.Y + f * Scale.Y , Scale.X * 2, Scale.Y * 2); canv.StrokeRect(pos.X, pos.Y + f * Scale.Y , Scale.X * 2, Scale.Y * 2); } } canv.Restore(); }
private void drawHighChunks(CanvasRenderingContext2D canvas, int fxP, int fyP, Point[] offs, Point localPoint) { foreach (Point off in offs) { int _xP = fxP + off.X; int _yP = fyP + off.Y; int _xPreal = fxP + off.X; int _yPreal = fyP + off.Y; //if (_xP < 0 || _xP >= SonicLevel.LevelWidth) continue; _xP = Help.Mod(_xP, SonicLevel.LevelWidth); _yP = Help.Mod(_yP, SonicLevel.LevelHeight); TileChunk chunk = SonicLevel.GetChunkAt(_xP, _yP); if (chunk == null) continue; localPoint.X = (_xPreal * 128) - WindowLocation.X; localPoint.Y = (_yPreal * 128) - WindowLocation.Y; if (!chunk.IsEmpty() && !chunk.OnlyBackground()) chunk.Draw(canvas, localPoint, ChunkLayer.High); if (ShowHeightMap) { var fd = SpriteCache.HeightMapChunks[(SonicLevel.CurHeightMap ? 1 : 2) + " " + chunk.Index]; if (fd == null) { fd = cacheHeightMapForChunk(chunk); } canvas.DrawImage(fd.Canvas, localPoint.X, localPoint.Y); } if (CurrentGameState == GameState.Editing) { canvas.StrokeStyle = "#DD0033"; canvas.LineWidth = 3; canvas.StrokeRect(localPoint.X, localPoint.Y, 128, 128); } } }
public void DrawAnimationDebug(CanvasRenderingContext2D canvas, Point position, ChunkLayer layer, TileChunkDebugDrawOptions debugDrawOptions ) { if (debugDrawOptions == null) return; canvas.Save(); canvas.FillStyle = "White"; canvas.TextBaseline = TextBaseline.Top; { int yOffset = layer == ChunkLayer.Low ? 0 : 64; if (debugDrawOptions.ShowBaseData) { canvas.FillText("Base", position.X + 0, position.Y + yOffset); } if (debugDrawOptions.ShowPaletteAnimationData) { if (HasPixelAnimations()) { var paletteAnimationCanvases = PaletteAnimationCanvasesCache[layer]; foreach (var paletteAnimationIndex in GetAllPaletteAnimationIndexes()) { var paletteAnimationCanvasFrames = paletteAnimationCanvases[paletteAnimationIndex]; if (paletteAnimationCanvasFrames == null) continue; var currentFrame = SonicManager.Instance.TilePaletteAnimationManager.GetCurrentFrame(paletteAnimationIndex); canvas.FillText("Palette " + paletteAnimationIndex + "-" + currentFrame.FrameIndex, position.X + 25, position.Y + yOffset + (paletteAnimationIndex*13)); } } } if (debugDrawOptions.ShowTileAnimationData) { if (HasTileAnimations()) { var tileAnimationCanvases = TileAnimationCanvasesCache[layer]; foreach (var tileAnimationIndex in GetAllTileAnimationIndexes()) { var tileAnimationCanvasFrames = tileAnimationCanvases[tileAnimationIndex]; if (tileAnimationCanvasFrames == null) continue; var currentFrame = SonicManager.Instance.TileAnimationManager.GetCurrentFrame(tileAnimationIndex); canvas.FillText("Tile " + tileAnimationIndex + "-" + currentFrame.FrameIndex, position.X + 75, position.Y + yOffset + (tileAnimationIndex*13)); } } } } if (debugDrawOptions.OutlineChunk) { canvas.StrokeStyle = "black"; canvas.StrokeRect(position.X, position.Y, 128, 128); } if (debugDrawOptions.OutlineTiles) { canvas.StrokeStyle = "green"; for (int x = 0; x < TileSideLength; x++) { for (int y = 0; y < TileSideLength; y++) { canvas.StrokeRect(position.X + (x * TileSquareSize), position.Y + (y * TileSquareSize), TileSquareSize, TileSquareSize); } } } if (debugDrawOptions.OutlineTilePieces) { canvas.StrokeStyle = "purple"; for (int x = 0; x < TilePieceSideLength; x++) { for (int y = 0; y < TilePieceSideLength; y++) { canvas.StrokeRect(position.X + (x * TilePiecesSquareSize), position.Y + (y * TilePiecesSquareSize), TilePiecesSquareSize, TilePiecesSquareSize); } } } if (debugDrawOptions.OutlineTile != null) { /* canvas.StrokeStyle = "yellow"; for (int x = 0; x < TileSideLength; x++) { for (int y = 0; y < TileSideLength; y++) { var tilePieceInfo = this.GetTilePiece(x, y); if (tilePieceInfo == null) continue; var tilePiece = tilePieceInfo.GetTilePiece(); if (tilePiece == null) continue; if (tilePiece == debugDrawOptions.OutlineTilePiece) { canvas.StrokeRect(position.X + (x * TileSquareSize), position.Y + (y * TileSquareSize), TileSquareSize, TileSquareSize); } } } */ } if (debugDrawOptions.OutlineTilePiece != null) { canvas.StrokeStyle = "yellow"; for (int x = 0; x < TilePieceSideLength; x++) { for (int y = 0; y < TilePieceSideLength; y++) { var tilePieceInfo = this.GetTilePieceInfo(x, y,false); if (tilePieceInfo == null) continue; var tilePiece = tilePieceInfo.GetTilePiece(); if (tilePiece == null) continue; if (tilePiece.Index == debugDrawOptions.OutlineTilePiece.Block) { canvas.StrokeRect(position.X + (x * TilePiecesSquareSize), position.Y + (y * TilePiecesSquareSize), TilePiecesSquareSize, TilePiecesSquareSize); } } } } canvas.Restore(); }