Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:rhpicture:drawgeometry [2015/09/14]
127.0.0.1 external edit
developer:rhpicture:drawgeometry [2016/03/18] (current)
sandy
Line 1: Line 1:
-====== RhPicture ​Plugin ​Geometry Drawing Routines ======+====== RhPicture ​Plug-in ​Geometry Drawing Routines ======
  
-> **Summary:​** //A description of geometry drawing calls as exposed through the [[developer:​rhinoscriptimageextension|RhPicture]] ​plugin.//+> **Summary:​** //A description of geometry drawing calls as exposed through the [[developer:​rhinoscriptimageextension|RhPicture]] ​plug-in//
  
 \\ \\
  
-=====The general syntax for Drawing Geometric Primitives=====+=====The general syntax for drawing geometric primitives=====
  
-RhPicture supports the drawing and filling of several geometric primitives, and the function calls are all very similar. All **Draw**** methods can be used to draw the outlines of geometry and they accept (apart from the essential data that defines the primitive) either a [[developer:​rhpicture:​gdipen|GDIPen]] object or a [[developer:​rhpicture:​gdicolor|GDIColor]] + Width combo. All **Fill**** methods can be used to paint the contents of geometry and they accept either a [[developer:​rhpicture:​gdibrush|GDIBrush]] object or a single [[developer:​rhpicture:​gdicolor|GDIColor]] .+RhPicture supports the drawing and filling of several geometric primitives, and the function calls are all very similar. All **Draw** methods can be used to draw the outlines of geometry and they accept (apart from the essential data that defines the primitive) either a [[developer:​rhpicture:​gdipen|GDI+ Pen]] object or a [[developer:​rhpicture:​gdicolor|GDI Color]] + Width combo. All **Fill** methods can be used to paint the contents of geometry and they accept either a [[developer:​rhpicture:​gdibrush|GDI Brush]] object or a single [[developer:​rhpicture:​gdicolor|GDI Color]].
  
-\\ 
  
-When drawing geometry you have to use the Image coordinate system. This is a floating point system which is infinite in all directions (though large numbers can cause overflow errors). The origin of the system is located at the upper-left pixel (0,0) and every system unit represents a single pixel. The highest value on the bitmap is (width-1, height-1) and everything ​drawn beyond this will not be visible.+When drawing geometry you have to use the Image coordinate system. This is a floating point system which is infinite in all directions (though large numbers can cause overflow errors). The origin of the system is located at the upper-left pixel (0,0) and every system unit represents a single pixel. The highest value on the bitmap is (width-1, height-1) and anything ​drawn beyond this will not be visible.
  
 \\ \\
Line 19: Line 18:
 \\ \\
  
-It is possible in GDI+ to apply a linear transformation to a drawing pipeline, but this feature has not yet been exposed in the [[developer:​rhinoscriptimageextension|RhPicture]] ​plugin.+It is possible in GDI+ to apply a linear transformation to a drawing pipeline, but this feature has not yet been exposed in the [[developer:​rhinoscriptimageextension|RhPicture]] ​plug-in.
  
 \\ \\
Line 29: Line 28:
  
 Lines, polylines and curves are essentially defined by an array of 2D bitmap coordinates. Drawing lines is the simplest example since it doesn'​t involve variable arrays: Lines, polylines and curves are essentially defined by an array of 2D bitmap coordinates. Drawing lines is the simplest example since it doesn'​t involve variable arrays:
- 
-\\ 
  
   Dim RhPicture : Set RhPicture = Rhino.GetPluginObject("​RhPicture"​)   Dim RhPicture : Set RhPicture = Rhino.GetPluginObject("​RhPicture"​)
Line 42: Line 39:
 \\ \\
  
-Polylines and curves take an array of 2D points instead of two singular coordinates. When the distance between the first and last point in the array is less than one tenth of a pixel, the polyline/​curve is considered closed and no end caps will be drawn. When drawing line geometry, ​one can also use [[developer:​rhpicture:​gdipen|GDI Pen objects]] : +Polylines and curves take an array of 2D points instead of two singular coordinates. When the distance between the first and last point in the array is less than one tenth of a pixel, the polyline/​curve is considered closed and no end caps will be drawn. When drawing line geometry, ​you can also use [[developer:​rhpicture:​gdipen|GDI Pen objects]]:
- +
-\\+
  
   RhPicture.DrawLine(A As Point, B As Point, Col As GDIColor [, Width As Double])   RhPicture.DrawLine(A As Point, B As Point, Col As GDIColor [, Width As Double])
Line 53: Line 48:
   RhPicture.DrawCurve(Pts() As Point, Pen As GDIPen)   RhPicture.DrawCurve(Pts() As Point, Pen As GDIPen)
  
