Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jingwood/d2dlib
Browse files Browse the repository at this point in the history
  • Loading branch information
jingwood committed Oct 30, 2022
2 parents 4d35060 + 1f1c0d0 commit 89ca4a4
Show file tree
Hide file tree
Showing 16 changed files with 647 additions and 156 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
root = true

# Don't use tabs for indentation.
[*.cs]
[*.{cs,c,cpp,h,hpp}]
indent_style = tabs
indent_style = tab
indent_size = 2
insert_final_newline = true
charset = utf-8-bom
Expand Down
40 changes: 24 additions & 16 deletions src/D2DLibExport/D2DDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,23 @@ public void Resize()
if (Handle != HANDLE.Zero) D2D.ResizeContext(this.Handle);
}

public D2DPen CreatePen(D2DColor color, D2DDashStyle dashStyle = D2DDashStyle.Solid,
public D2DStrokeStyle CreateStrokeStyle(float[] dashes = null, float dashOffset = 0.0f,
D2DCapStyle startCap = D2DCapStyle.Flat, D2DCapStyle endCap = D2DCapStyle.Flat)
{
HANDLE handle = D2D.CreateStrokeStyle(this.Handle, dashes, dashes != null ? (uint)dashes.Length : 0, dashOffset, startCap, endCap);

return handle == HANDLE.Zero ? null : new D2DStrokeStyle(this, handle, dashes, dashOffset, startCap, endCap);
}

public D2DPen CreatePen(D2DColor color, D2DDashStyle dashStyle = D2DDashStyle.Solid,
float[] customDashes = null, float dashOffset = 0.0f)
{
HANDLE handle = D2D.CreatePen(this.Handle, color, dashStyle,
customDashes, customDashes != null ? (uint)customDashes.Length : 0, dashOffset);
customDashes, customDashes != null ? (uint)customDashes.Length : 0, dashOffset);

return handle == HANDLE.Zero ? null : new D2DPen(this, handle, color, dashStyle, customDashes, dashOffset);
}

internal void DestroyPen(D2DPen pen)
{
if (pen == null) throw new ArgumentNullException(nameof(pen));
Expand All @@ -79,15 +87,15 @@ public D2DSolidColorBrush CreateSolidColorBrush(D2DColor color)
}

public D2DLinearGradientBrush CreateLinearGradientBrush(D2DPoint startPoint, D2DPoint endPoint,
D2DGradientStop[] gradientStops)
D2DGradientStop[] gradientStops)
{
HANDLE handle = D2D.CreateLinearGradientBrush(this.Handle, startPoint, endPoint, gradientStops, (uint)gradientStops.Length);
return new D2DLinearGradientBrush(handle, gradientStops);
}

public D2DRadialGradientBrush CreateRadialGradientBrush(D2DPoint origin, D2DPoint offset,
FLOAT radiusX, FLOAT radiusY,
D2DGradientStop[] gradientStops)
FLOAT radiusX, FLOAT radiusY,
D2DGradientStop[] gradientStops)
{
HANDLE handle = D2D.CreateRadialGradientBrush(this.Handle, origin, offset, radiusX, radiusY,
gradientStops, (uint)gradientStops.Length);
Expand All @@ -113,13 +121,13 @@ public D2DPathGeometry CreatePathGeometry()
return new D2DPathGeometry(this.Handle, geoHandle);
}

public D2DGeometry CreateEllipseGeometry(D2DPoint origin, D2DSize size)
{
var ellipse = new D2DEllipse(origin, size);
return new D2DGeometry(this.Handle, D2D.CreateEllipseGeometry(this.Handle, ref ellipse));
}
public D2DGeometry CreateEllipseGeometry(D2DPoint origin, D2DSize size)
{
var ellipse = new D2DEllipse(origin, size);
return new D2DGeometry(this.Handle, D2D.CreateEllipseGeometry(this.Handle, ref ellipse));
}

public D2DGeometry CreatePieGeometry(D2DPoint origin, D2DSize size, float startAngle, float endAngle)
public D2DGeometry CreatePieGeometry(D2DPoint origin, D2DSize size, float startAngle, float endAngle)
{
var path = this.CreatePathGeometry();

Expand Down Expand Up @@ -174,10 +182,10 @@ public D2DBitmap CreateBitmapFromMemory(UINT width, UINT height, UINT stride, In
return d2dbmp == HANDLE.Zero ? null : new D2DBitmap(d2dbmp);
}

public D2DLayer CreateLayer()
{
return new D2DLayer(D2D.CreateLayer(this.Handle));
}
public D2DLayer CreateLayer()
{
return new D2DLayer(D2D.CreateLayer(this.Handle));
}

[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr obj);
Expand Down
178 changes: 178 additions & 0 deletions src/D2DLibExport/D2DEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,183 @@ public enum LayerOptions
/// </summary>
InitializeForClearType = 0x00000001,
}

