예제 #1
0
        // private void Blur()
        // {
        //     var destTexture = RenderTexture.GetTemporary(_paintBuffer.descriptor);
        //     Graphics.Blit(_paintBuffer, destTexture, _blurMaterial, 0);
        //     Graphics.Blit(destTexture, _paintBuffer);
        //     RenderTexture.ReleaseTemporary(destTexture);
        // }

        public void LoadImage(string fileName)
        {
            Debug.Log($"LoadImage '{fileName}'");

            Layers.Clear();
            _imageFilename = fileName;
            var texture = PaintUtils.LoadImageTexture(_imageFilename);

            if (texture != null && (texture.width != defaultImageWidth || texture.height != defaultImageHeight))
            {
                Destroy(texture);
                texture = null;
            }

            if (texture != null)
            {
                // Set whole wetness buffer to dry:
                //_copyPaintBufferMaterial.SetFloat(PropId_Alpha, 0);
                //Graphics.Blit(texture, _paintBuffer, _copyPaintBufferMaterial);
                Layers.Create("Base", new Vector2Int(texture.width, texture.height));
                Graphics.Blit(texture, Layers.CurrentLayer.RenderTexture);
                Destroy(texture);
            }
            else
            {
                Layers.Create("Base", new Vector2Int(defaultImageWidth, defaultImageHeight));
                Clear();
            }

            _imageSize = Layers.CurrentLayer.Size;
        }
예제 #2
0
    void Start()
    {
        bmps    = new Sprite[10][];
        bmps[0] = bmp1;
        bmps[1] = bmp2;
        bmps[2] = bmp3;
        bmps[3] = bmp4;
        bmps[4] = bmp5;
        bmps[5] = bmp6;
        bmps[6] = bmp7;
        bmps[7] = bmp8;
        bmps[8] = bmp9;
        bmps[9] = bmp10;

        bmpsIndex = 0;
        bmpIndex  = (int)brushSize.value;
//		currentBrush = PaintUtils.ConvertSpriteToTexture2DForBmp(bitmaps[0]);
        currentBrush = PaintUtils.ConvertSpriteToTexture2DForBmp(bmps[bmpsIndex][4 - bmpIndex]);
        currentColor = new Color32(255, 197, 197, 255);
        currentShade = GameObject.Find("Canvas/SubMenus/ColorsAndBrushes/AnimationHolder/Shades").transform.GetChild(0).gameObject;
//		SetUpQuadPaint();
        SetUpFloodFillBrush();
        SelectGameMode();
//		Invoke("EnableDrawing", 1.2f);
    }
예제 #3
0
        public void Update()
        {
            if (Keyboard.current.bKey.wasPressedThisFrame)
            {
                PaintUtils.GaussianBlur(Layers.CurrentLayer.RenderTexture);
            }

            //Blur();
            if (!_isPainting)
            {
                return;
            }

            var pointer = Pointer.current;

            if (pointer == null || CurrentTool == null)
            {
                StopPainting();
                return;
            }

            CurrentTool.Move(_paintLayer.RenderTexture, GetPaintParameters(), _history.GetCurrentState());

            // _copyPaintBufferMaterial.SetFloat(PropId_Alpha, 1);
            //Graphics.Blit(_paintBuffer, _renderTexture, _copyPaintBufferMaterial, 0);
        }
예제 #4
0
        public void GetAlpha_Test(int value, byte espected)
        {
            PaintUtils paintUtils = new PaintUtils();
            var        result     = paintUtils.GetAlpha(value);

            Assert.AreEqual(espected, result);
        }
예제 #5
0
        private void SaveImageThumbnail()
        {
            var texture = Layers.GetImageThumbnail();

            PaintUtils.SaveImageTexture(Path.ChangeExtension(_imageFilename, ".thumb.png"), texture);
            Destroy(texture);
        }
예제 #6
0
        public void NewValue_Test()
        {
            PaintUtils paintUtils = new PaintUtils();

            paintUtils.NewValue(255, 50);
            Assert.Pass();
        }
예제 #7
0
            //public static Layer.AutoSaveLayer Create(PaintContext paint_context, SKCanvas.SaveLayerRec layer_rec)
            //{
            //    return new Layer.AutoSaveLayer(paint_context, layer_rec);
            //}

            public void Dispose()
            {
                if (paint_context_.checkerboard_offscreen_layers)
                {
                    PaintUtils.DrawCheckerboard(paint_context_.canvas, bounds_);
                }
                paint_context_.canvas.Restore();
            }
