
Figure 1
on mouseUp
choose line tool
-- To make the N:
drag from 150,50 to 150,200
drag from 150,50 to 200,200
drag from 200,200 to 200,50
-- To make the i:
drag from 225,75 to 225,200
-- To make the c:
drag from 250,75 to 300,75
drag from 250,75 to 250,200
drag from 250,200 to 300,200
-- To make the k:
drag from 325,50 to 325,200
drag from 325,82 to 375,60
drag from 340,76 to 375,200
end mouseUp
Figure 2
program name;
begin
{To make the m}
showdrawing;
drawline(50, 50, 50, 200);
drawline(50, 50, 75, 130);
drawline(75, 130, 100, 50);
drawline(100, 50, 100, 200);
{To make the i}
drawline(125, 50, 125, 75);
drawline(125, 100, 125, 200);
{To make the s}
drawline(200, 50, 150, 100);
drawline(150, 100, 200, 150);
drawline(200, 150, 150, 200);
{To make the t}
drawline(275, 50, 275, 200);
drawline(225, 100, 325, 100);
{To make the y}
drawline(350, 100, 400, 150);
drawline(420, 100, 365, 250);
end.

Figure 3
On mouseUp
choose rect tool
-- To make the N
drag from 50,50 to 75,200
drag from 75,50 to 100,100
drag from 100,100 to 125,150
drag from 125,150 to 150,200
drag from 150,200 to 175,50
-- To make the i
drag from 200,82 to 225,200
choose oval tool
drag from 200,50 to 225,75
choose rect tool
-- To make the c
drag from 275,75 to 325,100
drag from 275,75 to 250,200
drag from 275,200 to 325,175
-- To make the k
drag from 350,50 to 375,200
drag from 375,100 to 400,85
drag from 400,85 to 415,60
drag from 395,100 to 410,150
drag from 410,150 to 425,200
choose browse tool
end mouseUp
Figure 4
program name;
begin
{To make the M}
showdrawing;
framerect(50, 50, 200, 75);
drawline(75, 50, 100, 150);
drawline(100, 150, 125, 50);
framerect(50, 125, 200, 150);
{To make the I}
framerect(100, 175, 200, 200);
paintcircle(188, 62, 12);
{To make the s}
drawline(225, 50, 275, 50);
DRAWLINE(225, 50, 225, 125);
DRAWLINE(225, 125, 275, 125);
DRAWLINE(275, 125, 275, 200);
DRAWLINE(275, 200, 225, 200);
{To make the t}
FRAMERECT(50, 325, 200, 350);
FRAMERECT(100, 300, 125, 375);
{To make the y}
DRAWLINE(400, 100, 425, 200);
DRAWLINE(450, 100, 405, 300);
end.
Figure 5
-- A very simple house in HyperTalk
on mouseUp
choose rect tool
-- to build the **house**
drag from 100,100 to 300,200
-- to build the **door**
drag from 200,150 to 225,200
-- to build the **doorknob**
choose oval tool
drag from 205,175 to 210, 180 with shift key
choose rect tool
-- to build the **window**
drag from 125,125 to 140,140
-- to build the **window pane**
-- to build the **roof**
choose line tool
drag from 100,100 to 200,50
drag from 200,50 to 300,100
choose browse tool
end mouseUp
'A very simple house in Visual Basic
Dim intHouseLeft As Integer
Dim intHouseTop As Integer
Dim intHouseRight As Integer
Dim intHouseBottom As Integer
Private Sub DrawHouse_Click()
intHouseLeft = 100
intHouseTop = 150
intHouseRight = 300
intHouseBottom = 300
ScaleMode = 3 'Use Pixels for calculations
ForeColor = QBColor(2)
FillColor = QBColor(Int(Rnd * 15)) ' Choose random
FillColor.
'draw the house
Line (intHouseLeft, intHouseTop)-(intHouseRight,
intHouseBottom), , BF
DrawRoof
DrawDoor
End Sub
Private Sub DrawRoof()
Dim midpoint As Integer
midpoint = Round((intHouseLeft + intHouseRight) / 2)
'ScaleHeight is a built in property
Line (intHouseLeft, intHouseTop)-(midpoint, Round((ScaleHeight -
intHouseTop)
/ 2))
Line (intHouseRight, intHouseTop)-(midpoint, Round((ScaleHeight
- intHouseTop)
/ 2))
End Sub
Private Sub DrawDoor()
'Declare Local variables
Dim intDoorLeft As Integer
Dim intDoorTop As Integer
Dim intDoorRight As Integer
Dim intDoorBottom As Integer
Dim intDoorFrame As Integer
intDoorFrame = 5
'For the left edge of the door I divide by 5
'For the right edge of the door i divide by 2 to move it
farther
'to the right
intDoorLeft = Round((intHouseRight - intHouseLeft) / 5) +
intHouseLeft
intDoorTop = Round((intHouseBottom - intHouseTop) / 2) +
intHouseTop
intDoorRight = Round((intHouseRight - intHouseLeft) / 2) +
intHouseLeft
intDoorBottom = intHouseBottom
ForeColor = QBColor(12)
FillColor = QBColor(2)
'Draw the door
Line (intDoorLeft, intDoorTop)-(intDoorRight, intDoorBottom), ,
BF
'Draw the door frame
Line (intDoorLeft - intDoorFrame, intDoorTop -
intDoorFrame)-(intDoorRight
+ intDoorFrame, intDoorBottom), , B
'Draw the Door Knob
Circle (intDoorLeft + 10, intDoorBottom - Round((intDoorBottom -
intDoorTop)
/ 2)), 5, RGB(100, 100, 30)
End Sub
Figure 6
on mouseUp
choose rect tool
-- To build house
drag from 100,100 to 300,200
-- To build **door**
drag from 200,150 to 225,200
-- To build **doorknob**
choose oval tool
drag from 205,175 to 210, 180 with shift key
choose rect tool
-- To build **window**
drag from 125,125 to 140,140
-- To build **window pane**
-- To build **roof**
choose line tool
drag from 100,100 to 200,50
drag from 200,50 to 300,100
-- To build **grass**
grass
choose browse tool
end mouseUp
-- house, door, doorknob, window, window pane, roof,
and
-- grass are subroutines or procedures, if you prefer
to
-- think about it that way. They are called handlers
in
-- HyperTalk, an object-oriented language.
on grass
-- Make students do this the hard way first for
approximately
-- 20 blades of grass, one blade of grass at a time.
Ask what
is
-- changing (the variable) and what stays constant to
develop
the
-- concept of variable.
drag from 0,250 to 0,255
drag from 5,250 to 5,255
drag from 10,250 to 10,255
drag from 15,250 to 15,255
drag from 20,250 to 20,255
drag from 25,250 to 25,255
drag from 30,250 to 30,255
end grass
Figure 7
on grass
-- Make students do this the hard way first for
approximately
-- 20 blades of grass, one blade of grass at a time.
Ask what
is
-- changing (the variable) and what stays constant to
develop
the
-- concept of variable.
Put 0 into grass_hor_location
Repeat until grass_hor_location >500
Drag from grass_hor_location 250 to grass_hor_location
255
Add five to grass_hor_location
end repeat
end grass
Figure 8
on grass
-- Now do grass the easy way
Put 0 into grass_hor_location
Put 250 into grass_vert_location
Put 5 into grassheight
Put 5 into grassspace
-- I originally used =500 and got an infinite loop;
why?
repeat until grass_vert_location >340
repeat until grass_hor_location >500
drag from grass_hor_location, grass_vert_location to
grass_hor_location,¬
grass_vert_location+grassheight
add grassspace to grass_hor_location
end repeat
-- Important initializations students are likely to
miss:
add 4 to grassspace
add 10 to grass_vert_location
put 0 into grass_hor_location
end repeat
-- Then consider changing the grass height.
end grass
Figure 9
on mouseUp
global height,bottom,width
-- clear the old picture
choose select tool
domenu "Select All"
domenu "Clear Picture"
-- Input the location and size of the house:
ask "Input the location of the left edge of the
house"
put it into left
ask "Input the location of the top edge of the
house"
put it into top
ask "Input the width of the house"
put it into width
ask "Input the height of the house"
put it into height
-- Make the program easier to read:
put left+width into right
put height+top into bottom
choose rect tool
-- **house**
drag from left,top to right,bottom
put left +width into right
put height+top into bottom
-- **roof**
choose line tool
drag from left,top to (left + right) div 2,top-width
div 3
drag from (left +right) div 2,top-width div 3 to
right,top
-- **door**
choose rectangle tool
drag from (width div 5)+left ,height div 3 +top to
width div
2 +left, bottom
-- **doorknob**
choose oval tool
drag from round(width/4)+left,round(height/1.8)+top to
round(width/3.7)+left,¬
round(height/1.5) +top with shiftkey
choose rect tool
-- **window**
drag from right-width div 6,height div 5+top to
right-round(width/4),round(height/2.4)+top
-- **window pane**
-- Call separate handlers to draw the grass and the
fence.
grass
fence
choose browse tool
end mouseUp
Figure 10
on fence
global height,bottom,width
put 0 into fence_left
choose line tool
put bottom+height div 12 into fence_top
put bottom+round(height/2.2) into fence_bottom
put width div 20 into fence_width
repeat until fence_left >500
-- left edge of fence
drag from fence_left, fence_bottom to
fence_left,fence_top
-- top left slant of fence, the angle is at 45
degrees
drag from fence_left,fence_top to
fence_left+fence_width div
2,¬
fence_top-fence_width div 2
-- right slant of fence
drag from fence_left+fence_width div
2,fence_top-fence_width
div 2 to¬
fence_left+fence_width, fence_top
-- right side of fence
drag from fence_left+fence_width, fence_top to
fence_left+fence_width,
fence_bottom
add round(1.5*fence_width) to fence_left
end repeat
end fence
Back to "Old
Computer Tricks Enhance Algebraic Thinking"
Copyright © 2000, ISTE (International Society for Technology
in Education).
All rights reserved.
|