ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Classes | Public Types | Public Member Functions | Protected Attributes | Properties | List of all members
ImageResizer.Resizing.LayoutBuilder Class Reference

Classes

class  PointSet
 

Public Types

enum  PointFlags { PointFlags.Ring = 1, PointFlags.Invisible = 2, PointFlags.Ignored = 4 }
 
enum  PointTranslationBehavior { Exact, ClosestVisiblePoint, ClosestImagePoint, Empty }
 

Public Member Functions

PointSet AddRing (string name, PointF[] points)
 
bool ContainsRing (string name)
 
PointSet AddRing (string name, BoxPadding padding)
 Inflates the last ring using the specified padding options. Returns the resulting ring object More...
 
PointSet AddInvisiblePolygon (string name, PointF[] points)
 Add points this way to see where they will occur on the destination image More...
 
PointSet AddIgnoredPoints (string name, PointF[] points)
 
RectangleF GetBoundingBox ()
 Gets a bounding box that encloses all rings that don't have ExcludeFromBoundingBox set. More...
 
void Rotate (double degrees, PointF origin)
 Rotates all existing rings (Except those flagged ignore) More...
 
void Normalize (PointF origin)
 Normalizes all rings and invisible polygons so that the outermost ring's bounding box starts at the specified orign. More...
 
void Round ()
 
void Scale (double factor, PointF origin)
 Scales all rings and invisible polygons by the specified factor, around the specified point. More...
 
void Shift (RectangleF from, RectangleF to)
 Translates and scales all rings and invisible polygons as specified. More...
 

Protected Attributes

Dictionary< string, PointSetring = new Dictionary<string, PointSet>(10, StringComparer.OrdinalIgnoreCase)
 An ordered, named collection of polygons. pointsToTranslate, imageOuterEdge, imageAreaOuterEdge. More...
 
List< PointSetringList = new List<PointSet>(10)
 

Properties

PointF[] this[string key] [get, set]
 Access and set the Point[] arrays of rings by key. Case-insensitive. More...
 
PointSet LastRing [get]
 Returns the last ring that was added. Only returns PointSets where flags = Ring More...
 

Detailed Description

Definition at line 9 of file LayoutBuilder.cs.

Member Enumeration Documentation

Enumerator
Ring 

This polygon participates in the layout phase, and reserves space when added. Affected by all batch operations. Will be returned by LastRing until a new ring is added.

Invisible 

Doesn't participate in layout, takes no space, but is affected by batch operations. Will never be returned by LastRing and ignored when calculating bounding boxes.

Ignored 

Completely ignored by all operations, left intact.

Definition at line 11 of file LayoutBuilder.cs.

11  {
12 
13  /// <summary>
14  /// This polygon participates in the layout phase, and reserves space when added. Affected by all batch operations. Will be returned by LastRing until a new ring is added.
15  /// </summary>
16  Ring = 1,
17  /// <summary>
18  /// Doesn't participate in layout, takes no space, but is affected by batch operations. Will never be returned by LastRing and ignored when calculating bounding boxes.
19  /// </summary>
20  Invisible = 2,
21  /// <summary>
22  /// Completely ignored by all operations, left intact.
23  /// </summary>
24  Ignored = 4
25 
26  }
This polygon participates in the layout phase, and reserves space when added. Affected by all batch o...
Doesn&#39;t participate in layout, takes no space, but is affected by batch operations. Will never be returned by LastRing and ignored when calculating bounding boxes.
Completely ignored by all operations, left intact.

Member Function Documentation

PointSet ImageResizer.Resizing.LayoutBuilder.AddInvisiblePolygon ( string  name,
PointF[]  points 
)
inline

Add points this way to see where they will occur on the destination image

Parameters
name
points
Returns

Definition at line 114 of file LayoutBuilder.cs.

114  {
115  PointSet ps = new PointSet(points);
116  ps.flags = PointFlags.Invisible;
117  ring.Add(name, ps);
118  ringList.Add(ps);
119  return ps;
120  }
PointSet ImageResizer.Resizing.LayoutBuilder.AddRing ( string  name,
BoxPadding  padding 
)
inline

Inflates the last ring using the specified padding options. Returns the resulting ring object

Parameters
name
padding
Returns

Definition at line 105 of file LayoutBuilder.cs.

105  {
106  return AddRing(name, PolygonMath.InflatePoly(LastRing.points, padding.GetEdgeOffsets()));
107  }
PointSet LastRing
Returns the last ring that was added. Only returns PointSets where flags = Ring
static PointF[] InflatePoly(PointF[] poly, float offset)
Expands all sides on the specified polygon by the specified offset. Assumes the polygon is concave...
Definition: PolygonMath.cs:522
Defines a collection of utility functions for manipulating polygons. These functions may be (re)moved...
Definition: PolygonMath.cs:13
RectangleF ImageResizer.Resizing.LayoutBuilder.GetBoundingBox ( )
inline

