Class: Bioroebe::SVG::Glyph

Inherits:
Object
  • Object
show all
Defined in:
lib/bioroebe/svg/glyph.rb

Overview

Bioroebe::SVG::Glyph

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#glyphsObject (readonly)

Returns the value of attribute glyphs.



40
41
42
# File 'lib/bioroebe/svg/glyph.rb', line 40

def glyphs
  @glyphs
end

Class Method Details

.circle(args) ⇒ Object

#

Glyph.circle

A circular glyph centered on the start of the feature it represents.

Arguments:

:radius = the radius of the circle (default = 10) :fill_color = the fill colour of the Glyph (default = ‘red’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

} #* :stroke = the outline colour of the Glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000 :stroke_width = The width of the outline stroke (default = 1), can be any SVG colour eg rgb(256,0,0) or #FF0000 :style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;” :x = base x coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object :y = base y coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

Will return:

An Array of Bioroebe::SVG::Primitive objects.
#


154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/bioroebe/svg/glyph.rb', line 154

def self.circle(args) 
  args = { 
    :radius => 10, 
    :fill_color => 'red', 
    :stroke => 'black', 
    :stroke_width => 1, 
    :style => ''}.merge!(args)
    args[:x_center] = args[:x]
    args[:y_center] = args[:y]
    [:x, :y].each {|e| args.delete(e)}
  [::Bioroebe::SVG::Primitive.new(:circle, args)]
end

.directed(args) ⇒ Object

#

Glyph.directed

A polygon glyph with a point on the end that represents the features strand and direction.

Arguments: :width = the width of the feature in px :fill_color = the fill colour of the Glyph (default = ‘red’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

}

  • :stroke = the outline colour of the Glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000

  • :stroke_width = The width of the outline stroke (default = 1), can be any SVG colour eg rgb(256,0,0) or #FF0000

  • :style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;”

  • :strand = the strand on which the feature is located. May be ‘+’ or ‘-’

  • :points = the x and y axis coordinates that make up the corners of the polygon, calculated and added by the Bioroebe::SVG::Page object

  • :x = base x coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

  • :y = base y coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

The points of the polygon are calculated form the :x and :y co-ordinates

Returns:

An Array of Bioroebe::SVG::Primitive objects.
#


211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/bioroebe/svg/glyph.rb', line 211

def self.directed(args) #:x, :y, :width :fill, :stroke :stroke_width, :style, :height
  args = {
    :height => 10, 
    :fill_color => 'red', 
    :stroke => 'black', 
    :stroke_width => 1, 
    :style => "fill-opacity:0.4;"}.merge!(args)

    if args[:strand] == '-'
      args[:points] = "#{args[:x]},#{args[:y]} #{args[:x] + args[:width]},#{args[:y]} #{args[:x] + args[:width]},#{args[:y] + args[:height] } #{args[:x]},#{args[:y] + (args[:height])} #{args[:x] - (args[:height] * 0.2)},#{args[:y] + (args[:height]/2)}"
    else
      args[:points] = "#{args[:x]},#{args[:y]} #{args[:x] + args[:width] - (args[:height] * 0.2)},#{args[:y]} #{args[:x] + args[:width]},#{args[:y] + (args[:height]/2) } #{args[:x] + args[:width] - (args[:height] * 0.2)},#{args[:y] + args[:height]} #{args[:x]},#{args[:y] + args[:height]}"

    end
  [::Bioroebe::SVG::Primitive.new(:polygon, args)]
end

.down_triangle(args) ⇒ Object

#

A downward-pointing triangle glyph

Arguments:

:height = the height of the Glyph (default = 10) :fill_color = the fill colour of the Glyph (default = ‘red’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

} #* :stroke = the outline colour of the Glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000

  • :stroke_width = The width of the outline stroke (default = 1), can be any SVG colour eg rgb(256,0,0) or #FF0000

  • :style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;”

  • :x = x coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

  • :y = y coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

