Skip to content

Commit

Permalink
fix(extra): Add color option to Screen Oriented Text
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey authored and Chris Mackey committed Nov 28, 2023
1 parent b9aa471 commit 5d5d310
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
Binary file modified ladybug_grasshopper/icon/LB Screen Oriented Text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 20 additions & 13 deletions ladybug_grasshopper/json/LB_Screen_Oriented_Text.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
{
"description": "Generate screen-oriented text that displays in the Rhino scene as a head-up\ndisplay (HUD).\n_\nThis is useful when there are certain summary results or information that should\nalways be displayed on-screen.\n-",
"version": "1.7.1",
"nickname": "Text2D",
"outputs": [
[]
],
"code": "",
"name": "LB Screen Oriented Text",
"version": "1.7.0",
"category": "Ladybug",
"subcategory": "4 :: Extra",
"nickname": "Text2D",
"inputs": [
{
"type": "string",
"access": "list",
"name": "_text",
"description": "Text string to be displayed in the plane of the screen.",
"access": "list",
"type": "string",
"default": null
},
{
"type": "System.Object",
"access": "list",
"name": "leg_par2d_",
"description": "Optional 2D LegendParameters from the \"LB Legend Parameters 2D\"\ncomponent, which will be used to customize a text in the plane\nof the screen. Note that only the text_height, origin_x and origin_y\ninputs of this component affect the placement of the text.",
"access": "list",
"type": "System.Object",
"default": null
},
{
"type": "string",
"access": "item",
"name": "_font_",
"description": "An optional text string to specify the font to be used for the text.\nExamples include \"Arial\", \"Times New Roman\", \"Courier\" (all without\nquotations). Default is \"Arial\".",
"type": "string",
"default": null
},
{
"access": "item",
"name": "_color_",
"description": "An optional color to set the color of the text. If unspecified,\nit will be black.",
"type": "System.Drawing.Color",
"default": null
}
]
],
"subcategory": "4 :: Extra",
"code": "",
"category": "Ladybug",
"name": "LB Screen Oriented Text",
"description": "Generate screen-oriented text that displays in the Rhino scene as a head-up\ndisplay (HUD).\n_\nThis is useful when there are certain summary results or information that should\nalways be displayed on-screen.\n-"
}
12 changes: 9 additions & 3 deletions ladybug_grasshopper/src/LB Screen Oriented Text.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
_font_: An optional text string to specify the font to be used for the text.
Examples include "Arial", "Times New Roman", "Courier" (all without
quotations). Default is "Arial".
_color_: An optional color to set the color of the text. If unspecified,
it will be black.
"""

from ghpythonlib.componentbase import executingcomponent as component
Expand All @@ -38,10 +40,10 @@ def __init__(self):
super(MyComponent,self).__init__()
self.text_2d_args = None

def RunScript(self, _text, leg_par2d_, _font_):
def RunScript(self, _text, leg_par2d_, _font_, _color_):
ghenv.Component.Name = 'LB Screen Oriented Text'
ghenv.Component.NickName = 'Text2D'
ghenv.Component.Message = '1.7.0'
ghenv.Component.Message = '1.7.1'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '0'
Expand All @@ -67,6 +69,7 @@ def RunScript(self, _text, leg_par2d_, _font_):
vw = v_size.Width
vh = v_size.Height
_font = 'Arial' if _font_ is None else _font_
_color_ = black() if _color_ is None else _color_

# convert the inputs into arguments to be rendered
self.text_2d_args = []
Expand All @@ -79,7 +82,7 @@ def RunScript(self, _text, leg_par2d_, _font_):
or_x = Legend.parse_dim_2d(l_par.origin_x, vw)
or_y = Legend.parse_dim_2d(l_par.origin_y, vh)
d_args = (
txt, black(), rg.Point2d(or_x,or_y), False, _height, _font)
txt, _color_, rg.Point2d(or_x,or_y), False, _height, _font)
self.text_2d_args.append(d_args)
else:
self.text_2d_args = None
Expand All @@ -94,3 +97,6 @@ def DrawViewportWires(self, args):
display.Draw2dText(*draw_args)
except Exception, e:
System.Windows.Forms.MessageBox.Show(str(e), "script error")

def get_ClippingBox(self):
return Rhino.Geometry.BoundingBox()
Binary file modified ladybug_grasshopper/user_objects/LB Screen Oriented Text.ghuser
Binary file not shown.

0 comments on commit 5d5d310

Please sign in to comment.