User Tools

Site Tools


ivbasic:sampleapplication:flashcards:library

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ivbasic:sampleapplication:flashcards:library [2013/01/24 04:15]
Wayne Michael created
ivbasic:sampleapplication:flashcards:library [2024/02/16 01:11] (current)
Line 1: Line 1:
 +<code thinbasic>
 +fn randomcolor[]
 +dim l[4]
 +for a = 0 to 3
 +precision[0]
 +r= random[255]
 +precision[2]
 +l[a] =  (r / 255)
  
 +next a
 +
 +randomcolor = (r / 255)
 +
 +endfn
 +
 +
 +cmd square[]
 +Dim global color[4]
 +Dim global widthHeight[2]
 +Dim rectStart[2]
 + 
 +color[0]=randomcolor[] ' red
 +color[1]= randomcolor[]
 +color[2]=randomcolor[]
 +color[3]=1.0  ' alpha
 + 
 +rectStart[0]= 10 ' x
 +rectStart[1]= 10 ' y
 + 
 +' if width and height are the same is a circle
 +widthHeight[0] = 400 ' width
 +widthHeight[1] = 400 ' height
 + 
 +SetLineWidth[5]
 + 
 +fillRect[color,rectStart,widthHeight]
 +
 +enablecontrol["timer0"]
 +say["square"]
 +x= mytextdraw["square"]
 +
 +endcmd
 +
 +cmd rectangle[]
 +Dim global color[4]
 +Dim global widthHeight[2]
 +Dim rectStart[2]
 + 
 +color[0]=randomcolor[] ' red
 +color[1]= randomcolor[]
 +color[2]=randomcolor[]
 +color[3]=1.0  ' alpha
 + 
 +rectStart[0]= 10 ' x
 +rectStart[1]= 10 ' y
 + 
 +' if width and height are the same is a circle
 +widthHeight[0] = 250 ' width
 +widthHeight[1] = 400 ' height
 + 
 +SetLineWidth[5]
 + 
 +fillRect[color,rectStart,widthHeight]
 +
 +enablecontrol["timer0"]
 +say["Rectangle"]
 +x= mytextdraw["Rectangle"]
 +
 +endcmd
 +
 +cmd oval[]
 +Dim global color[4]
 +Dim global widthHeight[2]
 +Dim rectStart[2]
 + 
 +color[0]=randomcolor[] ' red
 +color[1]= randomcolor[]
 +color[2]=randomcolor[]
 +color[3]=.50  ' alpha
 + 
 + 
 +rectStart[0]= 10 ' x
 +rectStart[1]= 10 ' y
 + 
 +' if width and height are the same is a circle
 +widthHeight[0] = 300 ' width
 +widthHeight[1] = 400 ' height
 + 
 +SetLineWidth[5]
 + 
 +filloval[color,rectStart,widthHeight]
 +
 +enablecontrol["timer0"]
 +say["oval"]
 +xv= mytextdraw["Oval"]
 +endcmd
 +
 +
 +fn mytextdraw[n]
 +Dim  color[4]
 +Dim  TextFontAndSize[3]
 +Dim rectStart[2]
 + 
 +color[0]=randomcolor[] ' red
 +color[1]= randomcolor[]
 +color[2]=randomcolor[]
 +color[3]=1.0  ' alpha
 + 
 + 
 +rectStart[0]= 300 ' x
 +rectStart[1]= 500 ' y
 + 
 +' if width and height are the same is a circle
 +TextFontAndSize[0] = n
 +TextFontAndSize[1] = "Courier" ' Font Name
 +TextFontAndSize[2] = 20  ' Font Size
 + 
 + 
 +DrawText[color,rectStart,TextFontAndSize]
 +
 +endfn
 +
 +cmd circlel[]
 +Dim global color[4]
 +Dim global widthHeight[2]
 +Dim rectStart[2]
 + 
 +color[0]=randomcolor[] ' red
 +color[1]= randomcolor[]
 +color[2]=randomcolor[]
 +color[3]=1.0  ' alpha
 + 
 + 
 +rectStart[0]= 10 ' x
 +rectStart[1]= 10 ' y
 + 
 +' if width and height are the same is a circle
 +widthHeight[0] = 400 ' width
 +widthHeight[1] = 400 ' height
 + 
 +SetLineWidth[5]
 + 
 +filloval[color,rectStart,widthHeight]
 +
 +enablecontrol["timer0"]
 +say["Circle"]
 +x= mytextdraw["Circle"]
 +endcmd
 +
 +cmd mynext[]
 +again:
 +m = Random[4]
 +if m = lastm then
 +goto again
 +endif
 +lastm = m
 +
 +EraseScreen[]
 +'t = mytextdraw[m]
 +if m= 0 then
 +rectangle[]
 +endif
 +
 +if m= 1 then
 +square[]
 +endif
 +
 +if m=2 then
 +circlel[]
 +endif
 +if m=3 then
 +oval[]
 +endif
 +
 +if m=4 then
 + triangle[]
 +endif
 +endcmd
 +
 +
 +cmd triangle[]
 +Dim rectStart[2]
 +Dim color[4]
 + 
 +color[0]=randomcolor[] ' red
 +color[1]= randomcolor[]
 +color[2]=randomcolor[]
 +color[3]= 1.0 ' alpha
 + 
 + 
 +rectStart[0]= 0 ' x
 +rectStart[1]= 0 ' y
 + 
 +Dim points[12]
 + 
 +points[0]=300 ' x
 +points[1]=10 ' y
 + 
 +points[2]=150 ' x
 +points[3]=300 ' y
 + 
 +points[4]=450 ' x
 +points[5]=300 ' y
 + 
 +points[6]=300 ' x
 +points[7]=10 ' y
 + 
 + 
 +SetLineWidth[1]
 + 
 +FillPoly[color,points]
 + 
 +enablecontrol["timer0"]
 +say["Triangle"]
 +x= mytextdraw["Triangle"]
 +
 +endcmd
 +</code>

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
ivbasic/sampleapplication/flashcards/library.txt · Last modified: 2024/02/16 01:11 (external edit)

Impressum Datenschutz