Renderer Property

Renderer Property

Gets or sets the InkRenderer object that is used to draw ink.

Declaration

[C++]

[propputref] HRESULT putref_Renderer ([in] IInkRenderer* Renderer);
[propget] HRESULT get_Renderer ([out, retval] IInkRenderer** Renderer);

[Microsoft® Visual Basic® 6.0]

Public Property Get Renderer() As InkRenderer
Public Property Set Renderer(ByRef theRenderer As InkRenderer)

Property Value

InkRenderer The InkRenderer object that is used to draw ink.

This property is read/write.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER The Renderer parameter is not a valid pointer.
E_INK_EXCEPTION An exception occurred while processing.
E_INK_INVALID_MODE The ink collector must be in single-tablet mode.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates displaying several kinds of information that is recorded with each IInkStrokeDisp object. The calling program uses menu items to toggle the display of each strokes points, Bezier points, Bezier cusps, and self-intersections. Add the five menu items to the main window form: MenuDemoCusps, MenuDemoPoints, MenuDemoAllPoints, MenuDemoSelfIntersections, MenuFileExit.

The InkRenderer object's InkSpaceToPixelFromPoints method is used to convert the points for display. The helper function LocatePoint is used to interpolate the locations of the self-intersections.

[Visual Basic]
Option Explicit
Option Base 0
Dim WithEvents theInkCollector As InkCollector

Private Sub Form_Load()
    Me.ScaleMode = vbPixels
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
End Sub

Private Sub Form_Paint()
    Dim i As Integer
    Dim theStrokes As InkStrokes
    Set theStrokes = theInkCollector.Ink.Strokes
    Dim theStroke As IInkStrokeDisp
    For Each theStroke In theStrokes
        Dim ptBezierPoints() As Long
        ptBezierPoints = theStroke.BezierPoints
        Dim ptStrokePoints() As Long
        ptStrokePoints = theStroke.GetPoints()
        theInkCollector.Renderer.InkSpaceToPixelFromPoints Me.hDC, ptBezierPoints
        theInkCollector.Renderer.InkSpaceToPixelFromPoints Me.hDC, ptStrokePoints
        If MenuDemoCusps.Checked Then
            Dim theCusps() As Long
            theCusps = theStroke.BezierCusps
            For i = 0 To UBound(theCusps)
                'Draw a little rectangle around each Bezier cusp.
                Dim cuspX As Long
                Dim cuspY As Long
                cuspX = ptBezierPoints(theCusps(i) * 2)
                cuspY = ptBezierPoints(theCusps(i) * 2 + 1)
                Line (cuspX - 2, cuspY - 2)-Step(5, 5), vbRed, B
            Next
        End If
        If MenuDemoPoints.Checked Then
            For i = 0 To UBound(ptBezierPoints) Step 2
                'Draw a little diagonal line up from each Bezier point.
                Line (ptBezierPoints(i), ptBezierPoints(i + 1)) _
                    -Step(4, -4), vbBlue
            Next
        End If
        If MenuDemoAllPoints.Checked Then
            For i = 0 To UBound(ptStrokePoints) Step 2
                'Draw a little diagonal line down from each point.
                Line (ptStrokePoints(i), ptStrokePoints(i + 1)) _
                    -Step(-4, 5), vbMagenta
            Next
        End If
        If MenuDemoSelfIntersections.Checked Then
            Dim theSelfIntersectionLocationsArray() As Single
            theSelfIntersectionLocationsArray = theStroke.SelfIntersections
            Dim theSelfIntersectionLocation As Variant
            For Each theSelfIntersectionLocation In theSelfIntersectionLocationsArray
                Dim pt() As Long
                pt = LocatePoint(theStroke, theSelfIntersectionLocation)
                theInkCollector.Renderer.InkSpaceToPixel Me.hDC, pt(0), pt(1)
                'Draw a little circle around each intersection.
                Circle (pt(0), pt(1)), 7, vbRed
            Next
        End If
    Next
End Sub

Private Sub MenuDemoAllPoints_Click()
    MenuDemoAllPoints.Checked = Not MenuDemoAllPoints.Checked
End Sub

Private Sub MenuDemoCusps_Click()
    MenuDemoCusps.Checked = Not MenuDemoCusps.Checked
End Sub

Private Sub MenuDemoPoints_Click()
    MenuDemoPoints.Checked = Not MenuDemoPoints.Checked
End Sub

Private Sub MenuDemoSelfIntersections_Click()
    MenuDemoSelfIntersections.Checked = _
        Not MenuDemoSelfIntersections.Checked
End Sub

Private Sub MenuFileExit_Click()
    Unload Me
End Sub

'This function returns the approximate point along
'a stroke represented by a Single, as a Point.
Private Function LocatePoint( _
ByVal theStroke As IInkStrokeDisp, _
ByVal theFIndex As Single) As Long()
    Dim theResult(1) As Long
    'Get the two nearest points to the point of interest.
    Dim ptStrokePoints() As Long
    ptStrokePoints = theStroke.GetPoints(Int(theFIndex), 2)
    If UBound(ptStrokePoints) < 2 Then
        'This must be an end point.
        theResult(0) = ptStrokePoints(0)
        theResult(1) = ptStrokePoints(1)
    Else
        'Get fractional part to interpolate the distance
        'between the points.
        Dim theFraction As Single
        theFraction = theFIndex - Int(theFIndex)
        Dim deltaX As Integer
        deltaX = _
            CInt((ptStrokePoints(2) - ptStrokePoints(0)) * theFraction)
        Dim deltaY As Integer
        deltaY = _
            CInt((ptStrokePoints(3) - ptStrokePoints(1)) * theFraction)
        'Return the interpolated point.
        theResult(0) = ptStrokePoints(0) + deltaX
        theResult(1) = ptStrokePoints(1) + deltaY
    End If
    LocatePoint = theResult
End Function

Private Sub theInkCollector_Stroke( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Stroke As MSINKAUTLib.IInkStrokeDisp, _
Cancel As Boolean)
    Refresh
End Sub

Applies To