-\\ +<color Red> Note! The current version of the plug-in ​does not accept variables which are declared as arrays. You have to box these before calling procedures like DrawPolyline():​ </​color>​
- +
-<color Red> Note! The current version of the plugin ​does not accept variables which are declared as arrays. You have to box these before calling procedures like DrawPolyline():​ </​color>​+
  
   Dim vertices()   Dim vertices()
Line 61: Line 54:
   Dim v : v = vertices   Dim v : v = vertices
   Call RhPicture.DrawPolyline(v,​ vbBlack)   Call RhPicture.DrawPolyline(v,​ vbBlack)
- 
-\\ 
-\\ 
  
 Drawing the content of polylines and curves requires the same coordinates but the functions are called differently:​ Drawing the content of polylines and curves requires the same coordinates but the functions are called differently:​
- 
-\\ 
  
   RhPicture.FillPolyline(Pts() As Point, Col As GDIColor)   RhPicture.FillPolyline(Pts() As Point, Col As GDIColor)
Line 74: Line 62:
   RhPicture.FillCurve(Pts() As Point, Brush As GDIBrush)   RhPicture.FillCurve(Pts() As Point, Brush As GDIBrush)
  
-\\ +If the coordinates do not define a closed shape, the shape will be closed with a single linear segment. Instead of [[developer:​rhpicture:​gdipen|GDI Pen]] objects, Fill routines accept [[developer:​rhpicture:​gdibrush|GDI Brush]] objects.
- +
-If the coordinates do not define a closed shape, the shape will be closed with a single linear segment. Instead of [[developer:​rhpicture:​gdipen|GDIPen]] objects, Fill routines accept [[developer:​rhpicture:​gdibrush|GDIBrush]] objects.+
  
  
Line 86: Line 72:
 =====Drawing primitives===== =====Drawing primitives=====
  
-You can also draw rectangles, circles and ellipses directly. They work similar to the other drawing methods. Note the difference in coordinate specification between ellipses and circles though:+You can also draw rectangles, circlesand ellipses directly. They work similar to the other drawing methods. Note the difference in coordinate specification between ellipses and circles though:
  
  
Line 97: Line 83:
   RhPicture.DrawCircle(Center As Point, Radius As Double, Col As GDIColor [, Width As Double])   RhPicture.DrawCircle(Center As Point, Radius As Double, Col As GDIColor [, Width As Double])
   RhPicture.DrawCircle(Center As Point, Radius As Double, Pen As GDIPen)   RhPicture.DrawCircle(Center As Point, Radius As Double, Pen As GDIPen)
- 
-\\ 
  
 and... and...
- 
-\\ 
  
   RhPicture.FillRectangle(Corner As Point, Width As Double, Height As Double, Col As GDIColor)   RhPicture.FillRectangle(Corner As Point, Width As Double, Height As Double, Col As GDIColor)
Line 116: Line 98:
 \\ \\
  
-=====Drawing ​Strings=====+=====Drawing ​strings=====
  
 Text is drawn using a single overloaded method: Text is drawn using a single overloaded method:
- 
-\\ 
  
   RhPicture.DrawString(Text As String, Pt As Point)   RhPicture.DrawString(Text As String, Pt As Point)
Line 135: Line 115:
 | Text     | String ​  | The text to draw. | | Text     | String ​  | The text to draw. |
 | Pt       | 2D Point | The point where the text starts (lower left corner of the baseline) | | Pt       | 2D Point | The point where the text starts (lower left corner of the baseline) |
-| F        | GDIFont | A [[developer:​rhpicture:​gdifont|GDIFont]] object. |+| F        | GDIFont | A [[developer:​rhpicture:​gdifont|GDI Font]] object. |
 | FontName | String ​  | The name of a font family. | | FontName | String ​  | The name of a font family. |
-| Col      | GDIColor | The colour ​of the text. | +| Col      | GDIColor | The color of the text. | 
-| Brs      | GDIBrush ​ | A [[developer:​rhpicture:​gdibrush|GDIBrush]] object that defines the fill of the text. |+| Brs      | GDIBrush ​ | A [[developer:​rhpicture:​gdibrush|GDI Brush]] object that defines the fill of the text. |
 | Angle    | Double ​  | An angle (in degrees, counter clockwise) that controls the rotation of the text around the basepoint. | | Angle    | Double ​  | An angle (in degrees, counter clockwise) that controls the rotation of the text around the basepoint. |
  
Line 152: Line 132:
 =====Drawing Images===== =====Drawing Images=====
  
-It's also possible to draw images on top of other images. This allows ​for a number of possibilities which are not possible with texture brushes: +It's also possible to draw images on top of other images. This allows a number of possibilities which are not possible with texture brushes:
- +
-\\+
  
   * Scaling of images   * Scaling of images
