Method |
Type |
Description |
Params |
Support |
|
|
|
|
|
Circle |
SUB (x1%, y1%, x2%, y2%, c%, fill%) |
Draw & Fill Circle |
6 |
WXG |
CopyRect |
SUB (D, Image, S) |
D and S are QRECTs, Image can be a QImage, QCanvas, or QBitmap |
3 |
W |
|
Example (copies QIMAGE to canvas at 10,10):
DIM Destination AS QRECT
DIM Source AS QRECT
DIM Image AS QIMAGE
Image.BMP = "whatever.bmp"
SUB CanvasPaint (Sender AS QCANVAS)
WITH Destination
.Top = 10
.Left = 10
.Right = .Left+Image.Width
.Bottom = .Top+Image.Height
END WITH
WITH Source
.Top = 0
.Left = 0
.Right = Image.Width
.Bottom = Image.Height
END WITH
Sender.CopyRect(Destination, Image, Source)
END SUB
DIM Canvas AS QCANVAS
Canvas.OnPaint = CanvasPaint
|
Draw |
SUB (x%, y%, BMP) |
Draw Bitmap on Canvas |
3 |
WG |
|
Details:
BMP can be any BMP property from QBitmap, QImage, QImageList, etc. any component with a BMP property is fine.
Examples:
DIM Image1 AS QIMAGE
Image1.BMP = "whatever.bmp"
DIM Image2 AS QBITMAP
Image2.BMP = "whatever.bmp"
SUB CanvasPaint (Sender AS QCANVAS)
Sender.Draw(0, 0, Image1.BMP)
Sender.Draw(50, 50, Image2.BMP)
END SUB
DIM Canvas AS QCANVAS
Canvas.OnPaint = CanvasPaint
|
FillRect |
SUB (x1%, y1%, x2%, y2%, c%) |
Draws & Fills a rectangle |
5 |
WXG |
Line |
SUB (x1%, y1%, x2%, y2%, c%) |
Draws a line |
5 |
WXG |
Paint |
SUB (x%, y%, c%, borderc%) |
Fill Region |
4 |
WXG |
Pset |
SUB (x%, y%, c%) |
Pixel plot |
3 |
WXG |
Rectangle |
SUB (x1%, y1%, x2%, y2%, c%) |
Draws a rectangle |
5 |
WXG |
Repaint |
SUB |
Force repainting |
0 |
W |
Rotate |
SUB (xOrigin%, yOrigin%, Angle%) |
Rotates entire canvas at specified origin |
3 |
W |
RoundRect |
SUB (x1%, y1%, x2%, y2%, x3%, y3%, c%) |
Draws & Fills a rounded rectangle |
7 |
W |
StretchDraw |
SUB (Rect AS QRECT, BMP) |
Draw image and stretch to fit inside Rect |
2 |
W |
TextHeight |
FUNCTION (Text$) AS WORD |
Returns the height, in pixels, of Text$ string |
1 |
W |
TextWidth |
FUNCTION (Text$) AS WORD |
Returns the width, in pixels, of Text$ string |
1 |
W |
TextRect |
SUB (Rect AS QRECT, x%, y%, S$, fc%, bc%) |
Write text, and clip within region Rect |
6 |
W |
TextOut |
SUB (x%, y%, S$, fc%, bc%) |
Writes text to image |
5 |
WXG |
QCanvas Examples
' Pixel by pixel credit scroller for Rapid-Q by William Yu
DIM Canvas AS QCanvas
DIM Form AS QForm
DIM Timer1 AS QTimer
DIM Font AS QFont
DIM Y AS INTEGER
Y = -20
SUB Resize
Canvas.Height = Form.ClientHeight
Canvas.Width = Form.ClientWidth
END SUB
SUB Paint
Canvas.Textout (65,Y-30,"Beware the power of Rapid-Q!", &H00FF00, 0)
Canvas.Textout (30,Y,"Credit Scroller written in Rapid-Q by William Yu", &HFFFFFF, 0)
END SUB
SUB TimerOver
Timer1.Interval = 1 '' Can't go any lower!
Y = Y + 1 '' Pixel by pixel!
Paint
END SUB
Form.Width = 400
Form.Height = 200
Form.Center
Form.Color = 0
Font.Name = "Arial"
Font.Size = 12
Font.Color = &H00FF00
Canvas.Parent = Form
Canvas.Font = Font
Canvas.Color = 0
Canvas.OnPaint = Paint
Timer1.Interval = 1
Timer1.OnTimer = TimerOver
Form.Onresize = Resize
Form.ShowModal
Prev ComponentContentsNext Component