Documentation ¶
Index ¶
- Constants
- func Circle_pt(scale float64, cx float64, cy float64, radius float64, angle float64) *sktools.Point
- func Json_update(dt Drawingthing_i, jblob interface{})
- func Line_style_to_pattern(style int) []int
- func Rotate_pts(rpt *sktools.Point, points []*sktools.Point, angle float64) (new_points []*sktools.Point)
- type Drawingthing_i
- type Dt_bar_graph
- type Dt_base
- func (dt *Dt_base) Contains(x float64, y float64) bool
- func (dt *Dt_base) Get_data() *data_mgr.Data_group
- func (dt *Dt_base) Get_id() string
- func (dt *Dt_base) Get_text() string
- func (dt *Dt_base) Is_kind(kind int) bool
- func (dt *Dt_base) Is_visible(scale float64) bool
- func (dt *Dt_base) Nuke(sketch.Graphics_api)
- func (dt *Dt_base) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_base) Preserve()
- func (dt *Dt_base) Restore()
- func (dt *Dt_base) Rotate(vertex float64, angle float64)
- func (dt *Dt_base) Set_colour(cname string)
- func (dt *Dt_base) Set_data(data_thing interface{})
- func (dt *Dt_base) Set_delta_hw(dheight float64, dwidth float64)
- func (dt *Dt_base) Set_delta_length(length float64)
- func (dt *Dt_base) Set_endpt(x1 float64, y1 float64)
- func (dt *Dt_base) Set_fill(state bool)
- func (dt *Dt_base) Set_fill_colour(cname string)
- func (dt *Dt_base) Set_hw(height float64, width float64)
- func (dt *Dt_base) Set_iscale(increment float64)
- func (dt *Dt_base) Set_length(length float64)
- func (dt *Dt_base) Set_line_style(style int)
- func (dt *Dt_base) Set_origin(new_xo float64, new_yo float64)
- func (dt *Dt_base) Set_rel_origin(delta_xo float64, delta_yo float64)
- func (dt *Dt_base) Set_scale(new_scale float64)
- func (dt *Dt_base) Set_updated(state bool)
- func (dt *Dt_base) Set_vis_threshold(new_t float64)
- func (dt *Dt_base) Set_visibility(state bool)
- func (dt *Dt_base) String() string
- func (dt *Dt_base) Tickle(data interface{})
- func (dt *Dt_base) To_json() (string, error)
- func (dt *Dt_base) Updated() bool
- type Dt_blip
- type Dt_circle
- func (dt *Dt_circle) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_circle) Set_delta_length(dr float64)
- func (dt *Dt_circle) Set_fill(state bool)
- func (dt *Dt_circle) Set_fill_colour(cname string)
- func (dt *Dt_circle) Set_length(r float64)
- func (dt *Dt_circle) Set_line_style(style int)
- func (dt *Dt_circle) String() string
- func (dt *Dt_circle) To_json() (string, error)
- type Dt_clock
- type Dt_graph_base
- func (dtg *Dt_graph_base) Nuke(gc sketch.Graphics_api)
- func (dt *Dt_graph_base) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_graph_base) Preserve()
- func (dt *Dt_graph_base) Restore()
- func (dt *Dt_graph_base) Set_data(data_thing interface{})
- func (dt *Dt_graph_base) Set_scale(scale float64)
- type Dt_image
- func (dt *Dt_image) First_image()
- func (dt *Dt_image) Fix_fnames()
- func (dt *Dt_image) Last_image()
- func (dt *Dt_image) Load_next()
- func (dt *Dt_image) Load_prev()
- func (dt *Dt_image) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_image) Reload(gc sketch.Graphics_api)
- func (dt *Dt_image) Set_data(data_thing interface{})
- func (dt *Dt_image) Set_endpt(x float64, y float64)
- func (dt *Dt_image) Set_iscale(increment float64)
- func (dt *Dt_image) Set_scale(new_scale float64)
- func (dt *Dt_image) String() string
- func (dt *Dt_image) Tickle(idata interface{})
- func (dt *Dt_image) To_json() (string, error)
- type Dt_line
- type Dt_meter
- type Dt_piechart
- func (dt *Dt_piechart) Add_colour(cname string)
- func (dt *Dt_piechart) Add_pctg(p float64)
- func (dt *Dt_piechart) Clear_values(clear_colours bool)
- func (dt *Dt_piechart) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_piechart) Set_delta_radius(dr float64)
- func (dt *Dt_piechart) Set_radius(r float64)
- func (dt *Dt_piechart) String() string
- func (dt *Dt_piechart) To_json() (string, error)
- func (dt *Dt_piechart) XTo_json() string
- type Dt_rect
- func (dt *Dt_rect) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_rect) Set_delta_hw(h float64, w float64)
- func (dt *Dt_rect) Set_fill(state bool)
- func (dt *Dt_rect) Set_fill_colour(cname string)
- func (dt *Dt_rect) Set_line_style(style int)
- func (dt *Dt_rect) Set_size(h float64, w float64)
- func (dt *Dt_rect) String() string
- func (dt *Dt_rect) To_json() (string, error)
- type Dt_reg_polygon
- func (dt *Dt_reg_polygon) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_reg_polygon) Rotate(vertex float64, angle float64)
- func (dt *Dt_reg_polygon) Set_fill(state bool)
- func (dt *Dt_reg_polygon) Set_fill_colour(cname string)
- func (dt *Dt_reg_polygon) Set_iscale(increment float64)
- func (dt *Dt_reg_polygon) Set_line_style(style int)
- func (dt *Dt_reg_polygon) Set_origin(new_xo float64, new_yo float64)
- func (dt *Dt_reg_polygon) Set_scale(new_scale float64)
- func (dt *Dt_reg_polygon) String() string
- func (dt *Dt_reg_polygon) To_json() (string, error)
- type Dt_run_graph
- type Dt_tangle
- func (dt *Dt_tangle) Centre_xy() (x float64, y float64)
- func (dt *Dt_tangle) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_tangle) Set_delta_hb(h float64, b float64)
- func (dt *Dt_tangle) Set_fill(state bool)
- func (dt *Dt_tangle) Set_fill_colour(cname string)
- func (dt *Dt_tangle) Set_line_style(style int)
- func (dt *Dt_tangle) Set_rot_angle(new_angle float64)
- func (dt *Dt_tangle) Set_size(h float64, b float64)
- func (dt *Dt_tangle) String() string
- func (dt *Dt_tangle) To_json() (string, error)
- type Dt_text
- func (dt *Dt_text) Paint(gc sketch.Graphics_api, scale float64)
- func (dt *Dt_text) Set_data(data_thing interface{})
- func (dt *Dt_text) Set_delta_hw(dsize float64, dwidth float64)
- func (dt *Dt_text) Set_fill(state bool)
- func (dt *Dt_text) Set_fill_colour(cname string)
- func (dt *Dt_text) Set_size(size float64, width float64)
- func (dt *Dt_text) String() string
- func (dt *Dt_text) To_json() (string, error)
- type J2dt
Constants ¶
const ( DT_BASE int = iota + 1 // start at 1 so if kind missing from json, the reduling 0 doesn't bugger us up DT_RECT DT_LINE DT_TEXT DT_ARC DT_POLY DT_CIRCLE DT_PIECHART DT_GRAPH DT_BARGRAPH DT_RUNGRAPH DT_TANGLE DT_REGPOLY DT_METER DT_CLOCK DT_IMAGE DT_BLIP )
const ( DT_BGSTYLE_SOLID int = iota DT_BGSTYLE_TRANSP DT_BGSTYLE_OUTLINE )
const ( DS_DEFAULT int = iota // immediately right DS_UP_RIGHT DS_UP_LEFT DS_LOW_LEFT DS_LOW_RIGHT DS_HIDDEN // no text; make first click for quick hide DS_MAX )
data block location relative to triangle
const ( BLIP_KIND_T int = iota // what we draw; directional triangle BLIP_KIND_R // non-directional rectangle )
const ( XL_DEFAULT int = iota // x label styles XL_REVERSE XL_INDEX // index in data rather than recorded sequence number XL_REV_INDEX // reverse index order (data in normal order) XL_TIME // hh:mm:ss XL_REV_TIME // hhLmm:ss but max to min XL_TIME_HM // only hh:mm XL_REV_TIME_HM // only hh:mm but max to min XL_TIME_H // only hh XL_REV_TIME_H // only hh but max to min XL_DATE XL_REV_DATE XL_DATE_TIME // two tiered date and time (hh:mm) XL_REV_DATE_TIME // two tiered date and time (hh:mm) )
const ( Meter_220 int = iota Meter_180 Meter_90 )
const ( Needle_full int = iota // full needle line with box placed under the center point Needle_tic // tic mark with box placed at center point )
const ( Paint_smooth int = iota Paint_jump )
const ( SOLID_LINE int = iota DASHED_LINE DOT_LINE DOT_DOT_DASH_LINE DOT_DASH_LINE )
Variables ¶
This section is empty.
Functions ¶
func Circle_pt ¶
Compute the point (x,y) on a circle assuming a center of cx,cy, angle formed by a straight line running from cx,cy to the point, and radius r. Scale is applied to the x,y and radius values
func Json_update ¶
func Json_update(dt Drawingthing_i, jblob interface{})
Json_update allows a set of updated values to be applied to an object using a json blob containing the fields that should be updated. Any field not contained in the blob should remain as it exists. The specific drawing type may not allow some fields (like the id) to be updated after creation, thus supplying them will have no effect.
func Line_style_to_pattern ¶
Line_style_to_pattern accepts a DT_*_LINE constant and returns an integer pattern that can be used by the underlying graphics construct to set the line drawing style.
Types ¶
type Drawingthing_i ¶
type Drawingthing_i interface { Contains(x float64, y float64) bool Get_data() *data_mgr.Data_group Get_id() string Get_text() string Is_kind(kind int) bool //Is_updated() || Needs_paint() || Is_animated() Nuke(sketch.Graphics_api) Paint(gc sketch.Graphics_api, scale float64) Preserve() Restore() Rotate(vertex float64, angle float64) Set_colour(cname string) Set_data(data interface{}) Set_delta_hw(dheight float64, dwidth float64) Set_delta_length(dlength float64) Set_endpt(x1 float64, y1 float64) Set_fill(state bool) Set_fill_colour(cname string) Set_hw(height float64, width float64) Set_length(length float64) Set_line_style(style int) Set_iscale(new_scale float64) Set_scale(new_scale float64) Set_origin(new_xo float64, new_yo float64) Set_rel_origin(delta_xo float64, delta_yo float64) Set_vis_threshold(new_threshold float64) String() string Tickle(data interface{}) To_json() (string, error) }
The drawing thing interface. All drawingthings must implement these functions.
func Json2ScaledDt ¶ added in v1.2.5
func Json2ScaledDt(jif interface{}, scale float64) (Drawingthing_i, error)
Given a json description of a drawing thing this function unpacks the json to determine the type, then creates the proper struct from the json. Finally it returns a pointer to the interface which then can be used as follows:
dt, err = Json2ScaledDt( json_string, scale ) if err == nil { dt.Set_endpt( x, y ) }
The type of drawing thing is determined by the Kind field in the json which must be one of the DT_* constants. The struct is initialised with a call to the MK_default_*() function, and then the json is 'applied' over top; thus the json needs to supply only the values which override the defaults. For simple things, defaults are likely just all 0s, where as things like graphs the defaults are probalby much more complicated.
func Json2dt ¶
func Json2dt(jif interface{}) (Drawingthing_i, error)
Old proto to keep this change from being a breaking change. Deprecated; use Json2ScaledDt( jif, scale )
type Dt_bar_graph ¶
type Dt_bar_graph struct { Dt_graph_base // contains filtered or unexported fields }
func Mk_default_bar_graph ¶
func Mk_default_bar_graph() *Dt_bar_graph
This generates a bar graph struct with defaults.
func (*Dt_bar_graph) Paint ¶
func (dt *Dt_bar_graph) Paint(gc sketch.Graphics_api, scale float64)
Paint will render the bar graph using the graphics context (gc) passed in.
func (*Dt_bar_graph) To_json ¶
func (dt *Dt_bar_graph) To_json() (string, error)
Return json from the underlying drawing thing.
type Dt_base ¶
type Dt_base struct { Id string // creator assigned id Kind int // one of the DT_* consts that identifies the type Colour string // colur name or rgb string Xo float64 // 'origin' point; upper left x,y or center x,y depending on thing Yo float64 Scale float64 // Different things need scale info for different reasons; it's kept here Rot_angle float64 // rotation, degrees anti-clock with "3:00" being 0 Rot_vertex float64 // the vertex around which rotation happens Visible bool Vis_threshold float64 // scale value below which the thing isn't painted // contains filtered or unexported fields }
Field names must be public as we need to support json (un)packing.
func Mk_drawingthing ¶
Generic (dt) make funciton
func (*Dt_base) Contains ¶
Contains returns true if the x,y coord passed in is within the bounding box of the thing. As a generic function, likely not suitable for many things, true is returned if the point is +/- 5 px in each direction. We expect that most things will override this.
func (*Dt_base) Get_data ¶
func (dt *Dt_base) Get_data() *data_mgr.Data_group
Get_data returns the data group associated with the drawing thing or nil if the drawing thing does not support/use data.
func (*Dt_base) Get_text ¶
Get_text returns the text string associated with the drawing thing or "" if the drawing thing does not support/use data. This is a specialised form of Get_data() which relieves the caller from getting an interface and needing to sort out the type.
func (*Dt_base) Is_kind ¶
Is_kind returns true if the kind passed in (DT_* const) is the same kind as the struct.
func (*Dt_base) Is_visible ¶
Is_visible returns true if the thing's visible setting is true and the current value of scale is >= the vis_threshold value.
func (*Dt_base) Nuke ¶
func (dt *Dt_base) Nuke(sketch.Graphics_api)
Nuke will do any cleanup that is necessary.
func (*Dt_base) Paint ¶
func (dt *Dt_base) Paint(gc sketch.Graphics_api, scale float64)
Paint causes the drawingthing to be rendered using the sketch graphics context which is passed in. Scale is used by drawing things only to determine visibility based on current display scale, and does NOT affect the rendering of the thing.
func (*Dt_base) Preserve ¶
func (dt *Dt_base) Preserve()
Preserve allows the drawingthing to stash away information that it wants to ensure does not change during an update. By default we save/restore just the ID and kind. Each object may decide to do more and implement their own version of this function.
func (*Dt_base) Restore ¶
func (dt *Dt_base) Restore()
Restore allows the drawing thing to restore anything preserved, and/or to force additional computations on the next paint assuming that something affecting the paint (size, location, etc.) has changed. As a default, the ID will be restored and the updated boolean will be marked true.
func (*Dt_base) Rotate ¶
Rotate captures the information needed to rotate the thing when painted. The rotation point is given as a vertex number (1, 2, 3 etc.); rotation is then computed using the coordinates of the vertex. For some drawingthings, the vertex 0 indicates the center, and for some the vertex is ignored as the thing has a single definition of rotation.
func (*Dt_base) Set_colour ¶
Set_colur allows the drawingthing colur to be changed. For most drawingthings this is the outline or stroke colour, and for some drawing things (e.g. graphs) setting the colour likely has no effect. Cname (colouor name) can be a recognised name (e.g. green, red, or orange) or a hex rgb value in the form of either #rrggbb or 0xrrggbb.
func (*Dt_base) Set_data ¶
func (dt *Dt_base) Set_data(data_thing interface{})
Set_data allows a new piece of data to be added to the drawing thing. Data is different for each drawing thing. For a graph data will be a data group or possibly a data set, but for a text thing, the data will likely be a string.
This is a dummy function for things that don't support/use data.
func (*Dt_base) Set_delta_hw ¶
Set_delta_hw allows the height and width of a datathing to be changed by relative value. If the drawing thing supporst the concept of height and width, each are adjusted by adding the delta values passed to this funciton to the current height and width of the thing.
func (*Dt_base) Set_delta_length ¶
Set_delta_length allows the length of a drawing thing to be changed by a relative value. If the drawingthing supports the concept of length, it is adjusted by adding the value passed to this function.
func (*Dt_base) Set_endpt ¶
Set_endpt allows an x,y coordinate to be passed to the drawingthing to set/adjust the thing's concept of an endpoint. For a line, this is the second point and for multi-pointed things this probably has no effect.
func (*Dt_base) Set_fill ¶
Set_fill allows the fill property (boolean) to be turned on or off. Passing true, sets the property and if the drawingthing has a concept of being filled, it will be filled when painted.
func (*Dt_base) Set_fill_colour ¶
Set_fill_colour allows the fill colour to be adjusted. If the fill property is enabled (true) and the drawingthing supports the concept of being filled, the colour given will be used.
func (*Dt_base) Set_hw ¶
Set_hw allows the absolute height and width of the drawing thing to be set provided the drawing thing supports the concept of height and width.
func (*Dt_base) Set_iscale ¶
Set_iscale sets the painting scale for the drawingthing. The value passed is added to the current setting rather than used as an absolute. Some things, like graphs, might need to reset themselves if the scale is changed. See note about scale in drawingthing.go.
func (*Dt_base) Set_length ¶
Set_hw allows the absolute length of the drawing thing to be set provided the drawing thing supports the concept of length.
func (*Dt_base) Set_line_style ¶
Set_line_style allows the line style (e.g. solid, dashed) to be set for those drawingthings which support it.
func (*Dt_base) Set_origin ¶
Set_origin allows the origin point to be changed effectively moving the object in the drawing plane. The internal updated flag is set as for some drawing things the change to the origin may cause a recomputation of other vertices.
func (*Dt_base) Set_rel_origin ¶
Set_rel_origin changes the origin for the DT by adding the delta values to the current origin values.
func (*Dt_base) Set_scale ¶
Set_scale sets the painting scale for the drawingthing. Some things, like graphs, might need to reset themselves if the scale is changed. See note about scale in drawingthing.go.
func (*Dt_base) Set_updated ¶
Set_updated toggles the internal updated flag.
func (*Dt_base) Set_vis_threshold ¶
Set_vis_threshold sets the scale threshold below which a drawing thing will not be painted. If the threshold is set to 2.0, then when the current scale is < 2.0 the effect will be to hide the thing.
func (*Dt_base) Set_visibility ¶
Set_visibility allows the visible flag to be toggled. If the thing isn't visible it shouldn't paint.
func (*Dt_base) String ¶
String implements the stringer interface allowing the object to be passed to fmt.*() functions etc. We get lazy and just bang the struct into json.
func (*Dt_base) Tickle ¶
func (dt *Dt_base) Tickle(data interface{})
A tickle from the outside world. data contains needed information in a format that is unique to the underlying thing.
type Dt_blip ¶
type Dt_blip struct { Dt_base // common fields and functions Tangle *Dt_tangle Rect *Dt_rect Raw_txt string // raw text for to_* functions Tcolour string // triangle outline colour Tfill string // triangel fill colour Txt_size float64 // size of the text to paint Heading float64 // the rotation (degrees from 'north') Alt float64 // alt in meters Crumbs bool // true if we are leaving droppings // contains filtered or unexported fields }
func Mk_blip ¶
Mk_blip creates a blip given the coordinates and text string. Text is assumed to be a single string with pipe (|) separated fields.
func (*Dt_blip) Contains ¶ added in v1.2.0
Contains returns true if the point passed is in the triangle or in the bounding box of the text.
func (*Dt_blip) Paint ¶
func (dt *Dt_blip) Paint(gc sketch.Graphics_api, scale float64)
Paint draws the blip (triangle and text). If we were updated, we must first update the drawing things that we manage before we can paint them.
If crumbs are on, then we will paint the breadcrumb trail (droppings) starting with didx and wrapping to didx-1.
func (*Dt_blip) Preserve ¶
func (dt *Dt_blip) Preserve()
We override preserve and restore to capture the orign values before an update. If they change, then we update the droppings on restore.
func (*Dt_blip) Restore ¶
func (dt *Dt_blip) Restore()
If the origin changed, update the droppings. We also need to ensure that id and kind don't change.
type Dt_circle ¶
type Dt_circle struct { Dt_base // common fields and functions Fill_style int Fcolour string // fill colour Radius float64 Line_style int }
func Mk_circle ¶
func Mk_circle(xo float64, yo float64, radius float64, outline_colour string, fill bool, fill_colour string) *Dt_circle
Allow for easy programatic creation of a circle.
func Mk_def_circle ¶
func Mk_def_circle() (dt *Dt_circle)
Mk_def_circle creates a default circle struct.
func (*Dt_circle) Paint ¶
func (dt *Dt_circle) Paint(gc sketch.Graphics_api, scale float64)
Draw the circle with it's current folour outline, and fill style. If the visible attribute for the object is false, then it is not rendered.
func (*Dt_circle) Set_delta_length ¶
Adjust the current legngth (radius) by the delta value dr
func (*Dt_circle) Set_fill_colour ¶
Set the fill colour to use when the circle fill state is true.
func (*Dt_circle) Set_length ¶
Set the length (radius) to the given value r
func (*Dt_circle) Set_line_style ¶
Set_line_style allows the style of the outline to be changed after the thing has been created. Expects one of the *_LINE constants.
type Dt_clock ¶
type Dt_clock struct { Dt_base // common fields and functions Font string // Sans, Serif, are also legit Size int Weight int // stroke weight (bold-ness) Format string // GO style time format for output Zulu bool Tz string // contains filtered or unexported fields }
func Mk_clock ¶
func Mk_clock(xo float64, yo float64, size float64, font string, colour string, tfmt string) *Dt_clock
Mk_clock allows an instance of the clock struct to be created directly rather than creating a generic drawing thing.
func Mk_default_clock ¶
func Mk_default_clock() *Dt_clock
Mk_default_clock makes a simple clock structure onto which a json string can be 'overlaid'.
func (*Dt_clock) Paint ¶
func (dt *Dt_clock) Paint(gc sketch.Graphics_api, scale float64)
Paint draws the clock according to the information in the struct.
func (*Dt_clock) Set_delta_hw ¶
h and w are delta values which are added to the current size. Currently delth width is ignored.
type Dt_graph_base ¶
type Dt_graph_base struct { Dt_base // common fields and functions Height float64 // overall height,width of the 'sub page' (before scaling) Width float64 ScaledH float64 // height/width after scaling ScaledW float64 Gheight float64 // height width of the plot area Gwidth float64 Orig_x float64 // the offset of the origin on the sub page Orig_y float64 X_disp float64 // displacment (up) from the origin that the xaxis should be written Ymargin int // y labels on left are written starting this distance to the left of the y axis Yrmargin int // right y title spaced over this many points from the right y axis Y_split int // number of sections we split in y direction X_split int // number of splits in x dir Label_size int // size of x/y label text Subtitle_size int // size of axis title text Title_size int // size of main title // titles are written 5 pts to the inside of the respective subpage edge Title string // main graph title X_title string // title under x labels Y_ltitle string // title on left Y_rtitle string // title on right Title_font string Subtitle_font string Data *data_mgr.Data_group Grid_colour string // colour for the grid Axis_colour string // colour for the axis Bg_colour string // colour for the plot area background Sp_colour string // colour for the sub page (background to the whole graph area) Title_colour string // main title colour Subtitle_colour string // colur of x/y axis titles Label_colour string // x and y axis labels X_lab_style int // style x labels to be written in Scale_fmt string // format string (e.g. %.0f) used on axis labels Show_xgrid bool Show_ygrid bool Show_left_scale bool // show the scale on the left axis Show_right_scale bool // show the scale on the right axis Show_xlabels bool // show labels along x axis Show_left_yaxis bool // allow painting of either y axis Show_right_yaxis bool Right_min float64 // x-axis value for right y axis Right_max float64 // top value for right y axis Left_min float64 // x-axis value for left y axis Left_max float64 // top value for left y axis Left_round float64 // top value to round to (e.g. 100 or 1000) Sp_created bool // indicates whether or not the subpage has been created IsScaled bool // true if scaled height/width should be used // contains filtered or unexported fields }
Form base class xo,yo define the lower left of the working area. The coordinates of the origin of the graph are offset from this. Height and Width are the overall 'clip area,' with gheight and gwidth used for the graph itself.
It might seem silly to define both the origin offset from the lower left of the graph xo,yo and a Y margin, but the ymargin is used to place the y labels such that they are not placed up against the left edge of the drawing area. Y-margin is the distance to the left of the y axis, not to the right of the drawing area left edge.
func Mk_base_graph ¶
func Mk_base_graph(xo float64, yo float64, height float64, width float64, gh float64, gw float64) *Dt_graph_base
------ public functions ------------------------------------------
Create a base graph with defaults. This graph probalby has no value other than a place holder as it has no real paint function associated with it.
func (*Dt_graph_base) Nuke ¶
func (dtg *Dt_graph_base) Nuke(gc sketch.Graphics_api)
Nuke will clean up the subpage associated with the drawing thing; if it exists. State is saved such that the active page remains the same. The drawing thing is assumed to be on the curently selected page, or on the root page.
func (*Dt_graph_base) Paint ¶
func (dt *Dt_graph_base) Paint(gc sketch.Graphics_api, scale float64)
Paint will paint the base graph. Probably useless as there is no data style associated with the base graph and thus nothing is plotted.
func (*Dt_graph_base) Preserve ¶
func (dt *Dt_graph_base) Preserve()
Preserve allows the drawingthing to stash away information that it wants to ensure does not change during an update. By default we save/restore just the ID and kind. Each object may decide to do more and implement their own version of this function.
func (*Dt_graph_base) Restore ¶
func (dt *Dt_graph_base) Restore()
Restore allows the drawing thing to restore anything preserved, and/or to force additional computations on the next paint assuming that something affecting the paint (size, location, etc.) has changed. As a default, the ID will be restored and the updated boolean will be marked true.
func (*Dt_graph_base) Set_data ¶
func (dt *Dt_graph_base) Set_data(data_thing interface{})
Set data does one of two things depending on what is passed in:
If the data_thing is a data_manger group or set, it attaches a data set to the graph. The data set is used when the paint function is called, but otherwise is assumed to be managed outside of the drawing thing environment.
When the data_thing is a string, it is assumed to conain information to apply to the already attached data group. The string is assumed to have information of the form:
<set>:<seq>,<value> [<set>:<seq,<value>] ...
The sequence value allows for both x,y plotting as well as either sequence series run/bar graphis or time oriented where seq is a unix timestamp. In any case it is treated as a float64.
func (*Dt_graph_base) Set_scale ¶ added in v1.2.4
func (dt *Dt_graph_base) Set_scale(scale float64)
Set the desired scale. This applies only to the overall height/width used to manage the subpage. All other aspects of scaling the actual paint process are handled in the GC.
type Dt_image ¶
type Dt_image struct { Dt_base // common fields and functions Height float64 // bounding box that image will be scaled to fit in Width float64 Fname string // where the image lives (.jpg/.png supported) Rfreq int64 // seconds between reloads Border bool // causes a border to be drawn round the image // contains filtered or unexported fields }
Right now images are expected to be on disk, but that could change. The filename can be a single file name, or a list of file names which are separated by semicolons. These filenames can be cycled through with a call to the Load_next() or Load_prev() functions. Each filename can be a sublist of names, separated by commas. These sublists are treated as a single, stacked, image; the images are combined (with the first in the list being the "base") before painting.
Public names are captured when the struct is converted to json.
func Mk_image ¶
func Mk_image(gc sketch.Graphics_api, x0 float64, y0 float64, fname string, height float64, width float64, colour string, reload int64, border bool) *Dt_image
Mk_dt_image creates an image which will be positioned at the given point and scaled to fit proportionally in the bounding box described by height and width. If border is true, a rectangle outline will be painted round the image using the given colour. The image will be reloaded every 'reload' seconds.
The image file name may be a single filename, or a SEMICOLON separater list of filenames. Each filename in the list, or the single file name, may itself be a (sub)list of images. If the filename is a sublist, then it is assumed that these images are to be 'stacked' from first to last with the first being the 'base' image and each successive image layered or stacked on top. Black pickes in the stacked images are not written, thus those areas become 'transparant."
If a list of filenames is given, the first filename is slected and loaded. The user application may invoke the Load_next() or Load_prev() functions to cause a different file to be used.
func (*Dt_image) First_image ¶
func (dt *Dt_image) First_image()
First_image selects the first file in the list, when multiple given, and causes it to be reloaded.
func (*Dt_image) Fix_fnames ¶
func (dt *Dt_image) Fix_fnames()
Fix_fnames will take an object created with json that might have semicolon separated filenames in fname, and split them up as is needed to load.
func (*Dt_image) Last_image ¶
func (dt *Dt_image) Last_image()
Last_image selects the last file in the list, when multiple given, and causes it to be reloaded.
func (*Dt_image) Load_next ¶
func (dt *Dt_image) Load_next()
Load_next selects the next file in the list, when multiple given, and causes it to be reloaded.
func (*Dt_image) Load_prev ¶
func (dt *Dt_image) Load_prev()
Load_prev selects the previous file from the list, when multiple given, and causes it to be reloaded.
func (*Dt_image) Paint ¶
func (dt *Dt_image) Paint(gc sketch.Graphics_api, scale float64)
Paint will display the image. If the time to reload has passed, then a goroutine will be scheduled to reload the image which will be painted the first time this function is called after the load has completed.
func (*Dt_image) Reload ¶
func (dt *Dt_image) Reload(gc sketch.Graphics_api)
Reload is a function that can be run as a goroutine which will casue the image to be reloaded asynch. The image is loaded into the new-image component of the struct. When it is loaded, and ok, the swap flag is toggled allowing paint to move and use it.
Image is the only drawing thing that needs/uses scale to actually scale something rather than just to control visibility. This is because the image is scaled as it is loaded, not as it is painted, thus it cannot be adjusted at time of render.
func (*Dt_image) Set_data ¶
func (dt *Dt_image) Set_data(data_thing interface{})
Set_data allows a new filename to be supplied (optional) and causes an immediate reload of the image from the file. Data is a string or pointer to string of the form:
[colour=<colour-value>,]{filename | -}
If colour is supplied, then the outline colour is set to true and the colour is set to the supplied value. If filename is supplied, then the filename is replaced with the one given. Filename may be a dash (-) to indicate no change to the source of the image.
Regardless of colour or filename change we schedule an update of the image unless one is already in progress.
func (*Dt_image) Set_iscale ¶
Set_scale sets the painting scale for the image by adding the passed value to the current setting. We look to see if the new scale is different than the old scale and if it is we force a reload.
func (*Dt_image) Set_scale ¶
Set_scale sets the painting scale for the image. We look to see if the new scale is different than the old scale and if it is we force a reload.
type Dt_line ¶
func Mk_line ¶
Mk_dt_line creates a line with the given end points and returns a pointer to the structure.
type Dt_meter ¶
type Dt_meter struct { Dt_base // common fields and functions Paint_style int // PS_ constants (smooth/jump) Radius float64 // amuont the peak is shifted in the y direction from yo Needle_style int Needle_colour string Text_colour string Text_size int // text size; if 0 we use preset values Arc_colour string Arc_type int // Meter_* constants Tic_marks bool Value_box bool // if false, no digital value is displayed Center_box bool // for 220/90 center if true and in needle tic. if false placed below Smooth_factor float64 // number of calls required to move 10% Smooth_step float64 // computed smoothing step for the current movement Val_cur float64 // current value (min <= v <= max) Val_target float64 // target value (if smooth scrolling to transition current to target) Val_min float64 // value range Val_max float64 // contains filtered or unexported fields }
func Mk_default_meter ¶
func Mk_default_meter() (dt *Dt_meter)
Mk_def_meter creates a default meter struct.
func (*Dt_meter) Paint ¶
func (dt *Dt_meter) Paint(gc sketch.Graphics_api, scale float64)
Paint draws the meter according to the information in the struct.
func (*Dt_meter) Preserve ¶
func (dt *Dt_meter) Preserve()
Preerve saves the fields which may not be updated/overlaid. The generic Json_update() function in drawingthings.go will invoke this before overlaying the struct with caller json, and then will invoke retore() to restore the preserved values. This funciton is needed as the current value must be preserved when smooth adjusting the meter.
func (*Dt_meter) Restore ¶
func (dt *Dt_meter) Restore()
Restore copies presrved values back into the main struct. This allows us to protect some fields from being overlaid with user data. Id, Kind and Val_cur fields are preserved/restored.
func (*Dt_meter) Set_data ¶
func (dt *Dt_meter) Set_data(data_thing interface{})
Set_data sets the target value for the meter. If jump positioning is selected for the meter, then the needle will be shown in this position on the next paint. If smooth needle positioning is selected, then the needle will be moved in steps between the current position to the supplied target position. Target will be constrained between the current meter max and min values.
type Dt_piechart ¶
type Dt_piechart struct { Dt_base // common fields and functions Sep_colour string // the colour to use to separate pieces of the pie Fill_style int Fcolours []string // fill colours, one per slice Pcts []float64 // percentages, one per slice Radius float64 }
func Mk_piechart ¶
func Mk_piechart(xo float64, yo float64, radius float64, outline_colour string, sep_colour string, pcts []float64, fillcolours []string) *Dt_piechart
Programatic creation of a pie chart. The colours an percentages can be a single element array, and added to over the lifespan of the object.
func Mk_piechart_values ¶
func Mk_piechart_values(xo float64, yo float64, radius float64, outline_colour string, sep_colour string, values []float64, fillcolours []string) *Dt_piechart
Create a pie chart given an array of values which are normalised into percentages of the overall total. Fill colours can be supplied on the call, or added later.
func (*Dt_piechart) Add_colour ¶
func (dt *Dt_piechart) Add_colour(cname string)
Add a fill colour value to the array. Cname may be a supported colour name (e.e. yellow) or a hex rgb value of the form #rrggbb or 0xrrggbb.
func (*Dt_piechart) Add_pctg ¶
func (dt *Dt_piechart) Add_pctg(p float64)
Add a percentage value to the array.
func (*Dt_piechart) Clear_values ¶
func (dt *Dt_piechart) Clear_values(clear_colours bool)
Clear the values and optionally the colours.
func (*Dt_piechart) Paint ¶
func (dt *Dt_piechart) Paint(gc sketch.Graphics_api, scale float64)
Draw the chart with it's current folours, and outline. If the visible attribute for the object is false, then it is not rendered.
func (*Dt_piechart) Set_delta_radius ¶
func (dt *Dt_piechart) Set_delta_radius(dr float64)
Adjust the current radius by the delta value dr
func (*Dt_piechart) Set_radius ¶
func (dt *Dt_piechart) Set_radius(r float64)
Set the radius to the given value r
func (*Dt_piechart) String ¶
func (dt *Dt_piechart) String() string
func (*Dt_piechart) To_json ¶
func (dt *Dt_piechart) To_json() (string, error)
To_json will generate a json string from this struct.
func (*Dt_piechart) XTo_json ¶
func (dt *Dt_piechart) XTo_json() string
type Dt_rect ¶
type Dt_rect struct { Dt_base // common fields and functions Fill_style int Fcolour string // fill colour Height float64 Width float64 Line_style int }
func Mk_rect ¶
func Mk_rect(xo float64, yo float64, height float64, width float64, outline_colour string, fill bool, fill_colour string) *Dt_rect
Mk_rect allows an instance of the rect struct to be created directly rather than creating a generic drawing thing. Xo,Yo is upper left corner.
func (*Dt_rect) Paint ¶
func (dt *Dt_rect) Paint(gc sketch.Graphics_api, scale float64)
Paint draws the rectangle according to the information in the struct.
func (*Dt_rect) Set_delta_hw ¶
h and w are delta values which are added to the current size.
func (*Dt_rect) Set_fill_colour ¶
Set the fill colour to use when the rectangle fill state is true.
func (*Dt_rect) Set_line_style ¶
Set_line_style allows the style of the outline to be changed after the thing has been created. Expects one of the *_LINE constants.
type Dt_reg_polygon ¶
type Dt_reg_polygon struct { Dt_base // common fields and functions Fill_style int Fcolour string // fill colour Points []*sktools.Point Radius float64 Sides int Line_style int }
func Mk_def_poly ¶
func Mk_def_poly() (dt *Dt_reg_polygon)
Mk_def_poly creates a polygon struct with default (less than useful) values.
func Mk_reg_poly ¶
func Mk_reg_poly(xo float64, yo float64, radius float64, sides int, outline_colour string, fill bool, fill_colour string) *Dt_reg_polygon
Mk_rect allows an instance of the regular poly struct to be created directly rather than creating a generic drawing thing.
func (*Dt_reg_polygon) Paint ¶
func (dt *Dt_reg_polygon) Paint(gc sketch.Graphics_api, scale float64)
Paint draws the polygon according to the information in the struct.
func (*Dt_reg_polygon) Rotate ¶
func (dt *Dt_reg_polygon) Rotate(vertex float64, angle float64)
Rotate captures the information needed to rotate the triangle when painted. The rotation point is given as a vertex number (1, 2, 3 etc.) and to rotate round the centre of the triangle, the special vertex of 0 is used.
Some drawing things might treat a vertex of 1.5 to mean halfway between the first and second vertex, and others might ignore the fractional part all together.
func (*Dt_reg_polygon) Set_fill ¶
func (dt *Dt_reg_polygon) Set_fill(state bool)
Set the fill value. If true passed, then rectangle will be filled
func (*Dt_reg_polygon) Set_fill_colour ¶
func (dt *Dt_reg_polygon) Set_fill_colour(cname string)
Set the fill colour to use when the rectangle fill state is true.
func (*Dt_reg_polygon) Set_iscale ¶
func (dt *Dt_reg_polygon) Set_iscale(increment float64)
Set_iscale will set the drawing scale of the poligyon by adding the increment passed in to the current value.
func (*Dt_reg_polygon) Set_line_style ¶
func (dt *Dt_reg_polygon) Set_line_style(style int)
Set_line_style allows the style of the outline to be changed after the thing has been created. Expects one of the *_LINE constants.
func (*Dt_reg_polygon) Set_origin ¶
func (dt *Dt_reg_polygon) Set_origin(new_xo float64, new_yo float64)
Set a new orign for the drawing thing.
func (*Dt_reg_polygon) Set_scale ¶
func (dt *Dt_reg_polygon) Set_scale(new_scale float64)
Set_scale will set the drawing scale of the poligyon to the value passed in.
func (*Dt_reg_polygon) String ¶
func (dt *Dt_reg_polygon) String() string
func (*Dt_reg_polygon) To_json ¶
func (dt *Dt_reg_polygon) To_json() (string, error)
To_json will generate a json string from this struct.
type Dt_run_graph ¶
type Dt_run_graph struct { Dt_graph_base Line_styles []int // line style; one for each line }
The struct used to manage the run graph. Line styles from the array are applied in order. If less styles are provided than data sets, the styles wrap. If no line styles are provided the default is a solid line.
func Mk_default_run_graph ¶
func Mk_default_run_graph() *Dt_run_graph
This generates a run graph struct with defaults. Likely this is used to create a graph overwhich a subset of json is used to populate only the desired changes to the default.
func (*Dt_run_graph) Paint ¶
func (dt *Dt_run_graph) Paint(gc sketch.Graphics_api, scale float64)
Paint will render the run graph using the graphics context (gc) passed in.
func (*Dt_run_graph) To_json ¶
func (dt *Dt_run_graph) To_json() (string, error)
Return json from the underlying drawing thing.
type Dt_tangle ¶
type Dt_tangle struct { Dt_base // common fields and functions Fill_style int Fcolour string // fill colour Height float64 // amuont the peak is shifted in the y direction from yo Base_len float64 Rise float64 // rise of the second point from the pase y Peak_offset float64 // amount the peak is shifted in the x direction from xo Align_centre bool // if true, the centre of the triangle is positioned at Xo,Yo. Adjusted bool // set if adjusted x,y has been set Adjusted_xo float64 // adjusted lower left for quick painting Adjusted_yo float64 Line_style int // *_LINE consts Points []*sktools.Point // drawing points; scaled and rotated }
func Mk_def_tangle ¶
func Mk_def_tangle() (dt *Dt_tangle)
Mk_def_tangle creates a default triangle struct.
func Mk_tangle ¶
func Mk_tangle(xo float64, yo float64, height float64, base_len float64, peak_off float64, align_centre bool, outline_colour string, fill bool, fill_colour string) *Dt_tangle
Mk_tangle creates a triangle given the coordinates and:
the length of the base the offset (x) of the peak the height the rise off of the base y for the second point
If align center is true, then the centre of the triangle is positioned at Xo,Yo rather than the leftmost vertex.
func (*Dt_tangle) Centre_xy ¶
Centre_xy computes the centroid center of the triangele; the intersection of the three lines from each of the vertices to the opposite edge's midpoint.
We do this by computing two of the lines' slopes (m1 and m2), then computing 'b' for the line which isn't from Xo,Yo. Given ths slopes and the y intercept of the second line, we can compute the center's x value (xc) which can be plugged back into one of the equations to compute yc.
The returned xc,yc are NOT ajusted based on the current Xo,Yo values, but are deltas:
-add to Xo,Yo to find the center point in real coordinates - subtract from Xo,Yo to find the lower left of the triangle for painting when positioning by the center.
func (*Dt_tangle) Paint ¶
func (dt *Dt_tangle) Paint(gc sketch.Graphics_api, scale float64)
Paint draws the triangle according to the information in the struct.
func (*Dt_tangle) Set_delta_hb ¶
Set_delta_hb changes the height and base length by a delta value (h and b).
func (*Dt_tangle) Set_fill_colour ¶
Set_fill_colour replaces the current colour with the colour passed in.
func (*Dt_tangle) Set_line_style ¶
Set_line_style allows the style of the outline to be changed after the thing has been created. Expects one of the *_LINE constants.
func (*Dt_tangle) Set_rot_angle ¶
Set_rot_angle allows other objects to set the rotation angle.
type Dt_text ¶
type Dt_text struct { Dt_base // common fields and functions Text string // the 'data' to display Font string // Sans, Serif, are also legit Size int Weight int // stroke weight (bold-ness) Ital bool Fill_style int // ability to fill is a future thing Fcolour string // fill colour }
func Mk_text ¶
func Mk_text(xo float64, yo float64, size float64, font string, outline_colour string, fill bool, fill_colour string, text string) *Dt_text
Mk_text allows an instance of the text struct to be created directly rather than creating a generic drawing thing.
func (*Dt_text) Paint ¶
func (dt *Dt_text) Paint(gc sketch.Graphics_api, scale float64)
Paint draws the text according to the information in the struct.
func (*Dt_text) Set_data ¶
func (dt *Dt_text) Set_data(data_thing interface{})
Set_data allows the text, and text colour, associated with this dt to be changed. A string is accepted, and if it begins with "colourxxxxxx," then the characters up to the comma are used to set the colour. The xxxx can be a colour name or a hex rgb value if proceeded with a hash.
func (*Dt_text) Set_delta_hw ¶
h and w are delta values which are added to the current size. Currently delth width is ignored.
func (*Dt_text) Set_fill_colour ¶
Set the fill colour to use when the text fill state is true.