Platforms to show: All Mac Windows Linux Cross-Platform

DirectDrawGraphicsMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class Windows MBS Win Plugin 20.3 No Yes No Yes, Windows only No
Function: The class for drawing with DirectDraw 2D into a graphics context in Xojo.
Example:
dim p as Picture = BitmapForCaching(me.Width, me.Height)
dim g as graphics = p.Graphics

// Clear image with white
g.DrawingColor = &cFFFFFF
g.FillRectangle 0, 0, g.Width, g.Height

// now draw a few things
dim d as new DirectDrawGraphicsMBS(g)

call d.CreateSolidColorBrush(&cFF0000)
call d.CreateStrokeStyle 0, 0, 0, 0, 0, d.DashStyleDash

const size = 50
const offset = 10
const delta = offset + size

d.FillRectangle offset + delta * 0, offset + 0 * delta, offset + delta * 0 + size, offset + 0 * delta + size
d.DrawRectangle offset + delta * 0, offset + 1 * delta, offset + delta * 0 + size, offset + 1 * delta + size

d.FillEllipse offset + delta * 1 + size/2, offset + 0 * delta + size/2, size /2, size /2
d.DrawEllipse offset + delta * 1 + size/2, offset + 1 * delta + size/2, size /2, size /2

d.FillRoundedRectangle offset + delta * 2, offset + 0 * delta, offset + delta * 2 + size, offset + 0 * delta + size, 20, 20
d.DrawRoundedRectangle offset + delta * 2, offset + 1 * delta, offset + delta * 2 + size, offset + 1 * delta + size, 20, 20

// save to desktop
dim f as FolderItem = SpecialFolder.Desktop.Child("directdraw.jpg")
p.Save(f, Picture.Formats.JPEG, picture.QualityMaximum)

// show in window
window1.Backdrop = p

Feedback, Comments & Corrections

  • 13 properties
  • 17 methods
    • method ClearStrokeStyle
    • method Constructor(Graphics as Graphics)
    • method CreateSolidColorBrush(c as Color) as Boolean
    • method CreateSolidColorBrush(red as Single, green as Single, blue as Single, alpha as Single = 1.0) as Boolean
    • method CreateStrokeStyle(startCap as Integer = 0, endCap as Integer = 0, dashCap as Integer = 0, lineJoin as Integer = 0, miterLimit as Single = 1.0, dashStyle as Integer = 0, dashOffset as Single = 0, Dashes() as Single = nil) as Boolean
    • method Destructor
    • method DrawEllipse(x as single, y as single, radiusX as single, radiusY as single)
    • method DrawLine(x1 as single, y1 as single, x2 as single, y2 as single)
    • method DrawRectangle(left as single, top as single, right as single, bottom as single)
    • method DrawRoundedRectangle(left as single, top as single, right as single, bottom as single, radiusX as single, radiusY as single)
    • method FillEllipse(x as single, y as single, radiusX as single, radiusY as single)
    • method FillRectangle(left as single, top as single, right as single, bottom as single)
    • method FillRoundedRectangle(left as single, top as single, right as single, bottom as single, radiusX as single, radiusY as single)
    • method GetTransform(byref m11 as Single, byref m12 as Single, byref m21 as Single, byref m22 as Single, byref dx as Single, byref dy as Single)
    • method RestoreDrawingState
    • method SaveDrawingState
    • method SetTransform(m11 as Single, m12 as Single, m21 as Single, m22 as Single, dx as Single, dy as Single)
  • 20 constants

Anti Alias Modes

Constant Value Description
AntiAliasModeAliased 1 Objects are aliased in most cases. Objects are antialiased only when they are drawn to a render target created by the CreateDxgiSurfaceRenderTarget method and Direct3D multisampling has been enabled on the backing DirectX Graphics Infrastructure (DXGI) surface.
AntiAliasModePerPrimitive 0 Edges are antialiased using the Direct2D per-primitive method of high-quality antialiasing.

Cap Styles

Constant Value Description
CapStyleFlat 0 A cap that does not extend past the last point of the line. Comparable to cap used for objects other than lines.
CapStyleRound 0 A semicircle that has a diameter equal to the line thickness.
CapStyleSquare 0 Half of a square that has a length equal to the line thickness.
CapStyleTriangle 0 An isosceles right triangle whose hypotenuse is equal in length to the thickness of the line.

Dash Styles

Constant Value Description
DashStyleCustom 5 The dash pattern is specified by an array of floating-point values.
DashStyleDash 1 A dash followed by a gap of equal length. The dash and the gap are each twice as long as the stroke thickness. The equivalent dash array for D2D1_DASH_STYLE_DASH is {2, 2}.
DashStyleDashDot 3 A dash, followed by a gap, followed by a dot, followed by another gap. The equivalent dash array for D2D1_DASH_STYLE_DASH_DOT is {2, 2, 0, 2}.
DashStyleDashDotDot 4 A dash, followed by a gap, followed by a dot, followed by another gap, followed by another dot, followed by another gap. The equivalent dash array for D2D1_DASH_STYLE_DASH_DOT_DOT is {2, 2, 0, 2, 0, 2}.
DashStyleDot 2 A dot followed by a longer gap. The equivalent dash array for D2D1_DASH_STYLE_DOT is {0, 2}.
DashStyleSolid 0 A solid line with no breaks.

Line Join

Constant Value Description
LineJoinBevel 1 Beveled vertices.
LineJoinMiter 0 Regular angular vertices.
LineJoinMiterOrBevel 3 Regular angular vertices unless the join would extend beyond the miter limit; otherwise, beveled vertices.
LineJoinRound 2 Rounded vertices.

Text Anti Alias Modes

Constant Value Description
TextAntiAliasModeAliased 1 Do not use antialiasing.
TextAntiAliasModeClearType 1 Use ClearType antialiasing.
TextAntiAliasModeDefault 0 Use the system default. See Remarks.
TextAntiAliasModeGrayscale 1 Use grayscale antialiasing.

This class has no sub classes.

Blog Entries


The items on this page are in the following plugins: MBS Win Plugin.


DigestMBS   -   DirectorySizeMBS

The biggest plugin in space...




Links
MBS Xojo blog