Returns:

An Array of Bioroebe::SVG::Primitive objects
#


264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/bioroebe/svg/glyph.rb', line 264

def self.down_triangle(args) #:x, :y, :width :fill, :stroke :stroke_width, :style, :height
  args = {
    
    :height => 10, 
    :fill_color => 'red', 
    :stroke => 'black', 
    :stroke_width => 1, 
    :style => "fill-opacity:0.4;"}.merge!(args)

    args[:points] = "#{args[:x]},#{args[:y]} #{args[:x] + args[:width]},#{args[:y]} #{ args[:x] + (args[:width]/2) },#{(args[:y] + args[:height]) }"
  [::Bioroebe::SVG::Primitive.new(:polygon, args)]
end

.generic(args) ⇒ Object

#

Glyph.generic

A generic glyph is a block of colour that displays no specific directional information attached.

args

  • :height = the height of the Glyph (default = 10)

  • :fill_color = the fill colour of the Glyph (default = ‘red’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

} #* :stroke = the outline colour of the Glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000.

:stroke_width = The width of the outline stroke (default = 1), can be any SVG colour eg rgb(256,0,0) or #FF0000 :x_round = x-axis radius of the ellipse used to round off the corners of the rectangle (default = 1) :y_round = y-axis radius of the ellipse used to round off the corners of the rectangle (default = 1) :style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;” :x = x coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object :y = y coordinate of the feature in pixels, usually

added by the Bioroebe::SVG::Page object

Will return:

An Array of Bioroebe::SVG::Primitive objects.
#


104
105
106
107
108
109
110
111
112
113
114
# File 'lib/bioroebe/svg/glyph.rb', line 104

def self.generic(args)
  args = { 
    :height       => 10, 
    :fill_color   => 'red', 
    :stroke       => 'black',
    :stroke_width => 1,
    :x_round      => 1,
    :y_round      => 1,
    :style        => 'fill-opacity:0.4;'}.merge!(args)
  [::Bioroebe::SVG::Primitive.new(:rectangle, args)]
end

.gradient(gradient) ⇒ Object

#

Glyph.gradient

Sets the the type (linear or radial) and colours for a pre-defined gradient.

Arguments to this method:

gradient = a pre-defined gradient type, one of 
[:red_white_h, :green_white_h, :blue_white_h,
:yellow_white_h, :red_white_radial, :green_white_radial,
:blue_white_radial, :yellow_white_radial ]
#


656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
# File 'lib/bioroebe/svg/glyph.rb', line 656

def self.gradient(gradient)
  type, color = case gradient
  # === :red_white_h
  when :red_white_h
    [:linear, 'red']
  # === :green_white_h
  when :green_white_h
    [:linear, 'green']
  when :blue_white_h
    [:linear, 'blue']
  when :yellow_white_h
    [:linear, 'yellow']
  when :red_white_radial
    [:radial, 'red']
  when :green_white_radial
    [:radial, 'green']
  when :blue_white_radial
    [:radial, 'blue']
  when :yellow_white_radial
    [:radial, 'yellow']
  end
  
  case type # case tag
  # === :linear
  when :linear
    array_stops = [
      {
        :color => color, 
        :offset => 0, 
        :opacity=> 1
      },
      {
        :color => 'white', 
        :offset => 100, 
        :opacity=> 1 
      }
   ]
    {:type => :linear, 
     :id => gradient, 
     :x1 => 0, :y1 => 0, 
     :x2 => 0, :y2 => 100, 
     :stops => array_stops
     }
  # === :radial
  when :radial
    {
     :type => :radial, 
     :id => gradient, 
     :cx => 50, :cy => 50, 
     :r => 50, :fx => 50, :fy => 50, 
     :stops => [ 
       {
         :offset => 0, 
         :color => 'white', 
         :opacity => 0
       },  
       {
         :offset => 100, 
         :color => color, 
         :opacity => 1
       }
      ]
    }
  end
