PrintMatrix
Posted: Sunday 2nd July 2023 8:23pm
Hey folks, I'm making some gauges to track realtime data in my program, I place an SVG image down, then overlay it with a DrawingArea. By drawing the pointer on this layer, I have a really nice looking gauge. To draw a basic point I would do something like this...
That's fine and all... but then to rotate it, I'm doing some fancy sine/cosine math for every point. I can do that... but I know it is not the most efficient code to use.
A better way would be to consider the rotational pivot point to be (0,0) for the object, then determine the coordinates of the pointer and define it as some kind of shape... drop the shape where I want it and at the desired rotation.
I see the PrintMatrix and I'm wondering if that would work... but I cannot seem to figure it out. Can someone help me?
Assumptions:
Thanks,
Jerry
Code: Select all
Public Sub DRW_1_Draw()
Dim x, y As Integer
x = DRW_1.Width / 2
y = DRW_1.Height / 2
With Paint
' Draw Filled Center
.brush = Paint.Color(&hffff00)
.MoveTo(x, y - 90)
.LineTo(x - 20, y + 10)
.LineTo(x, y + 40)
.LineTo(x + 20, y + 10)
.LineTo(x, y - 90)
.fill
' Draw Outlin
.brush = Paint.Color(&h0000FF)
.MoveTo(x, y - 90)
.LineTo(x - 20, y + 10)
.LineTo(x, y + 40)
.LineTo(x + 20, y + 10)
.LineTo(x, y - 90)
.stroke
' Finish Drawing
.End
End With
End
A better way would be to consider the rotational pivot point to be (0,0) for the object, then determine the coordinates of the pointer and define it as some kind of shape... drop the shape where I want it and at the desired rotation.
I see the PrintMatrix and I'm wondering if that would work... but I cannot seem to figure it out. Can someone help me?
Assumptions:
- The Drawing Area is named DRW_1
- The center of rotation will be (DRW_1.Width/2 [, DRW_1.Height/2)
- For now Slider_1 will be set from -360 to +360 and will be applied as the rotational angle.
- If angle is specified as degrees, it will be Slider_1.value
- If angle is specified a radians, it will be RAD(Slider_1.value)
Thanks,
Jerry