| McNeel Wiki | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| edit · print · help · all topics | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Main Pages
Languages
|
GDI+ Brush objectsGDI+ Brush objects are used to draw contents (fills) of geometry. There are a number of distinct Brush types available in GDI+, some of which are exposed in the RhPicture plugin:
Brush types not available in the RhPicture plugin:
Note that you do not need a Brush object to draw fills in the RhPicture plugin. Every method that takes a Brush object is overloaded and can be called with a colour instead, in which case you get a simple solid fill:
Dim RhPicture : Set RhPicture = Rhin.GetPluginObject("RhPicture")
Call RhPicture.CreateImage(80, 50, vbWhite)
Call RhPicture.FillCircle(Array(40,25), 20, vbRed)
If you want to draw non-solid fills, you'll have to use an RhPicture Brush object. You can obtain a Brush object by calling one of the Brush creation methods on RhPicture:
Dim RhPicture : Set RhPicture = Rhin.GetPluginObject("RhPicture")
Call RhPicture.CreateImage(80, 50, vbWhite)
Dim BrushObj : Set BrushObj = RhPicture.CreateGradientBrush(Array(0, 0), Array(50,0), vbRed, vbBlack)
Call RhPicture.FillCircle(Array(40,25), 20, BrushObj)
Note that you can store any number of Brush objects in your script and you can reuse them as often as you like. Brush objects are not bound to the RhPicture instance that created them and you can use them on any RhPicture object. There are several Brush creation methods available, one for each type of Brush: RhPicture.CreateSolidBrush(Color As GDIColor) As GDIBrush RhPicture.CreateHatchBrush(HatchStyle As Integer, Foreground As GDIColor, Optional Background As GDIColor) As GDIBrush RhPicture.CreateTextureBrush(Texture As String, Optional WrapMode As Integer) As GDIBrush RhPicture.CreateGradientBrush(From As GDIPoint, To As GDIPoint, Color1 As GDIColor, Color2 As GDIColor) As GDIBrush
Enumerations explained:
Linear Gradients explained:Be careful when using Linear Gradient brushes. The coordinates that define the start and end points of the gradient may be subject to noise. Since gradients are stacked rather than mirrored it is possible you get bleeding colours if you've defined your gradient to fit exactly within your drawing region. It is usually best to make the gradient extend one pixel in each direction:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rename · changes · history · subscriptions · lost and found · references · file upload | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||