Exemple #1
0
        public void scale(LDSize s, AspectRatioMode mode)
        {
            LDSize size = this.scaled(s, mode);

            this.wd = size.wd;
            this.ht = size.ht;
        }
Exemple #2
0
        public LDSize scaled(LDSize s, AspectRatioMode mode)
        {
            if (s.isEmpty())
            {
                return(new LDSize());
            }
            LDSize S;

            switch (mode)
            {
            case AspectRatioMode.IgnoreAspectRatio:
                S = s;
                break;

            case AspectRatioMode.KeepAspectRatio:
                S = new LDSize(this.wd * Math.Min(s.wd / this.wd, s.ht / this.ht), this.ht * Math.Min(s.wd / this.wd, s.ht / this.ht));
                break;

            case AspectRatioMode.KeepAspectRatioByExpanding:
                S = new LDSize(this.wd * Math.Max(s.wd / this.wd, s.ht / this.ht), this.ht * Math.Max(s.wd / this.wd, s.ht / this.ht));
                break;

            default:
                S = null;
                break;
            }
            return(S);
        }
Exemple #3
0
 public LDRect(LDPoint topleft, LDSize size)
 {
     this.xp = topleft.x();
     this.yp = topleft.y();
     this.w  = size.width();
     this.h  = size.height();
 }
Exemple #4
0
 public LDRect(LDPoint topleft, LDSize size)
 {
     this.xp = topleft.x();
     this.yp = topleft.y();
     this.w = size.width();
     this.h = size.height();
 }
Exemple #5
0
        public void updateUvMap(LDSize ImageSize)
        {
            m_uvMap.Clear();
            for (int i = 0; i < m_points.size(); i++)
            {
                float u = m_points[i].x() / ImageSize.width();
                float v = m_points[i].y() / ImageSize.height();

                LDMathUtil.clamp(u, 0.0f, 1.0f);
                LDMathUtil.clamp(v, 0.0f, 1.0f);

                m_uvMap.Add(new LDPoint(u, v));
            }
        }
Exemple #6
0
 public LDSize(LDSize sz)
 {
     this.wd = sz.wd;
     this.ht = sz.ht;
 }
Exemple #7
0
 public LDSize boundedTo(LDSize s)
 {
     return(new LDSize(Math.Min(this.wd, s.wd), Math.Min(this.wd, this.ht)));
 }
Exemple #8
0
 public LDSize expandedTo(LDSize s)
 {
     return(new LDSize(Math.Max(this.wd, s.wd), Math.Max(this.wd, this.ht)));
 }
Exemple #9
0
 public void setSize(LDSize s)
 {
     this.w = s.width();
     this.h = s.height();
 }
Exemple #10
0
 public void setSize(LDSize s)
 {
     this.w = s.width();
     this.h = s.height();
 }
Exemple #11
0
 public LDSize expandedTo(LDSize s)
 {
     return new LDSize(Math.Max(this.wd, s.wd), Math.Max(this.wd, this.ht));
 }
Exemple #12
0
 public LDSize boundedTo(LDSize s)
 {
     return new LDSize(Math.Min(this.wd, s.wd), Math.Min(this.wd, this.ht));
 }
Exemple #13
0
 public LDSize(LDSize sz)
 {
     this.wd = sz.wd;
     this.ht = sz.ht;
 }
Exemple #14
0
 public LDSize scaled(LDSize s, AspectRatioMode mode)
 {
     if (s.isEmpty()) return new LDSize();
     LDSize S;
     switch (mode)
     {
         case AspectRatioMode.IgnoreAspectRatio:
             S = s;
             break;
         case AspectRatioMode.KeepAspectRatio:
             S = new LDSize(this.wd * Math.Min(s.wd / this.wd, s.ht / this.ht), this.ht * Math.Min(s.wd / this.wd, s.ht / this.ht));
             break;
         case AspectRatioMode.KeepAspectRatioByExpanding:
             S = new LDSize(this.wd * Math.Max(s.wd / this.wd, s.ht / this.ht), this.ht * Math.Max(s.wd / this.wd, s.ht / this.ht));
             break;
         default:
             S = null;
             break;
     }
     return S;
 }
Exemple #15
0
 public void scale(LDSize s, AspectRatioMode mode)
 {
     LDSize size = this.scaled(s, mode);
     this.wd = size.wd;
     this.ht = size.ht;
 }
Exemple #16
0
        public void updateUvMap(LDSize ImageSize)
        {
            m_uvMap.Clear();
            for (int i = 0; i < m_points.size(); i++)
            {
                float u = m_points[i].x() / ImageSize.width();
                float v = m_points[i].y() / ImageSize.height();

                LDMathUtil.clamp(u, 0.0f, 1.0f);
                LDMathUtil.clamp(v, 0.0f, 1.0f);

                m_uvMap.Add(new LDPoint(u, v));
            }
        }