Drawing Custom Brushes

Find quick help here to get you started with Hollywood
Post Reply
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Drawing Custom Brushes

Post 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.
Development System : Imac G5, MorphOs 3.19
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Drawing Custom Brushes

Post 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."?
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Drawing Custom Brushes

Post 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.
Development System : Imac G5, MorphOs 3.19
User avatar
jPV
Posts: 734
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Drawing Custom Brushes

Post 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
	}) 
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Drawing Custom Brushes

Post 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. :)
Development System : Imac G5, MorphOs 3.19
oceanarts
Posts: 111
Joined: Mon May 27, 2024 10:42 pm

Re: Drawing Custom Brushes

Post 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! :)
Development System : Imac G5, MorphOs 3.19
Post Reply