First, I'm setting the printer's scale and the X,Y position of the output:
Expand|Select|Wrap|Line Numbers
- Sub SetLargePrinterScale(obj As Object, VertPosition As Single)
- Dim Owid As Single
- Dim Ohgt As Single
- Dim Pwid As Single
- Dim Phgt As Single
- Dim Xmid As Single
- Dim Ymid As Single
- Dim S As Single
- Dim ScaleFactor As Single
- ScaleFactor = (50 - frmPrint.Slider3.Value) / 10
- Owid = obj.ScaleX(obj.ScaleWidth, obj.ScaleMode, vbPixels)
- Ohgt = obj.ScaleY(obj.ScaleHeight, obj.ScaleMode, vbPixels)
- Pwid = Printer.ScaleX(Printer.ScaleWidth, Printer.ScaleMode, vbPixels)
- Phgt = Printer.ScaleY(Printer.ScaleHeight, Printer.ScaleMode, vbPixels)
- ' This determines which dimension (X or Y) is largest, so I can make sure neither
- ' dimension exceeds the printer width
- If Ohgt / Owid > Phgt / Pwid Then
- S = Phgt / Ohgt
- Else
- S = Pwid / Owid
- End If
- Pwid = obj.ScaleX(Pwid * ScaleFactor, vbPixels, obj.ScaleMode) / S
- Phgt = obj.ScaleY(Phgt * ScaleFactor, vbPixels, obj.ScaleMode) / S
- ' This sets the vertical and horizontal coordinates of the center of the image
- ' Using the settings below, the image is printed in the center of the page
- Xmid = (obj.ScaleLeft + obj.ScaleWidth / 2) * ScaleFactor
- Ymid = (obj.ScaleTop + obj.ScaleHeight / 1.6) * ScaleFactor
- Printer.Scale (Xmid - Pwid / 2, Ymid - Phgt / 2)-(Xmid + Pwid / 2, Ymid + Phgt / 2)
- End Sub
Then I print a spyrograph-style pattern:
Expand|Select|Wrap|Line Numbers
- Sub PrintRoullette()
- Dim pi, r, R1, R2, i
- For i = 0 To UBound(prtR1) - 1
- R1 = prtR1(i)
- R2 = prtR2(i)
- r = prtR(i)
- pi = 4 * Atn(1)
- 't represents time, X & Y are the coordinates of each point drawn
- Dim Loop1, Loop2
- Dim t, X, Y As Double
- Dim Rotations As Integer
- If Int(R1 / R2) = R1 / R2 Then
- Rotations = 1
- Else
- Rotations = Abs(R2 / 10)
- If Int(R2 / 10) <> R2 / 10 Then Rotations = 10 * Rotations
- End If
- Rotations = Rotations + 1
- For Loop1 = 1 To Rotations
- For Loop2 = 0 To 2 * pi Step pi / (4 * 360)
- t = Loop1 * 2 * pi + Loop2
- X = (R1 + R2) * Cos(t) - (R2 + r) * Cos(((R1 + R2) / R2) * t)
- Y = (R1 + R2) * Sin(t) - (R2 + r) * Sin(((R1 + R2) / R2) * t)
- Printer.PSet (Printer.ScaleWidth / 2 + X, Printer.ScaleHeight _
- / 2 + Y), prtPen(i)
- Next
- DoEvents
- Next
- Next
- End Sub
I've tried adding pixels to the Printer.Scale statement in the SetLargePrinterScale sub:
Expand|Select|Wrap|Line Numbers
- Printer.Scale (Xmid - (Pwid / 2) + 300, Ymid - (Phgt / 2) + 300)-(Xmid + (Pwid / 2) + 300, Ymid + (Phgt / 2) + 300)
joe