Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Commit

Permalink
Changed symbols to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
pgtgrly committed Jun 26, 2018
1 parent c68612b commit 9a4ace1
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 102 deletions.
14 changes: 7 additions & 7 deletions examples/RubyPlot/Scatterplot.rb
@@ -1,15 +1,15 @@
require_relative '../../lib/grruby'
g = Rubyplot::Figure.new()

This comment has been minimized.

Copy link
@v0dro

v0dro Jun 30, 2018

Collaborator

I had specifically mentioned to you the conventions to follow when naming files in Ruby. Why are these simple things so difficult for you to follow?

g.title = 'This is Scatter'
g.title = 'This is a Fancy Graph'
@x1 = [1, 2, 3, 4, 5]
@y1 = [10, 29, 30, 40, 50]
@x2 = [2, 16, 4]
@y2 = [10, -5, -10]
g.text_font = :BOOKMAN_LIGHT_ITALIC
g.line! @x1, @y1, line_width: 3, line_color: :RED,
line_type: :LONG_SHORT_DASH,
marker_size: 2, marker_type: :SOLID_HGLASS, marker_color: :BLUE
g.scatter! @x2, @y2, marker_color: :GREEN, marker_size: 2,
marker_type: :SOLID_TRI_UP
g.text_font = :bookman_light_italic
g.line! @x1, @y1, line_width: 2,
line_color: :red, line_type: :long_short_dash,
marker_size: 2
g.scatter! @x2, @y2, marker_color: :green,
marker_size: 2, marker_type: :solid_tri_left
g.save("scatter.bmp")
g.view
174 changes: 87 additions & 87 deletions lib/grruby/tasks/GrFunctionsClasses.rb
Expand Up @@ -252,106 +252,106 @@ def call
# Will define color index, fonts, marker types and other constants
# color index between 1 to 1256. map all prominent ones here
GR_COLOR_INDEX = {
BLACK: 80,
BLUE: 257,
GREEN: 477,
RED: 367
black: 1,
blue: 257,
green: 477,
red: 367
}.freeze

GR_FONTS = {
TIMES_ROMAN: 101,
TIMES_ITALIC: 102,
TIMES_BOLD: 103,
TIMES_BOLD_ITALIC: 104,
HELVETICA: 105,
HELVETICA_OBLIQUE: 106,
HELVETICA_BOLD: 107,
HELVETICA_BOLD_OBLIQUE: 108,
COURIER: 109,
COURIER_OBLIQUE: 110,
COURIER_BOLD: 111,
COURIER_BOLD_OBLIQUE: 112,
SYMBOL: 113,
BOOKMAN_LIGHT: 114,
BOOKMAN_LIGHT_ITALIC: 115,
BOOKMAN_DEMI: 116,
BOOKMAN_DEMI_ITALIC: 117,
NEWCENTURYSCHLBK_ROMAN: 118,
NEWCENTURYSCHLBK_ITALIC: 119,
NEWCENTURYSCHLBK_BOLD: 120,
NEWCENTURYSCHLBK_BOLD_ITALIC: 121,
AVANTGARDE_BOOK: 122,
AVANTGARDE_BOOK_OBLIQUE: 123,
AVANTGARDE_DEMI: 124,
AVANTGARDE_DEMI_OBLIQUE: 125,
PALATINO_ROMAN: 126,
PALATINO_ITALIC: 127,
PALATINO_BOLD: 128,
PALATINO_BOLD_ITALIC: 129,
ZAPFCHANCERY_MEDIUM_ITALIC: 130,
ZAPFDINGBATS: 131
times_roman: 101,
times_italic: 102,
times_bold: 103,
times_bold_italic: 104,
helvetica: 105,
helvetica_oblique: 106,
helvetica_bold: 107,
helvetica_bold_oblique: 108,
courier: 109,
courier_oblique: 110,
courier_bold: 111,
courier_bold_oblique: 112,
symbol: 113,
bookman_light: 114,
bookman_light_italic: 115,
bookman_demi: 116,
bookman_demi_italic: 117,
newcenturyschlbk_roman: 118,

This comment has been minimized.

Copy link
@translunar

translunar Jun 26, 2018

Is this your abbreviation or GR's?

newcenturyschlbk_italic: 119,
newcenturyschlbk_bold: 120,
newcenturyschlbk_bold_italic: 121,
avantgarde_book: 122,
avantgarde_book_oblique: 123,
avantgarde_demi: 124,
avantgarde_demi_oblique: 125,
palatino_roman: 126,
palatino_italic: 127,
palatino_bold: 128,
palatino_bold_italic: 129,
zapfchancery_medium_italic: 130,
zapfdingbats: 131
}.freeze

GR_FONT_PRECISION = {
TEXT_PRECISION_STRING: 0,
TEXT_PRECISION_CHAR: 1,
TEXT_PRECISION_STROKE: 2
text_precision_string: 0,
text_precision_char: 1,
text_precision_stroke: 2
}.freeze