/// <summary>
/// The font stretch enumeration describes relative change from the normal aspect ratio
/// as specified by a font designer for the glyphs in a font.
/// Values less than 1 or greater than 9 are considered to be invalid, and they are rejected by font API functions.
/// </summary>
public enum D2DFontWeight
{
/// <summary>
/// Predefined font weight : Thin (100).
/// </summary>
Thin = 100,

/// <summary>
/// Predefined font weight : Extra-light (200).
/// </summary>
ExtraLight = 200,

/// <summary>
/// Predefined font weight : Ultra-light (200).
/// </summary>
UltraLight = 200,

/// <summary>
/// Predefined font weight : Light (300).
/// </summary>
Light = 300,

/// <summary>
/// Predefined font weight : Semi-light (350).
/// </summary>
SemiLight = 350,

/// <summary>
/// Predefined font weight : Normal (400).
/// </summary>
Normal = 400,

/// <summary>
/// Predefined font weight : Regular (400).
/// </summary>
Regular = 400,

/// <summary>
/// Predefined font weight : Medium (500).
/// </summary>
Medium = 500,

/// <summary>
/// Predefined font weight : Demi-bold (600).
/// </summary>
DemiBold = 600,

/// <summary>
/// Predefined font weight : Semi-bold (600).
/// </summary>
SemiBold = 600,

/// <summary>
/// Predefined font weight : Bold (700).
/// </summary>
Bold = 700,

/// <summary>
/// Predefined font weight : Extra-bold (800).
/// </summary>
ExtraBold = 800,

/// <summary>
/// Predefined font weight : Ultra-bold (800).
/// </summary>
UltraBold = 800,

/// <summary>
/// Predefined font weight : Black (900).
/// </summary>
Black = 900,

/// <summary>
/// Predefined font weight : Heavy (900).
/// </summary>
WeightHeavy = 900,

/// <summary>
/// Predefined font weight : Extra-black (950).
/// </summary>
ExtraBlack = 950,

/// <summary>
/// Predefined font weight : Ultra-black (950).
/// </summary>
UltraBlack = 950
};

/// <summary>
/// The font style enumeration describes the slope style of a font face, such as Normal, Italic or Oblique.
/// Values other than the ones defined in the enumeration are considered to be invalid, and they are rejected by font API functions.
/// </summary>
public enum D2DFontStyle
{
/// <summary>
/// Font slope style : Normal.
/// </summary>
Normal,

/// <summary>
/// Font slope style : Oblique.
/// </summary>
Oblique,

/// <summary>
/// Font slope style : Italic.
/// </summary>
Italic
};

/// <summary>
/// The font stretch enumeration describes relative change from the normal aspect ratio
/// as specified by a font designer for the glyphs in a font.
/// Values less than 1 or greater than 9 are considered to be invalid, and they are rejected by font API functions.
/// </summary>
public enum D2DFontStretch
{
/// <summary>
/// Predefined font stretch : Not known (0).
/// </summary>
Undefined = 0,

/// <summary>
/// Predefined font stretch : Ultra-condensed (1).
/// </summary>
UltraCondensed = 1,

/// <summary>
/// Predefined font stretch : Extra-condensed (2).
/// </summary>
ExtraCondensed = 2,

/// <summary>
/// Predefined font stretch : Condensed (3).
/// </summary>
Condensed = 3,

/// <summary>
/// Predefined font stretch : Semi-condensed (4).
/// </summary>
SemiCondensed = 4,

/// <summary>
/// Predefined font stretch : Normal (5).
/// </summary>
Normal = 5,

/// <summary>
/// Predefined font stretch : Medium (5).
/// </summary>
Medium = 5,

/// <summary>
/// Predefined font stretch : Semi-expanded (6).
/// </summary>
SemiExpanded = 6,

/// <summary>
/// Predefined font stretch : Expanded (7).
/// </summary>
Expanded = 7,

/// <summary>
/// Predefined font stretch : Extra-expanded (8).
/// </summary>
ExtraExpanded = 8,

/// <summary>
/// Predefined font stretch : Ultra-expanded (9).
/// </summary>
UltraExpanded = 9
};
}

Loading

0 comments on commit 89ca4a4

Please sign in to comment.