예제 #8
0
        public void SaveImage()
        {
            if (string.IsNullOrEmpty(_imageFilename))
            {
                return;
            }

            Debug.Log($"SaveImage '{_imageFilename}'");
            var texture = _history.GetCurrentState();

            PaintUtils.SaveImageTexture(_imageFilename, texture);
            Destroy(texture);
            SaveImageThumbnail();
        }
예제 #9
0
파일: BookView.cs 프로젝트: ahackel/Paint
        private void LoadThumbnails()
        {
            for (int i = 0; i < ImageBookConfig.Documents.Count; i++)
            {
                var document  = ImageBookConfig.Documents[i];
                var thumbnail = PaintUtils.LoadImageTexture(document.Name + ".thumb.png");
                if (thumbnail == null)
                {
                    thumbnail = document.Overlay;
                }

                _thumbnails[i].image = thumbnail;
            }
        }
예제 #10
0
 /// <summary>
 /// Updates brush size. Called on OnPointerUp event of BrushSize slider.
 /// </summary>
 public void UpdateBrushSize()
 {
     currentBrush = PaintUtils.ConvertSpriteToTexture2DForBmp(bmps[bmpsIndex][4 - bmpIndex]);
     if (bmpsIndex > 5)
     {
         currentDrawMode = DrawMode.CustomBrush;
         SetUpBitmapBrush();
     }
     else
     {
         currentDrawMode = DrawMode.Stamp;
         SetUpBitmapBrush();
     }
 }
예제 #11
0
        public void BeginFrame()
        {
            var window = FlutterBinding.UI.Window.Instance;

            double devicePixelRatio = window.devicePixelRatio;
            var    physicalSize     = window.physicalSize;
            var    logicalSize      = physicalSize / devicePixelRatio;

            var paragraphBuilder = new ParagraphBuilder(new ParagraphStyle());

            paragraphBuilder.addText("Hello, world!");
            var paragraph = paragraphBuilder.build();

            paragraph.layout(new ParagraphConstraints(width: logicalSize.width));

            var physicalBounds = Offset.zero & physicalSize;
            var recorder       = new PictureRecorder();

            var canvas = new FlutterBinding.UI.Canvas(recorder, physicalBounds);

            canvas.scale((float)devicePixelRatio, (float)devicePixelRatio);

            PaintUtils.DrawCheckerboard(canvas.RecordingCanvas, new SKRect(0, 0, (float)physicalSize.width, (float)physicalSize.height));

            var circlePaint = new SKPaint
            {
                Style       = SKPaintStyle.Stroke,
                IsAntialias = true,
                StrokeWidth = 3,
                Color       = SKColors.OrangeRed
            };

            canvas.drawCircle(new Offset(logicalSize.width / 2, logicalSize.height / 2), 100, circlePaint);

            canvas.drawParagraph(paragraph, new Offset(
                                     (logicalSize.width - paragraph.maxIntrinsicWidth) / 2.0,
                                     (logicalSize.height - paragraph.height) / 2.0));

            var picture = recorder.endRecording();

            var sceneBuilder = new SceneBuilder();

            sceneBuilder.pushClipRect(physicalBounds);
            sceneBuilder.addPicture(Offset.zero, picture);
            sceneBuilder.pop();

            var scene = sceneBuilder.build();

            window.render(scene);
        }
예제 #12
0
    public void DrawLine3()
    {
        //line inside
        //paintEngine.ReadCurrentCustomPattern(paintEngine.ConvertSpriteToTexture2D(patternSprite));
        //line edge
        //paintEngine.customBrush=paintEngine.ConvertSpriteToTexture2D(patternSprite2);
//		paintEngine.ReadCurrentCustomBrush();
//		paintEngine.brushSize=10;
//		paintEngine.lineEdgeSize=0;//10;
//		paintEngine.paintColor=Color.blue;
//		paintEngine.useAdditiveColors=false;
//		paintEngine.isLinePaint=true;
//		paintEngine.isPatternLine=false;
        //paintEngine.DrawLineBrush(new Vector2(11f,256f), new Vector2(500f,/*11f*/256f),8, true);
        //
        paintEngine.SetLineBrush(10, 0, Color.red, /*paintEngine*/ PaintUtils.ConvertSpriteToTexture2D(patternSprite), null);
    }
