DisplayPipelineDrawBitmap Method |
Namespace: Rhino.Display
using System.Drawing; using Rhino; using Rhino.Commands; using Rhino.Display; namespace examples_cs { public class DrawBitmapConduit : Rhino.Display.DisplayConduit { private readonly DisplayBitmap m_display_bitmap; public DrawBitmapConduit() { var flag = new System.Drawing.Bitmap(100, 100); for( int x = 0; x < flag.Height; ++x ) for( int y = 0; y < flag.Width; ++y ) flag.SetPixel(x, y, Color.White); var g = Graphics.FromImage(flag); g.FillEllipse(Brushes.Blue, 25, 25, 50, 50); m_display_bitmap = new DisplayBitmap(flag); } protected override void DrawForeground(Rhino.Display.DrawEventArgs e) { e.Display.DrawBitmap(m_display_bitmap, 50, 50); } } public class DrawBitmapCommand : Command { public override string EnglishName { get { return "csDrawBitmap"; } } readonly DrawBitmapConduit m_conduit = new DrawBitmapConduit(); protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // toggle conduit on/off m_conduit.Enabled = !m_conduit.Enabled; RhinoApp.WriteLine("Custom conduit enabled = {0}", m_conduit.Enabled); doc.Views.Redraw(); return Result.Success; } } }
import Rhino from Rhino.Geometry import * import System.Drawing import Rhino.Display import scriptcontext import rhinoscriptsyntax as rs class CustomConduit(Rhino.Display.DisplayConduit): def __init__(self): flag = System.Drawing.Bitmap(100,100) for x in range(0,100): for y in range(0,100): flag.SetPixel(x, y, System.Drawing.Color.Red) g = System.Drawing.Graphics.FromImage(flag) g.FillEllipse(System.Drawing.Brushes.Blue, 25, 25, 50, 50) self.display_bitmap = Rhino.Display.DisplayBitmap(flag) def DrawForeground(self, e): e.Display.DrawBitmap(self.display_bitmap, 50, 50) if __name__== "__main__": conduit = CustomConduit() conduit.Enabled = True scriptcontext.doc.Views.Redraw() rs.GetString("Pausing for user input") conduit.Enabled = False scriptcontext.doc.Views.Redraw()