def draw_delta_bar(self, time_delta, speed_delta, bar_moves):
    # Color
    if config.BAR_COLORS_OLD:
      bar_color = self._delta_stripe_color_old(speed_delta)
    else:
      bar_color = self._delta_stripe_color(speed_delta)
    ac.glColor4f(*bar_color)

    # Calculations
    clamped_time_delta = self._clamp_time_delta(time_delta)
    delta_stripe_width = int((abs(clamped_time_delta) * config.BAR_SCALE))
    delta_stripe_rect_width = delta_stripe_width
    should_draw_cap = delta_stripe_width > config.BAR_INNER_RECT_MAX_WIDTH

    if time_delta < 0:
      delta_rect_origin_x = config.BAR_WIDTH_HALF
      delta_label_position = delta_rect_origin_x + delta_stripe_width
    else:
      delta_rect_origin_x = config.BAR_WIDTH_HALF - delta_stripe_width
      delta_label_position = delta_rect_origin_x

    # Draw rounded cap and modify width and origin
    if should_draw_cap:
      delta_stripe_rect_width = config.BAR_INNER_RECT_MAX_WIDTH
      if time_delta > 0:
        delta_rect_origin_x = config.BAR_WIDTH_HALF - delta_stripe_rect_width

      self._draw_delta_stripe_cap(time_delta, delta_rect_origin_x, delta_stripe_width)

    # Draw stripe rect
    if delta_stripe_width > 0:
      ac.glQuad(delta_rect_origin_x, config.BAR_INNER_Y, delta_stripe_rect_width, config.BAR_INNER_HEIGHT)

    # Delta label
    self._update_delta_label(time_delta, delta_label_position, bar_moves)
Exemple #2
0
  def draw_delta_bar(self, time_delta, speed_delta, bar_moves):
    # Color
    bar_color = self._delta_stripe_color(speed_delta)
    ac.glColor4f(*bar_color)

    # Calculations
    clamped_time_delta = self._clamp_time_delta(time_delta)
    delta_stripe_width = int((abs(clamped_time_delta) * config.BAR_SCALE))
    delta_stripe_rect_width = delta_stripe_width
    should_draw_cap = delta_stripe_width > config.BAR_INNER_RECT_MAX_WIDTH

    if time_delta < 0:
      delta_rect_origin_x = config.BAR_WIDTH_HALF
      delta_label_position = delta_rect_origin_x + delta_stripe_width
    else:
      delta_rect_origin_x = config.BAR_WIDTH_HALF - delta_stripe_width
      delta_label_position = delta_rect_origin_x

    # Draw rounded cap and modify width and origin
    if should_draw_cap:
      delta_stripe_rect_width = config.BAR_INNER_RECT_MAX_WIDTH
      if time_delta > 0:
        delta_rect_origin_x = config.BAR_WIDTH_HALF - delta_stripe_rect_width

      self._draw_delta_stripe_cap(time_delta, delta_rect_origin_x, delta_stripe_width)

    # Draw stripe rect
    if delta_stripe_width > 0:
      ac.glQuad(delta_rect_origin_x, config.BAR_INNER_Y, delta_stripe_rect_width, config.BAR_INNER_HEIGHT)

    # Delta label
    self._update_delta_label(time_delta, delta_label_position, bar_moves)
    def draw(self, data, delta_t: float) -> None:
        # Calculates the current suspension travel in percentage.
        travel = (data.susp_t / data.susp_m_t) if data.susp_m_t > 0.0 else 0.5

        # Checks the correct color.
        if travel > 0.95 or travel < 0.05:
            self._back.color = Colors.red
        elif travel > 0.90 or travel < 0.1:
            self._back.color = Colors.yellow
        else:
            self._back.color = Colors.blue if data.susp_v else Colors.white
        self._draw(Suspension.texture_id)

        # Initial padding is 10x44
        rect = copy.copy(self._box.rect)
        rect[0] += 10 * self.__mult
        rect[1] += 44 * self.__mult
        rect[2] -= 20 * self.__mult
        rect[3] -= 88 * self.__mult  # 100%

        # Why there is negative and above maximum numbers, KUNOS???
        rect[3] = min(rect[3], max(0.0, rect[3] * (1.0 - travel)))

        ac.glColor4f(*self._back.color)
        ac.glQuad(*rect)
Exemple #4
0
    def draw(self, data):
        # Calculates the current suspension travel in percentage.
        travel = (data.susp_t / data.susp_m_t) if data.susp_m_t > 0.0 else 0.5

        # Keeps only the last 60 values.
        self.__last_values.append(travel)
        self.__last_values = self.__last_values[-60:]

        # Use the last 60 values to check if the suspension was maxed/'mined' out.
        maxed = max(self.__last_values)
        mined = min(self.__last_values)
        if maxed > 0.95 or mined < 0.05:
            self._back.color = Colors.red
        elif maxed > 0.90 or mined < 0.1:
            self._back.color = Colors.yellow
        else:
            self._back.color = Colors.blue if data.susp_v else Colors.white
        self._draw(Suspension.texture_id)

        # Initial padding is 10x44
        rect = copy.copy(self._box.rect)
        rect[0] += 10 * self.__mult
        rect[1] += 44 * self.__mult
        rect[2] -= 20 * self.__mult
        rect[3] -= 88 * self.__mult  # 100%

        # Why there is negative and above maximum numbers, KUNOS???
        rect[3] = min(rect[3], max(0.0, rect[3] * (1.0 - travel)))

        ac.glColor4f(*self._back.color)
        ac.glQuad(*rect)
    def draw(self, data, delta_t: float) -> None:
        dirt = data.tire_d * self.__mult

        rect = copy.copy(self._box.rect)
        rect[1] += (rect[3] - dirt)
        rect[3] = dirt

        ac.glColor4f(*Colors.brown)
        ac.glQuad(*rect)
Exemple #6
0
def drawboostBars(x, y):
    ac.glColor4f(1, 0.31, 0, 1)
    ac.glQuad(0, 42, percentage_boost * 4.35, 8)
    #ac.glQuad(960,42,-percentage_boost*4.35,8)
    ac.glBegin(acsys.GL.Quads)
    ac.glVertex2f(960, 42)
    ac.glVertex2f(960 - percentage_boost * 4.35, 42)
    ac.glVertex2f(960 - percentage_boost * 4.35, 50)
    ac.glVertex2f(960, 50)
    ac.glEnd()
def drawboostBars(x,y):
    ac.glColor4f(1,0.31,0,1)
    ac.glQuad(0,42,percentage_boost*4.35,8)
    #ac.glQuad(960,42,-percentage_boost*4.35,8)
    ac.glBegin(acsys.GL.Quads)
    ac.glVertex2f(960,42)
    ac.glVertex2f(960-percentage_boost*4.35,42)
    ac.glVertex2f(960-percentage_boost*4.35,50)
    ac.glVertex2f(960,50)
    ac.glEnd()
    def draw(self, rect, texture_id=None) -> None:
        """ Draws the box background. """
        if self.size > 0.0 and self.border[3] > 0.0:
            twice = self.size * 2.0
            ac.glColor4f(*self.border)
            ac.glQuad(rect[0] - self.size, rect[1] - self.size,
                      rect[2] + twice, rect[3] + twice)

        ac.glColor4f(*self.color)
        if texture_id is None:
            ac.glQuad(*rect)
        else:
            ac.glQuadTextured(rect[0], rect[1], rect[2], rect[3], texture_id)
Exemple #9
0
 def rect(x, y, w, h, color=Color(1, 1, 1, 1), filled=True):
     ac.glColor4f(color.r, color.g, color.b, color.a)
     if filled:
         ac.glQuad(x, y, w, h)
     else:
         ac.glBegin(1)
         ac.glVertex2f(x, y)
         ac.glVertex2f(x + w, y)
         ac.glVertex2f(x + w, y)
         ac.glVertex2f(x + w, y + h)
         ac.glVertex2f(x + w, y + h)
         ac.glVertex2f(x, y + h)
         ac.glVertex2f(x, y + h)
         ac.glVertex2f(x, y)
         ac.glEnd()
    def draw(self, data, delta_t: float) -> None:
        self._draw()

        rpm = data.rpm
        ratio = min(rpm / data.max_rpm, 1.0)

        bar = copy.copy(self._box.rect)
        bar[2] *= ratio

        color = self.__calc.interpolate_color(rpm)
        ac.glColor4f(*color)
        ac.glQuad(*bar)

        ac.setFontColor(self.__lb, color[0], color[1], color[2], color[3])
        ac.setText(self.__lb, "{} RPM".format(rpm))
    def draw(self, data, delta_t: float) -> None:
        """ Draws the wear. """
        self._draw()
        wear = data.tire_w
        if wear > 0.98:
            ac.glColor4f(*Colors.green)
        elif wear > 0.96:
            ac.glColor4f(*Colors.yellow)
        else:
            ac.glColor4f(*Colors.red)

        # Initial padding is 10x44
        wear = (wear - 0.94) / 0.06
        rect = copy.copy(self._box.rect)
        rect[1] += (1.0 - wear) * rect[3]
        rect[3] *= wear
        ac.glQuad(*rect)
def drawOdometer():
	global posting
	root_x = speed_pivot_x - 48
	root_y = speed_pivot_y - 50
	fg = odometer_fg
	bg = odometer_bg
	distance = sim_info.graphics.distanceTraveled/1000
	if imperial:
		distance = distance / 1.632
	s = "%3.1f" % (sim_info.graphics.distanceTraveled/1000)
	# zero-padding
	while len(s) < 5:
		s = "0" + s
	i = 0
	for c in s:
		if c != '.':
			drawNineSegment(root_x+96-24*(4-i),root_y,24,36,c,fg,bg)
			i = i + 1
	# Decimal point
	ac.glColor4f(0.0,0.0,0.0,1.0)
	ac.glQuad(root_x+48+22,root_y+30,4,4)
Exemple #13
0
def onFormRender(deltaT):

    kersValue = ac.getCarState(0, acsys.CS.KersCharge)

    usage = getErsCurrent() / getERSMax()

    ac.glColor4f(255, 255, 255, 0.4)
    ac.glQuad(300, 90, 40, 100)
    ac.glColor4f(0, 255, 0, 0.5)
    ac.glQuad(300, 90 - ((100 * kersValue) - 100), 40, (100 * kersValue))
    ac.glColor4f(255, 255, 255, 0.4)
    ac.glQuad(400, 90, 40, 100)
    ac.glColor4f(0, 0, 255, 0.5)
    ac.glQuad(400, 90 - ((100 * usage) - 100), 40, (100 * usage))
def drawrpmBars(x,y):
    if(abs(percentage_rpm)<max_user_rpm):ac.glColor4f(1,1,1,1)
    if(abs(percentage_rpm)>max_user_rpm):ac.glColor4f(1,0,0,1)
    if(percentage_rpm <min_user_rpm):
        ac.glQuad(0,20,0,20)
        ac.glQuad(960,20,0,20)
    if(percentage_rpm >min_user_rpm):
        ac.glQuad(0,20,abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm),20)
        #ac.glQuad(960,20,-(abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm)),20)
        ac.glBegin(acsys.GL.Quads)
        ac.glVertex2f(960,20)
        ac.glVertex2f(960-abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm),20)
        ac.glVertex2f(960-abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm),40)
        ac.glVertex2f(960, 40)
        ac.glEnd()
