RotateZoomEffectConfigToken.cs :  » GUI » Paint.net » PaintDotNet » Effects » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GUI » Paint.net 
Paint.net » PaintDotNet » Effects » RotateZoomEffectConfigToken.cs
/////////////////////////////////////////////////////////////////////////////////
// Paint.NET                                                                   //
// Copyright (C) dotPDN LLC, Rick Brewster, Tom Jackson, and contributors.     //
// Portions Copyright (C) Microsoft Corporation. All Rights Reserved.          //
// See src/Resources/Files/License.txt for full licensing and attribution      //
// details.                                                                    //
// .                                                                           //
/////////////////////////////////////////////////////////////////////////////////

using PaintDotNet;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace PaintDotNet.Effects{
    public class RotateZoomEffectConfigToken
        : EffectConfigToken
    {
        internal class RzInfo
        {
            // gradients
            public float startX;
            public float startY;
            public float startZ;
            public float dsxdx;
            public float dsydx;
            public float dszdx;
            public float dsxdy;
            public float dsydy;
            public float dszdy;

            private void Transform(RotateZoomEffectConfigToken token, int x, int y, out float sx, out float sy, out float sz)
            {
                float rb = token.preRotateZ;
                float ra = token.postRotateZ;
                float r = -token.tilt;
                float crb = (float)Math.Cos(rb);
                float cr = (float)Math.Cos(r);
                float cra = (float)Math.Cos(ra);
                float srb = (float)Math.Sin(rb);
                float sr = (float)Math.Sin(r);
                float sra = (float)Math.Sin(ra);
                float ox = x, oy = y, oz = 0;
            
                sx = (ox * crb + oy * srb) / cr;
                sy = -ox * srb + oy * crb;

                sz = sx * sr;
                sx = sx / cr;
                ox = sx; oy = sy; oz = sz;
            
                sx =  ox * cra + oy * sra;
                sy = -ox * sra + oy * cra;
            }

            public void Update(RotateZoomEffectConfigToken token)
            {
                Transform(token, 0, 0, out startX, out startY, out startZ);
                Transform(token, 1, 0, out dsxdx, out dsydx, out dszdx);
                Transform(token, 0, 1, out dsxdy, out dsydy, out dszdy);
    
                dsxdx -= startX; dsydx -= startY; dszdx -= startZ;
                dsxdy -= startX; dsydy -= startY; dszdy -= startZ;
            }
        }

        private void UpdateRzInfo()
        {
            lock (this)
            {
                computedOnce = new RzInfo();
                computedOnce.Update(this);
            }
        }

        private bool highQuality;
        public bool HighQuality
        {
            get
            {
                return highQuality;
            }

            set
            {
                this.highQuality = value;
            }
        }

        private RzInfo computedOnce;
        internal RzInfo ComputedOnce
        {
            get
            {
                return computedOnce;
            }
        }

        private float preRotateZ;
        public float PreRotateZ
        {
            get
            {
                return preRotateZ;
            }

            set
            {
                preRotateZ = value;
                UpdateRzInfo();
            }
        }

        private float postRotateZ;
        public float PostRotateZ
        {
            get
            {
                return postRotateZ;
            }

            set
            {
                postRotateZ = value;
                UpdateRzInfo();
            }
        }

        private float tilt;
        public float Tilt
        {
            get
            {
                return tilt;
            }

            set
            {
                tilt = value;
                UpdateRzInfo();
            }
        }

        private float zoom;
        public float Zoom
        {
            get
            {
                return zoom;
            }

            set
            {
                zoom = value;
                UpdateRzInfo();
            }
        }

        private bool sourceAsBackground;
        public bool SourceAsBackground
        {
            get
            {
                return sourceAsBackground;
            }

            set
            {
                sourceAsBackground = value;
                UpdateRzInfo();
            }
        }

        private bool tile;
        public bool Tile
        {
            get
            {
                return tile;
            }

            set
            {
                tile = value;
                UpdateRzInfo();
            }
        }

        private PointF offset;
        public PointF Offset
        {
            get
            {
                return offset;
            }

            set
            {
                offset = value;
                UpdateRzInfo();
            }
        }

        public RotateZoomEffectConfigToken(bool highQuality, float preRotateZ, float postRotateZ, 
            float tilt, float zoom, PointF offset, bool sourceAsBackground, bool tile)
        {
            this.highQuality = highQuality;
            this.preRotateZ = preRotateZ;
            this.postRotateZ = postRotateZ;
            this.tilt = tilt;
            this.zoom = zoom;
            this.offset = offset;
            this.sourceAsBackground = sourceAsBackground;
            this.tile = tile;
            UpdateRzInfo();
        }

        protected RotateZoomEffectConfigToken(RotateZoomEffectConfigToken copyMe)
        {
            this.highQuality = copyMe.highQuality;
            this.preRotateZ = copyMe.preRotateZ;
            this.postRotateZ = copyMe.postRotateZ;
            this.tilt = copyMe.tilt;
            this.zoom = copyMe.zoom;
            this.offset = copyMe.offset;
            this.sourceAsBackground = copyMe.sourceAsBackground;
            this.tile = copyMe.tile;
            UpdateRzInfo();
        }

        public override object Clone()
        {
            return new RotateZoomEffectConfigToken(this);
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.