end

.gradientsObject

#

Glyph.gradients

The list of pre-defined gradients. Eight different gradients are presently registered.

Here, we need to know which of its gradients are predefined.

#


633
634
635
636
637
638
639
640
# File 'lib/bioroebe/svg/glyph.rb', line 633

def self.gradients
  [
    :red_white_h,       :green_white_h,
    :blue_white_h,      :yellow_white_h,
    :red_white_radial,  :green_white_radial,
    :blue_white_radial, :yellow_white_radial
  ]
end

.label(args) ⇒ Object

#

Glyph.label

Creates a label Glyph to write text onto.

Arguments:

:text = the text to write :fill = the colour of the text as String, e. g. ‘black’ or ‘red’. :style = the style of writing (“font-family:monospace;”) :x = the co-ordinates of the Glyph for the x-axis :y = the co-ordinates of the Glyph for the y-axis

#


616
617
618
619
620
621
622
623
# File 'lib/bioroebe/svg/glyph.rb', line 616

def self.label(args)
  [::Bioroebe::SVG::Primitive.new(:text, 
                 :text => args[:text], 
                 :x => args[:x], 
                 :y => args[:y], 
                 :fill => 'black', 
                 :style => 'font-family:monospace;')]
end

.scale(args) ⇒ Object

#

Glyph.scale

Glyph for the scale across the top of the rendered page

Arguments to this method:

:start = the start of the scale, usually added by the Bioroebe::SVG::Page object
:stop = the end of the scale, usually added by the Bioroebe::SVG::Page object
:number_of_intervals = the number of tick-marks the scale will marked with
:page_width = the minimum width of the page, usually updated by the Bioroebe::SVG::Page object

Will return:

An Array of Bioroebe::SVG::Primitive objects (of type ‘line’, ‘rectangle’ and ‘text’).

#


570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# File 'lib/bioroebe/svg/glyph.rb', line 570

def self.scale(args)
  first_mark = args[:start]
  last_mark = args[:stop] 
  #(num.to_f / @nt_per_px_x.to_f)
  full_dist = last_mark - first_mark
  interval_width =  full_dist / (args[:number_of_intervals] - 1) 
  array = [::Bioroebe::SVG::Primitive.new(:line, 
                             :stroke => 'black', 
                             :stroke_width => 1, 
                             :x1 => 1, :x2 => args[:page_width],# * 1.1, 
                             :y1 => '20',
                             :y2 => '20')
          ]
  marks = (first_mark..last_mark).step(interval_width).to_a
  px_per_nt = args[:page_width].to_f / full_dist.to_f
  marks.each { |mark|
    x = (mark.to_f - first_mark ).to_f * px_per_nt
    array << ::Bioroebe::SVG::Primitive.new(:rectangle, 
                       :x => x, 
                       :y => 20, 
                       :stroke => 'black', 
                       :stroke_width => 1, 
                       :width => 1, 
                       :height => 5 )
    array << ::Bioroebe::SVG::Primitive.new(:text, 
                       :x => x, 
                       :y => 40, :fill => 'black', 
                       :text => mark, 
                       :style => "font-family:Arial;font-style:italic")
  }
  return array
end

.span(args) ⇒ Object

#

Glyph.span

A line (span) glyph.

Arguments:

:height = the height of the Glyph (default = 10) :fill_color = the fill colour of the Glyph (default = ‘red’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient: {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

} :stroke = the outline colour of the Glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000 :stroke_width = The width of the outline stroke (default = 1) :style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;” :x = x coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object :y = y coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

Returns:

An Array of Bioroebe::SVG::Primitive objects.
#


364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/bioroebe/svg/glyph.rb', line 364

def self.span(args)
  args = {
    :height => 10,
    :fill_color => 'red',
    :stroke => 'black',
    :stroke_width => 1,
    :style => 'fill-opacity:1;'
  }.merge!(args)
  args[:x1] = args[:x]
  args[:x2] = args[:x] + args[:width]
  args[:y1] = args[:y]
  args[:y2] = args[:y]
  [::Bioroebe::SVG::Primitive.new(:line, args)]
end

.transcript(args) ⇒ Object

#

Glyph.transcript

Creates a transcript glyph, which is a composite glyph containing generic glyphs for the exons/utrs and a directed glyph at the end. The glyphs are joined by lines.

Arguments:

:height = the height of the Glyph (default = 10) :utr_fill_color = the fill colour of the utr part of the glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

}

