Method: TCPDF#SetLineStyle
- Defined in:
- lib/tcpdf.rb
#SetLineStyle(style) ⇒ Object Also known as: set_line_style
Set line style.
- @param hash :style
-
Line style. Array with keys among the following:
-
width (float): Width of the line in user units.
-
cap (string): Type of cap to put on the line. Possible values are: butt, round, square. The difference between “square” and “butt” is that “square” projects a flat end past the end of the line.
-
join (string): Type of join. Possible values are: miter, round, bevel.
-
dash (mixed): Dash pattern. Is 0 (without dash) or string with series of length values, which are the lengths of the on and off dashes. For example: “2” represents 2 on, 2 off, 2 on, 2 off, …; “2,1” is 2 on, 1 off, 2 on, 1 off, …
-
phase (integer): Modifier on the dash pattern which is used to shift the point at which the pattern starts.
-
color (array): Draw color. Format: array(GREY) or array(R,G,B) or array(C,M,Y,K).
-
- @access public
- @since 2.1.000 (2008-01-08)
7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 |
# File 'lib/tcpdf.rb', line 7927 def SetLineStyle(style) unless style.is_a? Hash return end if !style['width'].nil? width = style['width'] width_prev = @line_width SetLineWidth(width) @line_width = width_prev end if !style['cap'].nil? cap = style['cap'] ca = {'butt' => 0, 'round'=> 1, 'square' => 2} if !ca[cap].nil? @linestyle_cap = ca[cap].to_s + ' J' out(@linestyle_cap) end end if !style['join'].nil? join = style['join'] ja = {'miter' => 0, 'round' => 1, 'bevel' => 2} if !ja[join].nil? @linestyle_join = ja[join].to_s + ' j' out(@linestyle_join); end end if !style['dash'].nil? dash = style['dash'] dash_string = '' if dash != 0 and dash != '' if dash =~ /^.+,/ tab = dash.split(',') else tab = [dash] end dash_string = '' tab.each_with_index { |v, i| if i != 0 dash_string << ' ' end dash_string << sprintf("%.2f", v.to_f) } end phase = 0 @linestyle_dash = sprintf("[%s] %.2f d", dash_string, phase) out(@linestyle_dash) end if !style['color'].nil? color = style['color'] SetDrawColorArray(color) end end |