All pastes #1042366 Raw Edit

clueless

public text v1 · immutable
#1042366 ·published 2008-06-08 21:49 UTC
rendered paste body
# Filename: IndivStaff.rb# # This is a class representing a single staff# with specific numbers of leger lines above# and below the staff.require 'rubygems'require 'RMagick'class IndivStaff < Magick::ImageList  def initialize    @lineThickness = 2    @lineSpacing = 15    @upperLegers = 0    @lowerLegers = 0    @extraTopSpace = 0    @extraBottomSpace = 0    @staffWidth = 300    @horizontalInset = 30        @staffX = @horizontalInset    @staffY = @extraTopSpace \               + ((@upperLegers + 1) * @lineSpacing)    @paneW = @staffWidth + @horizontalInset * 2    @paneH = @extraTopSpace \           + (@upperLegers + 1) * @lineSpacing \           + 5 * @lineSpacing \           + @lowerLegers * @lineSpacing \           + @extraBottomSpace               super        self.new_image(@paneW, @paneH)        @staff = Magick::Draw.new    @staff.stroke_width(@lineThickness)    @staff.stroke('black')    @staff.fill_opacity(0)    @staff.stroke_opacity(1)  end    def display    5.times \      {        | i | \          @staff.line(            @staffX,             @staffY + @lineSpacing * i,             @staffX + @staffWidth,             @staffY + @lineSpacing * i          )       }    @staff.draw(self)    super  end    def showVars    puts "@staffX = #{@staffX}"    puts "@staffY = #{@staffY}"    puts "@staffWidth = #{@staffWidth}"    puts "@lineSpacing = #{@lineSpacing}"    puts "@upperLegers = #{@lowerLegers}"    puts "@lowerLegers = #{@lowerLegers}"    puts "@extraTopSpace = #{@extraTopSpace}"    puts "@extraBottomSpace = #{@extraBottomSpace}"    puts "@horizontalInset = #{@horizontalInset}"    puts "@lineThickness = #{@lineThickness}"    puts "@paneW = #{@paneW}"    puts "@paneH = #{@paneH}"  end      end