:utr_stroke = the outline colour of the utr part of the glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000 :utr_stroke_width = The width of the outline stroke for the utr part of the glyph (default = 1) :exon_fill_color = the fill colour of the utr part of the glyph (default = ‘red’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients or a custom definition of a gradient

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

}

:exon_stroke = the outline colour of the exon part of the glyph (default = ‘black’) can be any SVG colour eg rgb(256,0,0) or #FF0000 :exon_stroke_width = The width of the outline stroke for the exon part of the glyph (default = 1) :line_color = the colour for the line part that joins the blocks (default = ‘black’) can be any SVG colour eg rgb(256,0,0) or #FF0000 :line_width = the width ffor the line part that joins the blocks (default = 1) :exon_style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;” :utr_style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;” :line_style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;” :block_gaps = gaps between the rendered blocks - calculated internally by Bioroebe::SVG::Page object :gap_marker = style of the line between blocks - either angled or straight :x = x coordinate of the feature in pixels, usually added by the

Bioroebe::SVG::Page object.

:y = y coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

Will return:

An Array of Bioroebe::SVG::Primitive objects.
#


452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# File 'lib/bioroebe/svg/glyph.rb', line 452

def self.transcript(args)
  args = {
    :height => 10, 
    :utr_fill_color => 'black', 
    :utr_stroke => 'black', 
    :utr_stroke_width => 1, 
    :exon_fill_color => 'red', 
    :exon_stroke => 'black', 
    :exon_stroke_width => 1, 
    :line_color => 'black',
    :line_width => 1, 
    :exon_style => 'fill-opacity:0.4;',
    :utr_style  => '',
    :line_style => '',
    :block_gaps => '',
    :gap_marker => ''
  }.merge!(args)

  composite = []
  # ======================================================================= #
  # Draw the utr as terminal element.
  # Tterminal utr is the one with the point on.
  # ======================================================================= #
  unless args[:utrs].empty?
    x, width = args[:strand] == '-' ? args[:utrs].shift : args[:utrs].pop 
    composite += Glyph.directed(:x => x, 
                                :y => args[:y], 
                                :width => width, 
                                :strand => args[:strand], 
                                :height => args[:height], 
                                :fill_color => args[:utr_fill_color], 
                                :stroke =>args[:utr_stroke], 
                                :stroke_width => args[:utr_stroke_width], 
                                :style => args[:utr_style] )
    # Draw the other(s!). 
    args[:utrs].each { |utr|
      composite << ::Bioroebe::SVG::Primitive.new(:rectangle, {
                                                :x => utr.first, 
                                                :width => utr.last, 
                                                :y => args[:y], 
                                                :height => args[:height], 
                                                :fill_color => args[:utr_fill_color], 
                                                :stroke =>args[:utr_stroke], 
                                                :stroke_width => args[:utr_stroke_width], 
                                                :style => args[:utr_style]}
      )
    }
  else # Draw the terminal exon as terminal element.  
    points = nil      
    x,width =  args[:strand] == '-' ? args[:exons].shift : args[:exons].pop 
    composite += Glyph.directed(:x => x, 
                                :y => args[:y], 
                                :width => width, 
                                :strand => args[:strand], 
                                :height => args[:height], 
                                :fill_color => args[:exon_fill_color], 
                                :stroke =>args[:exon_stroke], 
                                :stroke_width => args[:exon_stroke_width], 
                                :style => args[:exon_style] )
  end
  # Draw any remaining exons.
  args[:exons].each { |exon|
      composite << ::Bioroebe::SVG::Primitive.new(:rectangle, {
                                                :x => exon[0], 
                                                :width => exon[1], 
                                                :y => args[:y], 
                                                :height => args[:height], 
                                                :fill_color => args[:exon_fill_color], 
                                                :stroke =>args[:exon_stroke], 
                                                :stroke_width => args[:exon_stroke_width], 
                                                :style => args[:exon_style]} )
  }
  if not args[:block_gaps].empty?
    if args[:gap_marker] == 'angled'
      args[:block_gaps].each do |gap|
        points = "#{gap.first},#{args[:y] + (args[:height]/2) } #{gap.first + (gap.last/2)},#{args[:y]} #{gap.first + gap.last},#{args[:y] + (args[:height]/2)}"
        composite << ::Bioroebe::SVG::Primitive.new(:polyline, {
                                              :points => points, 
                                              :stroke => args[:line_color], 
                                              :stroke_width => args[:line_width], 
                                              :fill => "none", 
                                              :line_style => args[:line_style]})
      end
    else
      # Add line.
      composite << ::Bioroebe::SVG::Primitive.new(
        :line, {
          :x1 => args[:x],
          :x2 => "#{args[:x] + args[:width]}", 
          :y1 => args[:y] + (args[:height]/2), 
          :y2 => args[:y] + (args[:height]/2), 
          :stroke => args[:line_color], 
          :stroke_width => args[:line_width], 
          :line_style => args[:line_style]
        }
      )
    end
  end
  composite