Gets a bounding box that encloses all rings that don't have ExcludeFromBoundingBox set.

Returns

Definition at line 133 of file LayoutBuilder.cs.

Referenced by ImageResizer.ImageBuilder.EndLayout().

133  {
134  List<PointF> points = new List<PointF>(ring.Count * 5);
135 
136  foreach (PointSet val in ringList) {
137  if (val.flags == PointFlags.Ring) points.AddRange(val.points);
138  }
139  return PolygonMath.GetBoundingBox(points.ToArray());
140  }
void ImageResizer.Resizing.LayoutBuilder.Normalize ( PointF  origin)
inline

Normalizes all rings and invisible polygons so that the outermost ring's bounding box starts at the specified orign.

Parameters
origin
Returns

Definition at line 158 of file LayoutBuilder.cs.

Referenced by ImageResizer.ImageBuilder.LayoutNormalize().

158  {
159  PointF offset = GetBoundingBox().Location;
160  offset.X *= -1;
161  offset.Y *= -1;
162 
163  foreach (PointSet ps in ringList)
164  if (ps.flags != PointFlags.Ignored) ps.points = PolygonMath.MovePoly(ps.points, offset);
165  }
RectangleF GetBoundingBox()
Gets a bounding box that encloses all rings that don&#39;t have ExcludeFromBoundingBox set...
void ImageResizer.Resizing.LayoutBuilder.Rotate ( double  degrees,
PointF  origin 
)
inline

Rotates all existing rings (Except those flagged ignore)

Parameters
degrees
origin
Returns

Definition at line 147 of file LayoutBuilder.cs.

Referenced by ImageResizer.ImageBuilder.LayoutRotate().

147  {
148  foreach (PointSet ps in ringList)
149  if (ps.flags != PointFlags.Ignored) ps.points = PolygonMath.RotatePoly(ps.points, degrees, origin);
150  }
void ImageResizer.Resizing.LayoutBuilder.Scale ( double  factor,
PointF  origin 
)
inline

Scales all rings and invisible polygons by the specified factor, around the specified point.

Parameters
factor
origin

Definition at line 178 of file LayoutBuilder.cs.

178  {
179  foreach (PointSet ps in ringList)
180  if (ps.flags != PointFlags.Ignored) ps.points = PolygonMath.ScalePoints(ps.points, factor,factor, origin);
181  }
void ImageResizer.Resizing.LayoutBuilder.Shift ( RectangleF  from,
RectangleF  to 
)
inline

Translates and scales all rings and invisible polygons as specified.

Parameters
from
to

Definition at line 188 of file LayoutBuilder.cs.

188  {
189 
190  PointF fromOrigin = new PointF(from.X + (from.Width /2), from.Y + (from.Height /2));
191  PointF toOrigin = new PointF(to.X + (to.Width /2), to.Y + (to.Height /2));
192 
193  PointF offset = new PointF(toOrigin.X - fromOrigin.X,toOrigin.Y - fromOrigin.Y);
194  double xd = to.Width / from.Width;
195  double yd = to.Height / from.Height;
196 
197  //Offset points
198  foreach (PointSet ps in ringList)
199  if (ps.flags != PointFlags.Ignored) ps.points = PolygonMath.MovePoly(ps.points,offset );
200  //Scale points
201  foreach (PointSet ps in ringList)
202  if (ps.flags != PointFlags.Ignored) ps.points = PolygonMath.ScalePoints(ps.points, xd,yd, toOrigin );
203  }

Member Data Documentation

Dictionary<string, PointSet> ImageResizer.Resizing.LayoutBuilder.ring = new Dictionary<string, PointSet>(10, StringComparer.OrdinalIgnoreCase)
protected

An ordered, named collection of polygons. pointsToTranslate, imageOuterEdge, imageAreaOuterEdge.

Definition at line 59 of file LayoutBuilder.cs.

Property Documentation

PointSet ImageResizer.Resizing.LayoutBuilder.LastRing
get

Returns the last ring that was added. Only returns PointSets where flags = Ring

Definition at line 78 of file LayoutBuilder.cs.

Referenced by ImageResizer.ImageBuilder.RenderBackground().

PointF [] ImageResizer.Resizing.LayoutBuilder.this[string key]
getset

Access and set the Point[] arrays of rings by key. Case-insensitive.

Parameters
key
Returns

Definition at line 66 of file LayoutBuilder.cs.


The documentation for this class was generated from the following file: