• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

blendmodes - mojo2

Rich

Well-known member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
3rd Party Tool Dev
Joined
Sep 9, 2017
Messages
451
Hi
i may need some help please.. is there a blendmode (or other method) that will allow me to And the below pictures together to make image 3?
(forget the white ghosting in image 3, its supposed to all blue like in image 2, I'll ust being lazy when creating the picture)
 

Attachments

  • Image4.png
    Image4.png
    12.3 KB · Views: 200
Last edited:
If the second image is just a rectangle you could simply set your color and draw the image via DrawRect(x,y,image,sourceX,sourceY,width,height) or set a clipping rectangle. If the second image could be any image you should use a shader.
 
thanks for all the pointers everyone...
I decided to write a quick app to show me which one I need... Im leaning towards AlphaStamp
Cerberus:
Strict
Import mojo2

Class myClass Extends App
    Field canvas:Canvas
    Field blend:Int=0
    Field mask_img:Image, pic_img:Image
    Field dest_img:Image,dest_cnvs:Canvas

    Method OnCreate:Int()
        mask_img = Image.Load("mask.png")
        pic_img = Image.Load("pic.png")
        
        dest_img = New Image(200,200)
        dest_cnvs = New Canvas(dest_img)
        
        SetUpdateRate(60)                
        canvas = New Canvas
        Return 0
    End
    
    Method OnUpdate:Int()
        If KeyHit(KEY_SPACE) Or MouseHit(MOUSE_LEFT) Then blend=(blend+1) Mod 16
        Return 0
    End
    
    Method OnRender:Int()
        dest_cnvs.Clear(0,0,0,0)
        If blend<8
            dest_cnvs.SetBlendMode BlendMode.Alpha
            dest_cnvs.DrawImage mask_img,100,100
            dest_cnvs.SetBlendMode blend
            dest_cnvs.DrawImage pic_img,100,100
        Else
            dest_cnvs.SetBlendMode BlendMode.Alpha
            dest_cnvs.DrawImage pic_img,100,100
            dest_cnvs.SetBlendMode blend-8
            dest_cnvs.DrawImage mask_img,100,100
        End
        dest_cnvs.Flush()
        
        canvas.Clear (0,0.5,0)    
        canvas.SetBlendMode BlendMode.Alpha
        If blend<8
            canvas.DrawText "BlendMode."+blendmode(blend),0,0
            canvas.DrawImage mask_img,100,200                            
            canvas.DrawImage pic_img,300,200                            
            canvas.DrawImage dest_img,500,200                            
        Else
            canvas.DrawText "BlendMode."+blendmode(blend-8),0,0
            canvas.DrawImage pic_img,100,200                            
            canvas.DrawImage mask_img,300,200                            
            canvas.DrawImage dest_img,500,200                            
        End
        canvas.DrawText "+",200,200
        canvas.DrawText "=",400,200
        canvas.Flush

        Return 0
    End
    
    Method blendmode:String(mode:Int)
        Select mode
        Case 0
            Return "Opaque"
        Case 1
            Return "Alpha"
        Case 2
            Return "Additive"
        Case 3
            Return "Multiply"
        Case 4
            Return "Multiply2"
        Case 5
            Return "Alpha2"
        Case 6
            Return "Opaque2"
        Case 7
            Return "AlphaStamp"
        End
        Return "no blend mode"
     End
End

Function Main:Int()
    New myClass        
    Return 0
End
obv use you own images or use mine....
 

Attachments

  • mask.png
    mask.png
    1.1 KB · Views: 194
  • pic.png
    pic.png
    669 bytes · Views: 187
Last edited:
@Holzchopf it was Multiply2 in the end
the above example helped me prove which mode i wanted, which lead me to discover a bug in my app code ;-)
 
Back
Top Bottom