Exemple #15
0
def drawrpmBars(x, y):
    if (abs(percentage_rpm) < max_user_rpm): ac.glColor4f(1, 1, 1, 1)
    if (abs(percentage_rpm) > max_user_rpm): ac.glColor4f(1, 0, 0, 1)
    if (percentage_rpm < min_user_rpm):
        ac.glQuad(0, 20, 0, 20)
        ac.glQuad(960, 20, 0, 20)
    if (percentage_rpm > min_user_rpm):
        ac.glQuad(
            0, 20,
            abs(percentage_rpm - min_user_rpm) * 435 / (100 - min_user_rpm),
            20)
        #ac.glQuad(960,20,-(abs(percentage_rpm-min_user_rpm)*435/(100-min_user_rpm)),20)
        ac.glBegin(acsys.GL.Quads)
        ac.glVertex2f(960, 20)
        ac.glVertex2f(
            960 - abs(percentage_rpm - min_user_rpm) * 435 /
            (100 - min_user_rpm), 20)
        ac.glVertex2f(
            960 - abs(percentage_rpm - min_user_rpm) * 435 /
            (100 - min_user_rpm), 40)
        ac.glVertex2f(960, 40)
        ac.glEnd()
    def draw(self, data, delta_t: float) -> None:
        # Initial padding is 12x12
        pad = 12 * self.__mult
        pad2 = 2.0 * pad

        quarter = (self._box.rect[3] - pad2) * 0.125
        part = (self._box.rect[2] - pad2) / 3.0
        inner = self._box.rect[0] + pad
        outer = self._box.rect[0] + pad + 2.0 * part
        height = self._box.rect[1] + pad

        temp = data.tire_t_c
        interpolated = self.__calc.interpolate(temp)
        color = self.__calc.interpolate_color(temp, interpolated)
        ac.glColor4f(*color)
        ac.glQuad(inner, height + quarter, part * 3.0, quarter * 6.0)

        temp = data.tire_t_i
        interpolated = self.__calc.interpolate(temp)
        color = self.__calc.interpolate_color(temp, interpolated)
        ac.glColor4f(*color)
        ac.glQuad(inner, height, part, quarter)
        ac.glQuad(inner, height + quarter * 7, part, quarter)

        temp = data.tire_t_m
        interpolated = self.__calc.interpolate(temp)
        color = self.__calc.interpolate_color(temp, interpolated)
        ac.glColor4f(*color)
        ac.glQuad(self._box.rect[0] + pad + part, height, part, quarter)
        ac.glQuad(self._box.rect[0] + pad + part, height + quarter * 7, part,
                  quarter)

        temp = data.tire_t_o
        interpolated = self.__calc.interpolate(temp)
        color = self.__calc.interpolate_color(temp, interpolated)
        ac.glColor4f(*color)
        ac.glQuad(outer, height, part, quarter)
        ac.glQuad(outer, height + quarter * 7, part, quarter)
