Snippet Draw piano keys

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,282
This is code I made to draw pianokeys for a small music app in Cerberus-X:

Screenshot_20220124_055735.png


Cerberus:
Import mojo2

Function Main()
    New Game
    Return 0
End

Class Game Extends App

    Field canvas:Canvas
  
    Method OnCreate()
        canvas = New Canvas()
       Return 0
    End
 
 
    Method OnRender()
        canvas.Clear
        canvas.SetColor 1,1,1,1
        For Local xxxx:Int = 0 To 400 Step 20
            canvas.DrawRect xxxx,11*6+2,17,29
        Next
      
        canvas.SetColor 0,0,0
        Local temp:Int = 1
        For Local xxxx:Int = 0 To 400 Step 20 ' Draw 3 Octaves
            If temp = 1 Then canvas.DrawRect xxxx+12,68,12,16
            If temp = 2 Then canvas.DrawRect xxxx+12,68,12,16
            ' If temp = 3 Then canvas.DrawRect xxxx+12,68,12,16
            If temp = 4 Then canvas.DrawRect xxxx+12,68,12,16
            If temp = 5 Then canvas.DrawRect xxxx+12,68,12,16
            If temp = 6 Then canvas.DrawRect xxxx+12,68,12,16
            ' If temp = 7 Then canvas.DrawRect xxxx+12,68,12,16
            temp = temp + 1 ; If temp = 8 Then temp = 1
        Next
         canvas.SetColor 1,1,1

        canvas.Flush
    End
 
End
 
Top Bottom