private void PenTipChanged() { //ペン先のstrokeカラー設定 Color strokeColor = PaintColors.Transparent; switch (strokeColorPicker.SelectedItem as string) { default: case "None": strokeColor = PaintColors.Transparent; break; case "Black": strokeColor = PaintColors.Black; break; case "White": strokeColor = PaintColors.White; break; case "Red": strokeColor = PaintColors.Red; break; case "Yellow": strokeColor = PaintColors.Yellow; break; case "Green": strokeColor = PaintColors.Green; break; case "Blue": strokeColor = PaintColors.Blue; break; } anArtBoard.InProgressPath.StrokeColor = strokeColor; anArtBoard.InProgressPath.StrokeSize = (float)strokeSizeStepper.Value; anArtBoard.InProgressPath.StrokeJoin = SKStrokeJoin.Round; anArtBoard.InProgressPath.StrokeCap = SKStrokeCap.Round; anArtBoard.InProgressPath.IsScreentoneBlendMode = screentoneBlendModeSwitch.IsToggled; //ペン先のfillカラー設定 Color fillColor = PaintColors.Transparent; switch (fillColorPicker.SelectedItem as string) { default: case "None": fillColor = PaintColors.Transparent; break; case "Black": fillColor = PaintColors.Black; break; case "White": fillColor = PaintColors.White; break; case "Red": fillColor = PaintColors.Red; break; case "Yellow": fillColor = PaintColors.Yellow; break; case "Green": fillColor = PaintColors.Green; break; case "Blue": fillColor = PaintColors.Blue; break; } SKBitmap bitmap = new SKBitmap(); //ペン先のパターン設定 switch (fillPatternPicker.SelectedItem as string) { default: case "Normal": bitmap = PaintPatterns.NormalPattern(fillColor.ToSKColor()); break; case "Rough3x3": bitmap = PaintPatterns.Rough3x3Pattern(fillColor.ToSKColor()); break; case "Rough2x2": bitmap = PaintPatterns.Rough2x2Pattern(fillColor.ToSKColor()); break; case "Beads4x4": bitmap = PaintPatterns.Beads4x4Pattern(fillColor.ToSKColor()); break; case "StripeX": bitmap = PaintPatterns.StripeXPattern(fillColor.ToSKColor()); break; case "StripeY": bitmap = PaintPatterns.StripeYPattern(fillColor.ToSKColor()); break; case "Checkered": bitmap = PaintPatterns.CheckeredPattern(fillColor.ToSKColor()); break; case "Dense2x2": bitmap = PaintPatterns.Dense2x2Pattern(fillColor.ToSKColor()); break; case "Dense3x3": bitmap = PaintPatterns.Dense3x3Pattern(fillColor.ToSKColor()); break; case "LeftHatching": bitmap = PaintPatterns.LeftHatching8x8Pattern(fillColor.ToSKColor()); break; case "RightHatching": bitmap = PaintPatterns.RightHatching8x8Pattern(fillColor.ToSKColor()); break; } anArtBoard.InProgressPath.Screentone = bitmap; Path.ScreentoneScale = SaveProperties.ScreentoneScale; }
private void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e) { SKImageInfo info = e.Info; SKSurface surface = e.Surface; SKCanvas canvas = surface.Canvas; int surfaceWidth = info.Width; int surfaceHeight = info.Height; int aBitmapWidth = surfaceWidth / 4; int aBitmapHeight = surfaceHeight / 2; //絵画開始 //背景色を塗る canvas.Clear(PaintColors.ArtBoardBackground.ToSKColor()); //SKBitmap srcBitmap = PaintPatterns.CheckeredPattern(PaintColors.Black); SKBitmap[] srcBitmapList = new SKBitmap[8]; srcBitmapList[0] = PaintPatterns.Rough3x3Pattern(PaintColors.Black.ToSKColor()); srcBitmapList[1] = PaintPatterns.Rough2x2Pattern(PaintColors.Black.ToSKColor()); srcBitmapList[2] = PaintPatterns.Beads4x4Pattern(PaintColors.Black.ToSKColor()); srcBitmapList[3] = PaintPatterns.StripeXPattern(PaintColors.Black.ToSKColor()); srcBitmapList[4] = PaintPatterns.StripeYPattern(PaintColors.Black.ToSKColor()); srcBitmapList[5] = PaintPatterns.CheckeredPattern(PaintColors.Black.ToSKColor()); srcBitmapList[6] = PaintPatterns.Dense2x2Pattern(PaintColors.Black.ToSKColor()); srcBitmapList[7] = PaintPatterns.Dense3x3Pattern(PaintColors.Black.ToSKColor()); for (int index = 0; index < 8; index++) { SKBitmap dstBitmap = new SKBitmap( new SKImageInfo( srcBitmapList[index].Info.Width * (int)screentoneScaleStepper.Value, srcBitmapList[index].Info.Height * (int)screentoneScaleStepper.Value)); srcBitmapList[index].ScalePixels(dstBitmap, SKFilterQuality.None); SKPaint paint = new SKPaint(); paint.IsAntialias = false; paint.Style = SKPaintStyle.Fill; paint.Shader = SKShader.CreateBitmap(dstBitmap, SKShaderTileMode.Repeat, SKShaderTileMode.Repeat); if (0 <= index && index <= 3) { canvas.DrawRect(new SKRect(aBitmapWidth * index, 0, aBitmapWidth * (index + 1), aBitmapHeight), paint); } else { canvas.DrawRect(new SKRect(aBitmapWidth * (index - 4), aBitmapHeight, aBitmapWidth * ((index - 4) + 1), aBitmapHeight * 2), paint); } } /* * //旧形式 * SKImageInfo srcInfo = new SKImageInfo( * srcBitmap.Width * (int)screentoneScaleStepper.Value, * srcBitmap.Height * (int)screentoneScaleStepper.Value); * SKBitmap dstBitmap = srcBitmap.Resize(srcInfo, SKBitmapResizeMethod.Box); * * * * //新形式 * SKBitmap dstBitmap = new SKBitmap( * new SKImageInfo( * srcBitmap.Info.Width * (int)screentoneScaleStepper.Value, * srcBitmap.Info.Height * (int)screentoneScaleStepper.Value)); * srcBitmap.ScalePixels(dstBitmap,SKFilterQuality.None); * * * * paint.Shader = SKShader.CreateBitmap( * dstBitmap, * SKShaderTileMode.Repeat, * SKShaderTileMode.Repeat); * * * canvas.DrawRect(rect, paint); */ }