-  * Mask colours+  * Mask colors
   * Alpha multipliers   * Alpha multipliers
   * Blending modes   * Blending modes
  
-\\ +There are two distinct ways of drawing images in the RhPicture ​plug-in. The simplest one is very similar to drawing rectangles, except ​for brushes you have to supply the path to an image file on the disk:
- +
-There are two distinct ways of drawing images in the RHINOSCRIPTIMAGEEXTENSION|RhPicture]] plugin. The simplest one is very similar to drawing rectangles, except ​of brushes you have to supply the path to an image file on the disk: +
- +
-\\+
  
   RhPicture.DrawImage(FileName As String)   RhPicture.DrawImage(FileName As String)
Line 183: Line 157:
 | Quality ​     | Integer ​ | The Inteprolation Enumaration of the resampling operation. If the drawn image has to be scaled this value is used. See table below for valid values. | | Quality ​     | Integer ​ | The Inteprolation Enumaration of the resampling operation. If the drawn image has to be scaled this value is used. See table below for valid values. |
 | Alpha        | Double ​   | A value indicating the opacity of the drawn image. 0.0 means it will be completely transparant,​ 1.0 means completely opaque. This value is multiplied by the actual alpha channel information in the image, meaning it is still possible to drawn semi-transparant pixels when Alpha equals 1.0 | | Alpha        | Double ​   | A value indicating the opacity of the drawn image. 0.0 means it will be completely transparant,​ 1.0 means completely opaque. This value is multiplied by the actual alpha channel information in the image, meaning it is still possible to drawn semi-transparant pixels when Alpha equals 1.0 |
-| Mask         ​| ​GDIColor ​| A GDIColor ​that sets the mask-color of the image. This can be used to make single ​colour ​backgrounds ​transparant. |+| Mask         ​| ​GDI Color | A GDI Color that sets the mask-color of the image. This can be used to make single ​color backgrounds ​transparent. |
  
 \\ \\
Line 192: Line 166:
 | Quality = 0 | Quality = 1 | Quality = 2 | | Quality = 0 | Quality = 1 | Quality = 2 |
  
-\\ 
 \\ \\
  
-The second way of drawing ​images is to use the Merge methods in RhPicture. ​Rather than pasting the new image on top of the old one the Merge method performs a per-pixel comparison ​and the final result is usually a combination of the input pixels. This means that the overlay image cannot be drawn in a different size since that would break the 1-to-1 pixel relationship between the images. You can however specify the upper-left corner of the overlay and the blending mode to be used: +The second way to draw images is to use the Merge methods in RhPicture. ​Instead of pasting the new image on top of the old one the Merge method performs a per-pixel comparison. The final result is usually a combination of the input pixels. This means that the overlay image cannot be drawn in a different size since that would break the 1-to-1 pixel relationship between the images. You can however specify the upper-left corner of the overlay and the blending mode to be used:
- +
-\\+
  
   RhPicture.Merge(Other As RhPicture [, Style As Integer [, Corner As Point]])   RhPicture.Merge(Other As RhPicture [, Style As Integer [, Corner As Point]])
   RhPicture.Merge(FileName As String [, Style As Integer [, Corner As Point]])   RhPicture.Merge(FileName As String [, Style As Integer [, Corner As Point]])
  
-\\ +As you can see you either use an existing image file on the disk or another (not the same, NEVER the same!) instance of the RhPicture ​plug-in. I'll explain the blendings styles ​by example. We'll be merging image B with image A:
- +
-As you can see you either use an existing image file on the disk or another (not the same, NEVER the same!) instance of the RhPicture ​plugin. I'll explain the blendings styles ​per example. We'll be merging image B with image A:+
  
 \\ \\
Line 223: Line 192:
 | Style | Description | | Style | Description |
 | Multiply | The unitized channel values {0.0~1.0} are multiplied together, giving the impression of viewing the base image through a pane of tinted glass. The image can only become darker. | | Multiply | The unitized channel values {0.0~1.0} are multiplied together, giving the impression of viewing the base image through a pane of tinted glass. The image can only become darker. |
-| Addition | The RGB values are added together and then clipped back to the {0~255} range. ​the image can only become brighter. |+| Addition | The RGB values are added together and then clipped back to the {0~255} range. ​The image can only become brighter. |
 | Subtraction | The RGB values in the overlay images are subtracted from the RGB values in the base image. The image can only become darker. | | Subtraction | The RGB values in the overlay images are subtracted from the RGB values in the base image. The image can only become darker. |
 | Average ​ | All RGB channels are averaged. | | Average ​ | All RGB channels are averaged. |
developer/rhpicture/drawgeometry.txt · Last modified: 2016/03/18 by sandy