Exemple #17
0
def onFormRender(deltaT):
    global doRender, maxRPM, maxGear

    if not doRender:
        return

    gear = ac.getCarState(0, acsys.CS.Gear)
    rpm = ac.getCarState(0, acsys.CS.RPM)

    hBarWidth = appWidth * 0.04
    lineWidth = appWidth * 0.01
    doubleWidth = lineWidth * 2
    halfWidth = lineWidth / 2

    gearY = appHeight - (gear * gearSpacing)
    rpmY = appHeight * (rpm / CarData["maxRPM"])
    rpmX = rpmY / lineSlope
    rpmXL = doubleWidth + rpmX
    rpmXR = (appWidth - doubleWidth) - rpmX
    rpmY = appHeight - rpmY

    centerX = appWidth / 2
    centerY = gearY - fontSize / 2
    l = centerX - fontSize / 2
    r = centerX + fontSize / 2
    t = gearY - fontSize

    ac.glColor4f(0.7, 0.0, 0.0, 0.9)
    ac.glBegin(acsys.GL.Quads)

    # red diagonals
    ac.glVertex2f(0, appHeight)
    ac.glVertex2f(lineWidth, appHeight)
    ac.glVertex2f(appHeight / lineSlope + lineWidth, 0)
    ac.glVertex2f(appHeight / lineSlope, 0)

    ac.glVertex2f(appWidth - lineWidth, appHeight)
    ac.glVertex2f(appWidth, appHeight)
    ac.glVertex2f(appWidth - (appHeight / lineSlope), 0)
    ac.glVertex2f(appWidth - lineWidth - (appHeight / lineSlope), 0)

    ac.glEnd()

    # red RPM x1000 ticks
    y = appHeight
    while y > -1:
        dx = (appHeight - y) / lineSlope
        ac.glQuad(dx, y, hBarWidth, lineWidth)
        ac.glQuad(appWidth - dx - hBarWidth, y, hBarWidth, lineWidth)
        y -= (PxPer1000RPM * RPMdivs)

    # red/green diagonal quads
    ac.glColor4f(0.0, 0.9, 0.0, 0.9)
    topY = appHeight - (PxPer1000RPM * RPMdivs) + doubleWidth
    botY = appHeight - lineWidth
    while botY > 0:
        if topY < (PxPer1000RPM * RPMdivs):
            ac.glColor4f(0.7, 0.0, 0.0, 0.9)
            y = max(0, topY)  # redline bars
        elif topY < rpmY:
            y = rpmY  # current rpm bar
        else:
            y = topY  # rest of the lower rpm bars
        dxt = (appHeight - y + doubleWidth) / lineSlope + doubleWidth
        dxb = (appHeight - botY + doubleWidth) / lineSlope + doubleWidth

        ac.glBegin(acsys.GL.Quads)
        ac.glVertex2f(dxb, botY)
        ac.glVertex2f(dxb + lineWidth * 3, botY)
        ac.glVertex2f(dxt + lineWidth * 3, y)
        ac.glVertex2f(dxt, y)

        ac.glVertex2f(appWidth - dxb - lineWidth * 3, botY)
        ac.glVertex2f(appWidth - dxb, botY)
        ac.glVertex2f(appWidth - dxt, y)
        ac.glVertex2f(appWidth - dxt - lineWidth * 3, y)

        ac.glEnd()

        botY = topY - lineWidth * 3
        topY -= (PxPer1000RPM * RPMdivs)

    # white boxes around gears
    for g in range(CarData["totalGears"] + 2):
        if g == gear:
            ac.glColor4f(0.0, 0.9, 0.0, 0.9)
            lw = lineWidth
        else:
            ac.glColor4f(0.9, 0.9, 0.9, 0.9)
            lw = halfWidth
        gy = appHeight - (g * gearSpacing)
        gt = gy - fontSize
        ac.glQuad(l - lw, gy, fontSize + (lw * 2), lw)  # bot
        ac.glQuad(r, gt, lw, fontSize)  # right
        ac.glQuad(l - lw, gt - lw, fontSize + (lw * 2), lw)  # top
        ac.glQuad(l - lw, gt, lw, fontSize)  # left

    ac.glColor4f(0.9, 0.9, 0.9, 0.9)
    ac.glBegin(acsys.GL.Lines)

    # white diagonal back to selected gear
    ac.glVertex2f(rpmXL + hBarWidth + lineWidth, rpmY)
    ac.glVertex2f(l - hBarWidth - lineWidth, centerY)
    ac.glVertex2f(rpmXR - hBarWidth - lineWidth, rpmY)
    ac.glVertex2f(r + hBarWidth + lineWidth, centerY)

    ac.glEnd()

    ac.glColor4f(0.9, 0.9, 0.9, 0.9)
    # white horizontal rpms
    ac.glQuad(rpmXL + lineWidth, rpmY - halfWidth, hBarWidth, lineWidth)
    ac.glQuad(rpmXR - hBarWidth - lineWidth, rpmY - halfWidth, hBarWidth,
              lineWidth)

    # white horizontal selected gear
    ac.glQuad(l - hBarWidth - lineWidth, centerY - halfWidth, hBarWidth,
              lineWidth)
    ac.glQuad(r + lineWidth, centerY - halfWidth, hBarWidth, lineWidth)