예제 #13
0
 private void MPPSInstancePage_Paint(object sender, PaintEventArgs e)
 {
     PaintUtils.HighlightRequiredFields(this, e.Graphics, true, Color.Red);
 }
예제 #14
0
 public void ReadUnreadableTex()
 {
     paintSurface = PaintUtils.ReadUnreadableTexture(unreadableTex2D);
     paintEngine.SetDrawingTexture(paintSurface);
 }
예제 #15
0
 public void SetUpVectorBrushType2()
 {
     //paintEngine_Canvas.SetBitmapBrush(brushExample1,AdvancedMobilePaint.BrushProperties.Pattern,false,true,Color.blue,false,false,patternExample2);
     paintEngine.SetVectorBrush(VectorBrush.Rectangular, 32, 32, Color.gray, /*paintEngine*/ PaintUtils.ConvertSpriteToTexture2D(patternSprite) /*patternExample1*/, false, false, false, false);
     //paintEngine.drawMode=AdvancedMobilePaint.DrawMode.Pattern;
     //paintEngine.brushMode=AdvancedMobilePaint.BrushProperties.Pattern;
     paintEngine.customBrushHeight = 128;
     paintEngine.customBrushWidth  = 32;
     paintEngine.drawEnabled       = true;
 }
예제 #16
0
    public void RotateTexture()
    {
        Texture2D rotTex = PaintUtils.RotateTexture(paintSurface, rotationAngle);

        rotatedTextureDisplay.GetComponent <RawImage>().texture = rotTex;
    }
예제 #17
0
 // Use this for initialization
 void Start()
 {
     //SetUpQuadPaint();
     patternExample2 = /*paintEngine*/ PaintUtils.ConvertSpriteToTexture2D(patternSprite2);
     DoReset();
 }
