$INCLUDE "rapidq.inc"
$TYPECHECK ON
DIM N$ AS STRING
DIM n AS SINGLE
DIM Fname$ AS STRING
DIM x1 AS SINGLE
DIM y1 AS SINGLE
DIM x2 AS SINGLE
DIM y2 AS SINGLE
DIM x3 AS SINGLE
DIM y3 AS SINGLE
DIM angle AS SINGLE
DIM theta AS SINGLE
DIM s1 AS SINGLE
s1 = 1
DIM skew AS SINGLE
skew = 0
DIM tilt AS SINGLE
tilt = 0
DIM Rad AS SINGLE
Rad = 3.1415927/180
DIM w1 AS SINGLE
w1 = 100
DIM h1 AS SINGLE
h1 = 200
DIM w2 AS SINGLE
w2 = 200
DIM h2 AS SINGLE
h2 = 100
DIM FN AS SINGLE
FN = 0
DIM Hue AS SINGLE
Hue = &H2FDCE0
DIM BmpCol AS SINGLE
BmpCol = &H4D764B
DIM TextCol AS SINGLE
TextCol = &H0000FF
DIM FormCol AS SINGLE
FormCol = &HC0C0C0
DIM CanvCol AS SINGLE
CanvCol = &H4D764B
DECLARE SUB paint
DECLARE SUB ButtonClick (Sender AS QBUTTON)
DIM font AS QFONT
DIM bump AS QBITMAP
DIM form AS QFORM
DIM canvas AS QCANVAS
DIM label1 AS QLABEL
DIM label2 AS QLABEL
DIM label3 AS QLABEL
DIM label4 AS QLABEL
DIM label5 AS QLABEL
DIM label6 AS QLABEL
DIM label7 AS QLABEL
DIM label8 AS QLABEL
DIM label9 AS QLABEL
DIM labelA AS QLABEL
DIM StartB AS QBUTTON
DIM StopB AS QBUTTON
DIM EndB AS QBUTTON
DIM Input1 AS QEDIT
DIM Input2 AS QEDIT
DIM Input3 AS QEDIT
DIM Input4 AS QEDIT
DIM Input5 AS QEDIT
DIM Input6 AS QEDIT
DIM Input7 AS QEDIT
bump.width = 400
bump.height = 400
bump.fillrect(0,0,400,400,BmpCol)
form.CAPTION = "Ellipse"
form.clientheight = 500
form.clientwidth = 600
form.COLOR = FormCol
form.center
canvas.PARENT = form
canvas.width = 400
canvas.height = 400
canvas.top = 50
canvas.left = 50
canvas.COLOR = CanvCol
canvas.onpaint = paint
label1.PARENT = form
label1.CAPTION = " Computer Generated Graphics"
label1.Top = 5
label1.Left = 50
label1.Width = 400
label1.Height = 15
label1.Transparent = 0
label1.hint = "label 1 hint"
label2.PARENT = form
label2.CAPTION = "Provide the ellipses width, height, skew and resolution"
label2.Top = 20
label2.Left = 50
label2.Width = 400
label2.Height = 15
label2.Transparent = 0
label3.PARENT = form
label3.CAPTION = " ellipse one and two"
label3.Top = 25
label3.Left = 450
label3.Width = 130
label3.Height = 15
label3.Transparent = 0
label4.PARENT = form
label4.CAPTION = " __width____height__"
label4.Top = 43
label4.Left = 450
label4.Width = 130
label4.Height = 15
label4.Transparent = 0
label5.PARENT = form
label5.CAPTION = " _Skew__"
label5.Top = 135
label5.Left = 450
label5.Width = 130
label5.Height = 15
label5.Transparent = 0
label6.PARENT = form
label6.CAPTION = " Resolution"
label6.Top = 165
label6.Left = 450
label6.Width = 130
label6.Height = 15
label6.Transparent = 0
label7.PARENT = form
label7.CAPTION = " _Tilt____"
label7.Top = 195
label7.Left = 450
label7.Width = 130
label7.Height = 15
label7.Transparent = 0
label8.PARENT = form
label8.CAPTION = " draw new selections"
label8.Top = 285
label8.Left = 450
label8.Width = 130
label8.Height = 15
label8.Transparent = 0
label9.PARENT = form
label9.CAPTION = " save picture"
label9.Top = 345
label9.Left = 450
label9.Width = 130
label9.Height = 15
label9.Transparent = 0
labelA.PARENT = form
labelA.CAPTION = " exits program"
labelA.Top = 405
labelA.Left = 450
labelA.Width = 130
labelA.Height = 15
labelA.Transparent = 0
input1.PARENT = form
input1.Hint = "#1 width -200 to +200 pixels"
input1.Top = 60
input1.Left = 460
input1.Width = 50
input1.ShowHint = 1
input1.text = STR$(w1)
input2.PARENT = form
input2.Hint = "#1 height -200 to +200 pixels"
input2.Top = 60
input2.Left = 520
input2.Width = 50
input2.ShowHint = 1
input2.text = STR$(h1)
input3.PARENT = form
input3.Hint = "#2 width -200 to +200 pixels"
input3.Top = 90
input3.Left = 460
input3.Width = 50
input3.ShowHint = 1
input3.text = STR$(w2)
input4.PARENT = form
input4.Hint = "#2 height -200 to +200 pixels"
input4.Top = 90
input4.Left = 520
input4.Width = 50
input4.ShowHint = 1
input4.text = STR$(h2)
input5.PARENT = form
input5.Hint = "skew angle -180 to +180 degrees"
input5.Top = 125
input5.Left = 520
input5.Width = 50
input5.ShowHint = 1
input5.text = STR$(skew)
input6.PARENT = form
input6.Hint = "1 or greater degrees"
input6.Top = 155
input6.Left = 520
input6.Width = 50
input6.ShowHint = 1
input6.text = STR$(s1)
input7.PARENT = form
input7.Hint = "within 0 to 360 degrees"
input7.Top = 185
input7.Left = 520
input7.Width = 50
input7.ShowHint = 1
input7.text = STR$(tilt)
startB.PARENT = form
startB.CAPTION = "Draw"
startB.OnClick = ButtonClick
startB.Hint = "re-draws new settings"
startB.ShowHint = 1
startB.Left = 480
startB.Top = 305
stopb.PARENT = form
stopB.CAPTION = "Save"
stopB.OnClick = ButtonClick
stopB.Hint = "send bmp file to desktop"
stopB.ShowHint = 1
stopB.Left = 480
stopB.Top = 365
stopB.TabOrder = 1
EndB.PARENT = form
EndB.CAPTION = "Exit"
EndB.OnClick = ButtonClick
EndB.Hint = "gracefully exits the program"
EndB.ShowHint = 1
EndB.Left = 480
EndB.Top = 425
N = 10
N$= "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "The right margin contains Edit boxes and Event Buttons "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= " "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "Edit Boxes <or status boxes>"
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "The Edit boxes contain the current values for the Draw event "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "..Change a value by placing the mouse over the value "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "....A hint will show the value expected. Click it to select it "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "....Use the keyboard number keys to select new value "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= " "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "Event Buttons "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "..A mouse click will execute the event "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "....DRAW displays a picture for the selected values "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "....SAVE creates a Bump.bmp file on the desktop "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "....EXIT closes this program gracefully with elegant couth "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= " "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "Points for two elipses are plotted on a 400x400 pixel field "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "From 0 to 360 degrees, the point for each ellipse is drawn in "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "turn for each angle and a line drawn between each set of points "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= " "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "To see this clearly, make the width and height the same for both "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "ellipses. The line between them will be of zero length... "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "..Skew: degrees shifted between each set of plots "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "..Resolution: degrees between successive sets of plots "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "..Tilt: degrees the second elipse is rotated "
bump.textout (10,N,N$,TextCol,0): n=n+15
N$= "______________________________________________________"
bump.textout (10,N,N$,TextCol,0)
form.SHOWMODAL
SHOWMESSAGE("The program will close;however, less couthfully than with EXIT")
END
SUB paint
canvas.draw(0,0,bump.bmp)
END SUB
SUB ButtonClick (Sender AS QBUTTON)
SELECT CASE Sender.CAPTION
CASE "Save"
FN = FN + 1
fname$ = "Bump" + STR$(FN) + ".bmp"
bump.SaveToFile ("c:\windows\desktop\" + fname$)
CASE "Exit"
END
END SELECT
n$ = input1.text: n = VAL(n$)
IF n>-201 AND n<201 THEN w1=n:input1.text=STR$(w1) ELSE input1.text="error"
n$ = input2.text: n = VAL(n$)
IF n>-201 AND n<201 THEN h1=n:input2.text=STR$(h1) ELSE input2.text="error"
n$ = input3.text: n = VAL(n$)
IF n>-201 AND n<201 THEN w2=n:input3.text=STR$(w2) ELSE input3.text="error"
n$ = input4.text: n = VAL(n$)
IF n>-201 AND n<201 THEN h2=n:input4.text=STR$(h2) ELSE input4.text="error"
n$ = input5.text: n = VAL(n$)
IF ABS(n)> 180 THEN input5.text="error" ELSE skew= n: input5.text= STR$(skew)
n$ = input6.text: n = VAL(n$)
IF n< 1 THEN input6.text= "error" ELSE s1=n: input6.text= STR$(s1)
n$ = input7.text: n = VAL(n$): tilt=n: input7.text= STR$(tilt)
bump.fillrect(0,0,400,400,BmpCol)
FOR angle = 0 TO 360 STEP s1
Theta = angle + skew
x1 = COS(angle * rad) * w1
y1 = SIN(angle * rad) * h1
bump.pset(200 + x1, 200 - y1, hue)
x2 = COS(theta * rad) * w2
y2 = SIN(theta * rad) * h2
x3 = x2 * COS(tilt * rad) + y2 * SIN(tilt * rad)
y3 = y2 * COS(tilt * rad) - x2 * SIN(tilt * rad)
bump.line(200 + x1, 200 + y1, 200 + x3, 200 + y3, hue)
NEXT angle
canvas.repaint
END SUB
|
|