# Marker types
GR_MARKER_SHAPES = {

This comment has been minimized.

Copy link
@translunar

translunar Jun 26, 2018

Something else you can do with symbols is stuff like :*, which is an asterisk symbol. So, in addition to having :asterisk as a key in your dict, you can also have :* as a key, and have it map to the same value.

DOT: 1,
PLUS: 2,
ASTERISK: 3,
CIRCLE: 4,
DIAGONAL_CROSS: 5,
SOLID_CIRCLE: -1,
TRIANGLE_UP: -2,
SOLID_TRI_UP: -3,
TRIANGLE_DOWN: -4,
SOLID_TRI_DOWN: -5,
SQUARE: -6,
SOLID_SQUARE: -7,
BOWTIE: -8,
SOLID_BOWTIE: -9,
HGLASS: -10,
SOLID_HGLASS: -11,
DIAMOND: -12,
SOLID_DIAMOND: -13,
STAR: -14,
SOLID_STAR: -15,
TRI_UP_DOWN: -16,
SOLID_TRI_RIGHT: -17,
SOLID_TRI_LEFT: -18,
HOLLOW_PLUS: -19,
SOLID_PLUS: -20,
PENTAGON: -21,
HEXAGON: -22,
HEPTAGON: -23,
OCTAGON: -24,
STAR_4: -25,
STAR_5: -26,
STAR_6: -27,
STAR_7: -28,
STAR_8: -29,
VLINE: -30,
HLINE: -31,
OMARK: -32
dot: 1,
plus: 2,
asterisk: 3,
circle: 4,
diagonal_cross: 5,
solid_circle: -1,
triangle_up: -2,
solid_tri_up: -3,
triangle_down: -4,
solid_tri_down: -5,
square: -6,
solid_square: -7,
bowtie: -8,
solid_bowtie: -9,
hglass: -10,
solid_hglass: -11,
diamond: -12,
solid_diamond: -13,
star: -14,
solid_star: -15,
tri_up_down: -16,
solid_tri_right: -17,
solid_tri_left: -18,
hollow_plus: -19,
solid_plus: -20,
pentagon: -21,
hexagon: -22,
heptagon: -23,
octagon: -24,
star_4: -25,
star_5: -26,
star_6: -27,
star_7: -28,
star_8: -29,
vline: -30,
hline: -31,
omark: -32
}.freeze

GR_LINE_TYPES = {
SOLID: 1,
DASHED: 2,
DOTTED: 3,
DASHED_DOTTED: 4,
DASH_2_DOT: -1,
DASH_3_DOT: -2,
LONG_DASH: -3,
LONG_SHORT_DASH: -4,
SPACED_DASH: -5,
SPACED_DOT: -6,
DOUBLE_DOT: -7,
TRIPLE_DOT: -8
solid: 1,
dashed: 2,
dotted: 3,
dashed_dotted: 4,
dash_2_dot: -1,
dash_3_dot: -2,
long_dash: -3,
long_short_dash: -4,
spaced_dash: -5,
spaced_dot: -6,
double_dot: -7,
triple_dot: -8
}.freeze
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/rubyplot/PlotClasses/PlotClasses.rb
Expand Up @@ -15,9 +15,9 @@ class Scatter < Base
def initialize(x_coordinates,y_coordinates, marker_size: :default,
marker_color: :default, marker_type: :default)
@tasks = []
marker_color = :BLACK if marker_color == :default
marker_color = :black if marker_color == :default
marker_size = 1 if marker_size == :default
marker_type = :SOLID_CIRCLE if marker_type == :default
marker_type = :solid_circle if marker_type == :default
@tasks.push(SetMarkerColorIndex.new(GR_COLOR_INDEX[marker_color]))
@tasks.push(SetMarkerSize.new(marker_size))
@tasks.push(SetMarkerType.new(GR_MARKER_SHAPES[marker_type]))
Expand All @@ -33,16 +33,16 @@ def initialize(x_coordinates,y_coordinates, line_width: :default,
marker_type: :default)
@tasks = []
if marker_size != :default
marker_color = :BLACK if marker_color == :default
marker_type = :SOLID_CIRCLE if marker_type == :default
marker_color = :black if marker_color == :default
marker_type = :solid_circle if marker_type == :default
@tasks.push(SetMarkerColorIndex.new(GR_COLOR_INDEX[marker_color]))
@tasks.push(SetMarkerSize.new(marker_size))
@tasks.push(SetMarkerType.new(GR_MARKER_SHAPES[marker_type]))
@tasks.push(Polymarker.new(x_coordinates, y_coordinates))
end
line_color = :BLACK if line_color == :default
line_color = :black if line_color == :default
line_width = 1 if line_width == :default
line_type = :SOLID if line_type == :default
line_type = :solid if line_type == :default
@tasks.push(SetLineColorIndex.new(GR_COLOR_INDEX[line_color]))
@tasks.push(SetLineWidth.new(line_width))
@tasks.push(SetLineType.new(GR_LINE_TYPES[line_type]))
Expand Down
7 changes: 5 additions & 2 deletions lib/rubyplot/scripting.rb
Expand Up @@ -97,13 +97,16 @@ def set_axis! # for internal use before drawing
# Make sure that window is set bigger than range figure out how to manage it
SetTextAlign.new(2, 0).call
if @text_font == :default
@text_font = :TIMES_ROMAN
@text_font = :times_roman
end
SetTextFontPrecision.new(GR_FONTS[@text_font],
GR_FONT_PRECISION[:TEXT_PRECISION_STRING]).call
GR_FONT_PRECISION[:text_precision_string]).call
SetCharHeight.new(0.012).call
@y_tick_count = 10 if @y_tick_count == :default
@x_tick_count = 10 if @x_tick_count == :default # 10 ticks by default
@tasks.push(SetLineColorIndex.new(GR_COLOR_INDEX[:black]))
@tasks.push(SetLineWidth.new(1))
@tasks.push(SetLineType.new(GR_LINE_TYPES[:solid]))
Grid.new((@x_range[1] - @x_range[0]).to_f / @x_tick_count,
(@y_range[1] - @y_range[0]).to_f / @y_tick_count,
0, 0, 1, 1).call
Expand Down

0 comments on commit 9a4ace1

Please sign in to comment.