Page 1 of 1

Drawing Custom Brushes

Posted: Wed Dec 04, 2024 10:03 pm
by oceanarts
Why does this :

Code: Select all

v = {}
	v[0] = 200;X1
	v[1] = 380 ;Y1
	v[2] = 780;X2
	v[3] = 380;Y2
	v[4] = 780 ;X3
	v[5] = 480 ;Y3
	v[6] = 200;X4
	v[7] = 480 ;Y4
	SetFormStyle(#BORDER|#ANTIALIAS, {BorderColor = d_col, BorderSize = 1})
	Polygon(0, 0, v, 4)
And this ;

Code: Select all

	CreateBrush(1, 70, 70, 0, {AlphaChannel = True, Clear = True, Callback =
	Function(msg)
		SelectBrush(msg.id, #SELMODE_COMBO)
			v = {}
			v[0] = 0;X1
			v[1] = 0 ;Y1
			v[2] = 69;X2
			v[3] = 0;Y2
			v[4] = 69 ;X3
			v[5] = 69;Y3
			v[6] = 0;X4
			v[7] = 69 ;Y4
		SetFormStyle(#BORDER|#ANTIALIAS, {BorderColor = d_col, BorderSize = 1})
		Polygon(0, 0, v, 4, d_col) ; The Color Variable is required here.
		EndSelect
	EndFunction
	})
Produce different results? In the first example a double outline is drawn, but in the second example a single outline is drawn. And I can't seem to get BorderSize to do anything at all.

Re: Drawing Custom Brushes

Posted: Thu Dec 05, 2024 7:27 am
by jPV
oceanarts wrote: Wed Dec 04, 2024 10:03 pm Produce different results? In the first example a double outline is drawn, but in the second example a single outline is drawn.
Could you provide fully working examples? Hard to tell what's been done in your actual script before these snippets.
And I can't seem to get BorderSize to do anything at all.
Maybe because: "Please note that #BORDER is not supported for the fill style #FILLNONE if layers are disabled."?

Re: Drawing Custom Brushes

Posted: Thu Dec 05, 2024 1:57 pm
by oceanarts
Working code:

Code: Select all

@DISPLAY{WIDTH = 960, HEIGHT = 540, MODE = "WINDOWED", TITLE = "TEST", COLOR = #BLACK}

EnableLayers()
EscapeQuit(True)

;=========================================================================================
;GLOBAL VARS:
;------------

Global d_width = GetAttribute(#DISPLAY, 1, #ATTRRAWWIDTH ) ; Display-Width
Global d_height = GetAttribute(#DISPLAY, 1, #ATTRRAWHEIGHT) ; Display-Height
Global d_col = $4C8B3F ; Display-Color
Global mst_vol = 32 ; Master Volume

Global active_screen = 1

;=========================================================================================

Function p_MainScreen()

	;RECTANGLE:	
	v = {}
	v[0] = 200;X1
	v[1] = 380 ;Y1
	v[2] = 780;X2
	v[3] = 380;Y2
	v[4] = 780 ;X3
	v[5] = 480 ;Y3
	v[6] = 200;X4
	v[7] = 480 ;Y4
	SetFormStyle(#BORDER|#ANTIALIAS, {BorderColor = d_col, BorderSize = 1})
	Polygon(0, 0, v, 4)
	
	; CUSTOM ICON-SELECTOR BRUSH:
	CreateBrush(1, 70, 70, 0, {AlphaChannel = True, Clear = True, Callback =
	Function(msg)
		SelectBrush(msg.id, #SELMODE_COMBO)
			v = {}
			v[0] = 0;X1
			v[1] = 0 ;Y1
			v[2] = 69;X2
			v[3] = 0;Y2
			v[4] = 69 ;X3
			v[5] = 69;Y3
			v[6] = 0;X4
			v[7] = 69 ;Y4
		SetFormStyle(#BORDER|#ANTIALIAS, {BorderColor = d_col, BorderSize = 1})
		Polygon(0, 0, v, 4, d_col)
		EndSelect
	EndFunction
	})
	
	DisplayBrush(1, 0, 0)
	
EndFunction

Function p_FlipBook()

	if active_screen = 1
		p_MainScreen()
	EndIf
	
EndFunction

;MAIN-LOOP:

	p_FlipBook()

Repeat

	WaitEvent
	
Forever

DisableLayers()

End
If comment out SetFormStyle(#BORDER|#ANTIALIAS, {BorderColor = d_col, BorderSize = 1}) in the first (non-brush) polygon it won't draw anything at all (at least visibly). So, it must have a function??
But that line has no effect in the brush polygon.

Re: Drawing Custom Brushes

Posted: Thu Dec 05, 2024 9:12 pm
by jPV
Sorry a bit hurry for couple of days, but a quick reply..
oceanarts wrote: Thu Dec 05, 2024 1:57 pm If comment out SetFormStyle(#BORDER|#ANTIALIAS, {BorderColor = d_col, BorderSize = 1}) in the first (non-brush) polygon it won't draw anything at all (at least visibly).
You're drawing black on black? Define a color for polygon.
Produce different results? In the first example a double outline is drawn, but in the second example a single outline is drawn. And I can't seem to get BorderSize to do anything at all.
First is using layers (remember "Please note that #BORDER is not supported for the fill style #FILLNONE if layers are disabled."), but drawing into a brush isn't using layers and is using the default #FILLNONE.

Also the border is drawn outside of an object, so when you draw exactly on the brush area, border would go outside of the brush and thus not drawn.

Play around with this:

Code: Select all

	CreateBrush(1, 70, 70, 0, {AlphaChannel = True, Clear = True, Callback =
	Function(msg)
		SelectBrush(msg.id, #SELMODE_COMBO)
			v = {}
			v[0] = 1;X1
			v[1] = 1 ;Y1
			v[2] = 68;X2
			v[3] = 1;Y2
			v[4] = 68 ;X3
			v[5] = 68;Y3
			v[6] = 1;X4
			v[7] = 68 ;Y4
		SetFillStyle(#FILLCOLOR)
		SetFormStyle(#BORDER|#ANTIALIAS, {BorderColor = d_col, BorderSize = 1})
		Polygon(0, 0, v, 4, #BLUE)
		EndSelect
	EndFunction
	}) 

Re: Drawing Custom Brushes

Posted: Fri Dec 06, 2024 11:40 pm
by oceanarts
drawing into a brush isn't using layers and is using the default #FILLNONE.
Ah! Foiled again!

Thanks for taking the time to explain things to me. Can't really express my gratitude.
I'll play around with this. :)

Re: Drawing Custom Brushes

Posted: Sat Dec 07, 2024 4:56 pm
by oceanarts
Yes, SetFillStyle seems to do what I want here.

Code: Select all

; CUSTOM ICON-SELECTOR BRUSH:
	CreateBrush(1, 70, 70, 0, {AlphaChannel = True, Clear = True, Callback =
	Function(msg)
		SelectBrush(msg.id, #SELMODE_COMBO)
			v = {}
			v[0] = 0;X1
			v[1] = 0 ;Y1
			v[2] = 69;X2
			v[3] = 0;Y2
			v[4] = 69 ;X3
			v[5] = 69;Y3
			v[6] = 0;X4
			v[7] = 69 ;Y4
		SetFillStyle(#FILLNONE, 2)
		Polygon(0, 0, v, 4, d_col)
		EndSelect
	EndFunction
	})
Thanks again! :)