end

.up_triangle(args) ⇒ Object

#

An upward-pointing triangle glyph.

  • :height = the height of the Glyph (default = 10)

  • :fill_color = the fill colour of the Glyph (default = ‘red’), can be any SVG colour eg rgb(256,0,0) or #FF0000, or one of the built in gradient types Bioroebe::SVG::Glyph#gradients

:red_white_h, :green_white_h, :blue_white_h, :yellow_white_h, :red_white_radial, :green_white_radial, :blue_white_radial, :yellow_white_radial

or a custom definition of a gradient {:type => :radial, :id => :custom, :cx => 5, :cy => 5, :r => 50, :fx => 50, :fy => 50,

:stops => [ {
     :offset => 0, 
     :color => 'rgb(255,255,255)', 
     :opacity => 0
     },  {
     :offset => 100, 
     :color => 'rgb(0,127,200)', 
     :opacity => 1
     }, ]

}

  • :stroke = the outline colour of the Glyph (default = ‘black’), can be any SVG colour eg rgb(256,0,0) or #FF0000

  • :stroke_width = The width of the outline stroke (default = 1), can be any SVG colour eg rgb(256,0,0) or #FF0000

  • :style = an arbitrary SVG compliant style string eg “fill-opacity:0.4;”

  • :x = x coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

  • :y = y coordinate of the feature in pixels, usually added by the Bioroebe::SVG::Page object

returns

  • An Array of Bioroebe::SVG::Primitive objects.

#


311
312
313
314
315
316
317
318
319
320
321
# File 'lib/bioroebe/svg/glyph.rb', line 311

def self.up_triangle(args) #:x, :y, :width :fill, :stroke :stroke_width, :style, :height
  args = {
    :height => 10, 
    :fill_color => 'red', 
    :stroke => 'black', 
    :stroke_width => 1, 
    :style => 'fill-opacity:0.4;'
  }.merge!(args)
  args[:points] = "#{args[:x]},#{args[:y] + args[:height]} #{args[:x] + args[:width]},#{args[:y] + args[:height]} #{ args[:x] + (args[:width]/2) },#{args[:y] }"
  [::Bioroebe::SVG::Primitive.new(:polygon, args)]
end