Jump to content
Tuts 4 You
Sign in to follow this  
LCF-AT

How to use RoundRects with Gardient Color?

Rate this topic

Recommended Posts

LCF-AT

Hi guys,

I would like to know whether anyone knows a method to create rounded corners (buttons / Icons) filled with gardient colors inside and transparent outside the corners.At the moment I didnt found any way to make it with a simple method.Only thing I could do is to fill each outside pixel manually with some color xy.

Example: Using static color of menu (no gardient style)

I create a context menu with drawed icons before each menu entry.Now I draw the background with same color like the menu has and then creating the round corners.

                ...............
        		invoke GetSysColor,COLOR_MENU               ; get system menu color
        		invoke CreateSolidBrush,eax
        		push eax
        		invoke FillRect,hdcBitmap,addr rect,eax     ; fill icon rect 16x16 with menu color
        		pop eax
        		invoke SelectObject,hdcBitmap,eax
        		invoke RoundRect, hdcBitmap, rect.left, rect.top, rect.right, rect.bottom, 6, 6	
                ..............

The result looks so...

01.png.b2e84607f55729406d0c5a80ebc25170.png

...this works.

Example: Doing same with Gardient color

        		invoke Gradient_Fill,hdcBitmap,addr rect,084ACDDh,0ECF5FFh,GRADIENT_FILL_RECT_V

        		invoke GetStockObject,HOLLOW_BRUSH		
        		invoke SelectObject,hdcBitmap,eax
        		
        		invoke RoundRect, hdcBitmap, rect.left, rect.top, rect.right, rect.bottom, 6, 6

...result like this...

02.png.a0dd1eb68981229e71d71c378d8cedc2.png

....if you check the corners outside then you still see the colors...

03.png.063276b34b7820a0167ca72d86cb01bb.png

....I dont wanna have.Only way I could do is to fill each single outside pixel of the corners manually using FillRect function like this....

        		invoke Gradient_Fill,hdcBitmap,addr rect,084ACDDh,0ECF5FFh,GRADIENT_FILL_RECT_V

        		invoke GetStockObject,HOLLOW_BRUSH		
        		invoke SelectObject,hdcBitmap,eax
        		
        		invoke RoundRect, hdcBitmap, rect.left, rect.top, rect.right, rect.bottom, 6, 6	

        		invoke GetSysColor,COLOR_MENU
        		INVOKE CreateSolidBrush,eax       		
        		mov SYSCOLOR,eax


        		mov rect.bottom,0
        		mov rect.left,0 
         		mov rect.right,2
        		mov rect.top,1
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR     		
        		
        		mov rect.bottom,0
        		mov rect.left,0
         		mov rect.right,1
        		mov rect.top,2     		
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR
        		
        		mov rect.bottom,16
        		mov rect.left,0
         		mov rect.right,2
        		mov rect.top,15      		
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR
        		
        		mov rect.bottom,16
        		mov rect.left,0
         		mov rect.right,1
        		mov rect.top,14      		
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR
        		
        		mov rect.bottom,0
        		mov rect.left,14
         		mov rect.right,16
        		mov rect.top,1    		
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR
        		
        		mov rect.bottom,0
        		mov rect.left,15
         		mov rect.right,16
        		mov rect.top,2       		
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR
        		
        		mov rect.bottom,16
        		mov rect.left,14
         		mov rect.right,16
        		mov rect.top,15      		
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR     		
        		
        		mov rect.bottom,16
        		mov rect.left,15
         		mov rect.right,16
        		mov rect.top,14       		
        		INVOKE FillRect, hdcBitmap, ADDR rect, SYSCOLOR

....result....

04.png.551a1864527d6238852f0d932b6af1ef.png05.png.4f77d8bbc5d83c7a7e4c4aec94565544.png

...so it works but its a bad method using so much single FillRects for this for the outside pixels.Does anyone has any clue how to make the pixel outside transparent etc when using RoundRect function?Or is there any Gardient Round Fill function I could use?

greetz

Share this post


Link to post
Share on other sites
Mad Max

Bemme check mal bitte deine PM!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...