B4A Library ABExtDrawing 1.0

Discussion in 'Additional libraries, classes and official updates' started by alwaysbusy, Feb 3, 2012.

  1. victormedranop

    victormedranop Well-Known Member Licensed User

    I'm trying to rotate an image but no luck.

    Code:
    Sub [B]Process_Globals[/B]
    Dim ExDraw As ABExtDrawing
    End Sub
    Sub [B]Globals[/B]
    Dim MyCanvas As Canvas
    Dim Panel1 As Panel
    End Sub
    Sub [B]Activity_Create[/B](FirstTime As Boolean)
    Activity.LoadLayout("1")
    Panel1.Initialize(
    "Panel1")
    Panel1.Width = 
    20dip
    Panel1.Height = 
    20dip
    Dim m As ABMatrix
    m.Initialize
    m.postRotate(
    45)
    m.postTranslate(
    10dip,10dip)
    Dim b As Bitmap
    Dim pnt As ABPaint
    MyCanvas.Initialize(Panel1)
    b.Initialize(
    File.DirAssets,"1488957559_swipe_left.png")
    ExDraw.drawBitmap4(MyCanvas,b,m,pnt)
    End Sub
    [\code]
     
  2. DonManfred

    DonManfred Expert Licensed User

    You did not added the Panel to the activity.
    If the Panel is inside the loaded layout then you should not initialize the panel.
    Did you get any error? WHICH???
     
  3. almontgreen

    almontgreen Active Member Licensed User

  4. themr23

    themr23 Member Licensed User

    I just took a look at this work, and made a few changes. This looks good on higher and lower density devices I have.

    Code:
    Sub InitDrawingTools()
    ...
        ScalePaint.SetAntiAlias(
    True)
        ScalePaint.SetDither(
    True' added
        ScalePaint.SetLinearText(True' added
    ...
    End Sub

    Sub drawScale(Canv As Canvas)
        ExDraw.drawOval(Canv, scaleRect, ScalePaint)

        ExDraw.save2(Canv, ExDraw.MATRIX_SAVE_FLAG)

        
    Dim fMag As Float = 25
        
    Dim fOTS As Float = ScalePaint.GetTextSize
        
    Dim fOSW As Float =    ScalePaint.GetStrokeWidth
        ScalePaint.SetTextSize(fMag*fOTS)
        ScalePaint.SetStrokeWidth(fOSW*fMag)
        ExDraw.scale(Canv, 
    1/fMag, 1/fMag)
       
        
    Dim i As Int
        
    Dim y1 As Float
        
    Dim y2 As Float
        
    Dim y3 As Float
        
    Dim value As Int
        
    Dim valueString As String
        
    For i = 0 To totalNicks
            y1 = scaleRect.top
            
    If (i Mod 5 = 0Then
                y2 = y1 - 
    0.025 ' for the 5 degree nicks
            Else
                y2 = y1 - 
    0.018
            
    End If
            y3 = y1 - 
    0.020 - 0.015
           
            value = nickToDegree(i)
            
    If (value >= minDegrees And value <= maxDegrees) Then
                ExDraw.drawLine(Canv, 
    0.5*fMag, fMag*y1, 0.5*fMag, fMag*y2, ScalePaint)
               
                
    If (i Mod 5 = 0Then   
                    valueString = value
                    ExDraw.drawText(Canv, valueString, 
    0.5*fMag,fMag*y3, ScalePaint)
                
    End If
            
    End If
           
            ExDraw.rotate2(Canv, degreesPerNick, 
    0.5*fMag,fMag* 0.5)
        
    Next

        ScalePaint.SetStrokeWidth(fOSW)
        ScalePaint.SetTextSize(fOTS)
        ExDraw.restore(Canv)
    End Sub

    Sub nickToDegree(Nick As Int) As Int
        
    Dim rawDegree As Int
        
    If (Nick < totalNicks / 2Then
            rawDegree = Nick*
    2
        
    Else
             rawDegree = (Nick - totalNicks) * 
    2
        
    End If
       
        
    Dim shiftedDegree As Int
       
        shiftedDegree = rawDegree + centerDegree
        
    Return shiftedDegree
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice