示例#1
0
        public override void OnDraw()
        {
            background.A_Byte = (uint)alpha.Value();
            alpha.Label("Opacity: " + ((uint)((alpha.Value() / 255.0) * 100)).ToString() + "%");
            Pictor.GammaLookupTable gamma = new Pictor.GammaLookupTable(1.8);
            Pictor.PixelFormat.IBlender NormalBlender = new Pictor.PixelFormat.BlenderBGRA();
            Pictor.PixelFormat.IBlender GammaBlender = new Pictor.PixelFormat.BlenderGammaBGRA(gamma);
            Pictor.PixelFormat.FormatRGBA pixf = new Pictor.PixelFormat.FormatRGBA(RenderBufferWindow, NormalBlender);
            Pictor.PixelFormat.FormatClippingProxy clippingProxy = new Pictor.PixelFormat.FormatClippingProxy(pixf);

            clippingProxy.Clear(new Pictor.RGBA_Doubles(1, 1, 1));

            Pictor.AntiAliasedScanlineRasterizer ras = new Pictor.AntiAliasedScanlineRasterizer();
            Pictor.Scanline sl = new Pictor.Scanline();

            Pictor.VertexSource.Ellipse e = new Pictor.VertexSource.Ellipse();

            // TODO: If you drag the control circles below the bottom of the window we get an exception.  This does not happen in Pictor.
            // It needs to be debugged.  Turning on clipping fixes it.  But standard Pictor works without clipping.  Could be a bigger problem than this.
            //ras.clip_box(0, 0, Width(), Height());

            // Render two "control" circles
            e.Init(m_x[0], m_y[0], 3, 3, 16);
            ras.AddPath(e);
            Pictor.Renderer.RenderSolid(clippingProxy, ras, sl, new Pictor.RGBA_Bytes(127, 127, 127));
            e.Init(m_x[1], m_y[1], 3, 3, 16);
            ras.AddPath(e);
            Pictor.Renderer.RenderSolid(clippingProxy, ras, sl, new Pictor.RGBA_Bytes(127, 127, 127));

            double d = 0.0;

            // Creating a rounded rectangle
            Pictor.VertexSource.RoundedRect r = new Pictor.VertexSource.RoundedRect(m_x[0] + d, m_y[0] + d, m_x[1] + d, m_y[1] + d, radius.Value());
            r.NormalizeRadius();

            if (border.Status()) {
                Pictor.VertexSource.StrokeConverter p = new Pictor.VertexSource.StrokeConverter(r);
                p.Width(1.0);
                ras.AddPath(p);
            }
            else {
                ras.AddPath(r);
            }

            pixf.Blender = GammaBlender;

            Pictor.Renderer.RenderSolid(clippingProxy, ras, sl, background);

            // this was in the original demo, but it does nothing because we changed the blender not the Gamma function.
            //ras.Gamma(new gamma_none());
            // so let's change the blender instead
            pixf.Blender = NormalBlender;

            if (null != dialog && !dialog.Running && dialog.Result)
                System.Windows.Forms.Application.Exit();

            // Render the controls
            //m_radius.Render(ras, sl, clippingProxy);
            //m_gamma.Render(ras, sl, clippingProxy);
            //m_offset.Render(ras, sl, clippingProxy);
            //m_white_on_black.Render(ras, sl, clippingProxy);
            //m_DrawAsOutlineCheckBox.Render(ras, sl, clippingProxy);
            base.OnDraw();
        }
示例#2
0
        public override void OnDraw()
        {
            background.A_Byte = (uint)alpha.Value();
            alpha.Label("Opacity: " + ((uint)((alpha.Value() / 255.0) * 100)).ToString() + "%");
            Pictor.GammaLookupTable                gamma         = new Pictor.GammaLookupTable(1.8);
            Pictor.PixelFormat.IBlender            NormalBlender = new Pictor.PixelFormat.BlenderBGRA();
            Pictor.PixelFormat.IBlender            GammaBlender  = new Pictor.PixelFormat.BlenderGammaBGRA(gamma);
            Pictor.PixelFormat.FormatRGBA          pixf          = new Pictor.PixelFormat.FormatRGBA(RenderBufferWindow, NormalBlender);
            Pictor.PixelFormat.FormatClippingProxy clippingProxy = new Pictor.PixelFormat.FormatClippingProxy(pixf);

            clippingProxy.Clear(new Pictor.RGBA_Doubles(1, 1, 1));

            Pictor.AntiAliasedScanlineRasterizer ras = new Pictor.AntiAliasedScanlineRasterizer();
            Pictor.Scanline sl = new Pictor.Scanline();

            Pictor.VertexSource.Ellipse e = new Pictor.VertexSource.Ellipse();

            // TODO: If you drag the control circles below the bottom of the window we get an exception.  This does not happen in Pictor.
            // It needs to be debugged.  Turning on clipping fixes it.  But standard Pictor works without clipping.  Could be a bigger problem than this.
            //ras.clip_box(0, 0, Width(), Height());

            // Render two "control" circles
            e.Init(m_x[0], m_y[0], 3, 3, 16);
            ras.AddPath(e);
            Pictor.Renderer.RenderSolid(clippingProxy, ras, sl, new Pictor.RGBA_Bytes(127, 127, 127));
            e.Init(m_x[1], m_y[1], 3, 3, 16);
            ras.AddPath(e);
            Pictor.Renderer.RenderSolid(clippingProxy, ras, sl, new Pictor.RGBA_Bytes(127, 127, 127));

            double d = 0.0;

            // Creating a rounded rectangle
            Pictor.VertexSource.RoundedRect r = new Pictor.VertexSource.RoundedRect(m_x[0] + d, m_y[0] + d, m_x[1] + d, m_y[1] + d, radius.Value());
            r.NormalizeRadius();

            if (border.Status())
            {
                Pictor.VertexSource.StrokeConverter p = new Pictor.VertexSource.StrokeConverter(r);
                p.Width(1.0);
                ras.AddPath(p);
            }
            else
            {
                ras.AddPath(r);
            }

            pixf.Blender = GammaBlender;

            Pictor.Renderer.RenderSolid(clippingProxy, ras, sl, background);

            // this was in the original demo, but it does nothing because we changed the blender not the Gamma function.
            //ras.Gamma(new gamma_none());
            // so let's change the blender instead
            pixf.Blender = NormalBlender;

            if (null != dialog && !dialog.Running && dialog.Result)
            {
                System.Windows.Forms.Application.Exit();
            }

            // Render the controls
            //m_radius.Render(ras, sl, clippingProxy);
            //m_gamma.Render(ras, sl, clippingProxy);
            //m_offset.Render(ras, sl, clippingProxy);
            //m_white_on_black.Render(ras, sl, clippingProxy);
            //m_DrawAsOutlineCheckBox.Render(ras, sl, clippingProxy);
            base.OnDraw();
        }