예제 #18
0
        public override void Render(float x, float y, float width, bool curveTop, bool curveBottom, SKCanvas canvas)
        {
            PaintUtils.DrawRoundRect(
                canvas,
                x,
                y,
                width,
                GraphStyle.ChartHeight,
                curveTop ? GraphStyle.CornerRadius : 0,
                curveTop ? GraphStyle.CornerRadius : 0,
                curveBottom ? GraphStyle.CornerRadius : 0,
                curveBottom ? GraphStyle.CornerRadius : 0,
                CommonFade ? GraphStyle.FadedChartPaint : GraphStyle.ChartPaint // FIXME: Faded
                );
            var tapeSnapshot = tape.ToArray();
            var filtered     = tapeSnapshot.Where(smp => smp.values.Count == 1 && smp.values[0] is FloatField)
                               .Select(smp => Tuple.Create(smp.timestamp, (smp.values[0] as FloatField).value));

            if (filtered.Count() != 0)
            {
                var minimumTs = filtered.Min(f => f.Item1) - 0.2f;
                var maximumTs = filtered.Max(f => f.Item1) + 0.2f;

                if (maximumTs - minimumTs < 2)
                {
                    maximumTs += 2;
                }

                var minimumFound = filtered.Select((f, i) => Tuple.Create(i, f)).MinBy(f => f.Item2.Item2).First();
                var minimum      = minimumFound.Item2.Item2;
                var minimumIdx   = minimumFound.Item1;

                var maximumFound = filtered.Select((f, i) => Tuple.Create(i, f)).MaxBy(f => f.Item2.Item2).First();
                var maximum      = maximumFound.Item2.Item2;
                var maximumIdx   = maximumFound.Item1;

                minimum = Math.Min(-0.2f, minimum - 0.5f);
                maximum = Math.Max(maximum + 0.5f, 0.2f);

                // Draw the zero line
                if (minimum <= 0 && maximum > 0)
                {
                    var zeroHeight = Math.Abs(minimum) / Math.Abs(maximum - minimum);
                    canvas.DrawLine(
                        new SKPoint(x, y + GraphStyle.ChartHeight * (1 - zeroHeight)),
                        new SKPoint(x + width, y + GraphStyle.ChartHeight * (1 - zeroHeight)),
                        GraphStyle.ChartFaintLinePaint
                        );
                    canvas.DrawText("0", new SKPoint(x + 9, y + GraphStyle.ChartHeight * (1 - zeroHeight) - 7), GraphStyle.ChartFaintLinePaint);
                }

                // Draw data lines
                //var dataEnum = tapeSnapshot.GetEnumerator();
                //dataEnum.MoveNext();
                //var curr = dataEnum.Current;
                //dataEnum.MoveNext();
                //var next = dataEnum.Current;
                for (var i = 0; i < tapeSnapshot.Count() - 1; i++)
                {
                    var x1Pos = (tapeSnapshot[i].timestamp - minimumTs) / Math.Abs(maximumTs - minimumTs);
                    var y1Pos = ((tapeSnapshot[i].values[0] as FloatField).value - minimum) / Math.Abs(maximum - minimum);
                    var x2Pos = (tapeSnapshot[i + 1].timestamp - minimumTs) / Math.Abs(maximumTs - minimumTs);
                    var y2Pos = ((tapeSnapshot[i + 1].values[0] as FloatField).value - minimum) / Math.Abs(maximum - minimum);
                    canvas.DrawLine(
                        new SKPoint(x + width * x1Pos, y + GraphStyle.ChartHeight * (1 - y1Pos)),
                        new SKPoint(x + width * x2Pos, y + GraphStyle.ChartHeight * (1 - y2Pos)),
                        GraphStyle.ChartLinePaint // FIXME: Faded
                        );

                    //dataEnum.MoveNext();
                    //curr = next;
                    //next = dataEnum.Current;
                }

                // Draw data points
                {
                    var i = 0;
                    foreach (var smp in tape)
                    {
                        var xPos = (smp.timestamp - minimumTs) / Math.Abs(maximumTs - minimumTs);
                        var yPos = ((smp.values[0] as FloatField).value - minimum) / Math.Abs(maximum - minimum);
                        canvas.DrawCircle(
                            new SKPoint(x + width * xPos, y + GraphStyle.ChartHeight * (1 - yPos)),
                            2,
                            GraphStyle.ChartBoldLinePaint // FIXME: Faded
                            );

                        if (i == maximumIdx)
                        {
                            canvas.DrawText($"{maximum}", new SKPoint(x + width * xPos, y + GraphStyle.ChartHeight * (1 - yPos) - 5), GraphStyle.ChartCenteredShadowLinePaint);
                            canvas.DrawText($"{maximum}", new SKPoint(x + width * xPos, y + GraphStyle.ChartHeight * (1 - yPos) - 5), GraphStyle.ChartCenteredBoldLinePaint);
                        }
                        else if (i == minimumIdx)
                        {
                            canvas.DrawText($"{minimum}", new SKPoint(x + width * xPos, y + GraphStyle.ChartHeight * (1 - yPos) + 16), GraphStyle.ChartCenteredShadowLinePaint);
                            canvas.DrawText($"{minimum}", new SKPoint(x + width * xPos, y + GraphStyle.ChartHeight * (1 - yPos) + 16), GraphStyle.ChartCenteredBoldLinePaint);
                        }
                        i++;
                    }
                }
            }
            else
            {
                canvas.DrawText("No data", new SKPoint(x + width / 2, y + GraphStyle.ChartHeight / 2), GraphStyle.ChartCenteredBoldLinePaint);
            }
        }
예제 #19
0
 public void SetUpBitmapBrushType2()
 {
     paintEngine.drawMode = AdvancedMobilePaint.DrawMode.CustomBrush;
     paintEngine.SetBitmapBrush(brushExample1, AdvancedMobilePaint.BrushProperties.Pattern, false, true, Color.blue, false, false, /*paintEngine*/ PaintUtils.ConvertSpriteToTexture2D(patternSprite));
     paintEngine.drawEnabled = true;
 }
예제 #20
0
 private void ScheduledProcedureStepPage_Paint(object sender, PaintEventArgs e)
 {
     PaintUtils.HighlightRequiredFields(this, e.Graphics, true, Color.Red);
 }
예제 #21
0
 private void ImagingServiceRequestPage_Paint(object sender, PaintEventArgs e)
 {
     PaintUtils.HighlightRequiredFields(this, e.Graphics, true, Color.Red);
 }