def drawTyreMonitor():
	global flt_label1, frt_label1, rlt_label1, rrt_label1 # Temp
	global flt_label2, frt_label2, rlt_label2, rrt_label2 # Pressure
	fl_t, fr_t, rl_t, rr_t = ac.getCarState(0,acsys.CS.CurrentTyresCoreTemp)
	temps = [fl_t, fr_t, rl_t, rr_t]
	fl_p, fr_p, rl_p, rr_p = ac.getCarState(0,acsys.CS.DynamicPressure)
	wheelslip = ac.getCarState(0,acsys.CS.TyreSlip)
	wear      = sim_info.physics.tyreWear
	dirt      = sim_info.physics.tyreDirtyLevel
	ac.setText(flt_label1,"%dC"%fl_t)
	ac.setText(frt_label1,"%dC"%fr_t)
	ac.setText(rlt_label1,"%dC"%rl_t)
	ac.setText(rrt_label1,"%dC"%rr_t)
	# Outside of tyre = white if normal, yellow if losing grip, red if lost grip
	for i in range(0,4):
		outside_color = [1.0,1.0,1.0,tyre_monitor_opacity]
		if wheelslip[i] >= 35000:
			outside_color = [1.0,0.0,0.0,tyre_monitor_opacity]
		elif wheelslip[i] >= 25000:
			percent = (int(wheelslip[i])-25000)/10000
			outside_color = [1.0,(165 - 165*percent)/255,0.0,tyre_monitor_opacity] # Orange
		elif wheelslip[i] >= 10000:
			percent = (int(wheelslip[i])-10000)/15000
			outside_color = [1.0,(255 - 90*percent)/255,0.0,tyre_monitor_opacity]
		elif wheelslip[i] > 7000:
			# 100% = [1.0,1.0,0.0,1.0]
			#   0% = [1.0,1.0,1.0,1.0]
			percent = (int(wheelslip[i])-7000)/3000
			outside_color = [1.0,1.0,1-percent,tyre_monitor_opacity]
		root_x = tyre_mon_xpos
		root_y = tyre_mon_ypos
		if i == 1 or i == 3:
			root_x = root_x + 80
		if i == 2 or i == 3:
			root_y = root_y + 96
		ac.glColor4f(outside_color[0],outside_color[1],outside_color[2],outside_color[3])
		ac.glQuad(root_x,root_y,36,4)
		ac.glQuad(root_x,root_y+4,4,56)
		ac.glQuad(root_x+32,root_y+4,4,56)
		ac.glQuad(root_x,root_y+60,36,4)
		# 28x56
		# Dirty level
		ac.glColor4f(150/255,75/255,0.0,tyre_monitor_opacity)
		ac.glQuad(root_x+4,root_y+60,28,-(56*dirt[i]/5))
		# Inside of tyre = blue if v. cold, light blue if cold, white if normal, yellow if hot, red if v. hot
		inside_color = [1.0,1.0,1.0,tyre_monitor_opacity]
		if temps[i] < (tyre_optimal_temp[0]-25):
			inside_color = [0.0,100.0/255,1.0,tyre_monitor_opacity]
		elif temps[i] < (tyre_optimal_temp[0]-10):
			percent = (-int(temps[i])+tyre_optimal_temp[0])/25
			inside_color = [0.0,(255 - 155*percent)/255,1.0,tyre_monitor_opacity]
		elif temps[i] < tyre_optimal_temp[0]:
			percent = (tyre_optimal_temp[0]-int(temps[i]))/10
			inside_color = [1-percent,1.0,1.0,tyre_monitor_opacity]
		elif int(temps[i]) in tyre_optimal_temp:
			inside_color = [1.0,1.0,1.0,tyre_monitor_opacity]
		elif temps[i] < (tyre_optimal_temp[-1]+15):
			percent = (int(temps[i])-tyre_optimal_temp[-1])/15
			inside_color = [1.0,1.0,1-percent,tyre_monitor_opacity]
		elif temps[i] <= (tyre_optimal_temp[-1]+25):
			percent = (int(temps[i])-tyre_optimal_temp[-1]-15)/10
			inside_color = [1.0,1-percent,0.0,tyre_monitor_opacity]
		else: # DANGER
			inside_color = [1.0,0.0,0.0,tyre_monitor_opacity]
		# no. of bars inside tyre = wear level
		bars = int(wear[i]/10)
		if bars > 9:
			bars = 9
		for j in range(0,bars):
			ac.glColor4f(inside_color[0],inside_color[1],inside_color[2],inside_color[3])
			ac.glQuad(root_x + 6,root_y + 54 - 6*j,24,4)
	ac.setText(flt_label2,"%d psi"%fl_p)
	ac.setText(frt_label2,"%d psi"%fr_p)
	ac.setText(rlt_label2,"%d psi"%rl_p)
	ac.setText(rrt_label2,"%d psi"%rr_p)
Exemple #19
0
def drawTyresDirt(x, y, w, h, dirt):
    ac.glColor4f(0.9, 0.6, 0.2, 1)
    ac.glQuad(x, y, w, -(10 * dirt))
Exemple #20
0
def drawTyres(x, y, w, h, temp):
    colorTyres(temp)
    ac.glQuad(x, y, w, h)
Exemple #21
0
def drawTyresDirt(x, y, w, h, dirt):
  ac.glColor4f(0.9, 0.6, 0.2, 1)
  ac.glQuad(x, y, w, -(10 * dirt))
Exemple #22
0
def drawTyres(x, y, w, h, temp):
  colorTyres(temp)
  ac.glQuad(x, y, w, h)