def Update(self): load = self.controller.GetCapacitorCapacity() maxcap = self.controller.GetCapacitorCapacityMax() proportion = max( 0.0, min(1.0, round(maxcap and load / maxcap or maxcap, 2))) if self.lastSetCapacitor == proportion: return sm.ScatterEvent('OnCapacitorChange', load, maxcap, proportion) good = trinity.TriColor(*COLOR_ORANGE) bad = trinity.TriColor(*COLOR_DARK_ORANGE) bad.Scale(1.0 - proportion) good.Scale(proportion) maxCap = self.controller.GetCapacitorCapacityMax() if maxCap is not None and self.initialized and self.powerCells: totalCells = len(self.powerCells) visible = max(0, min(totalCells, int(proportion * totalCells))) for ci, each in enumerate(self.powerCells): if ci >= visible: each.SetRGB(0.5, 0.5, 0.5, 0.5) each.glowColor = (0, 0, 0, 1) each.glowFactor = 0.0 each.glowExpand = 0.1 each.shadowOffset = (0, 0) else: each.SetRGB(0.125, 0.125, 0.125, 1) each.glowColor = (bad.r + good.r, bad.g + good.g, bad.b + good.b, 1.0) each.glowFactor = 0.0 each.glowExpand = 0.1 each.shadowOffset = (0, 1) if self.powerBlink is None: self.powerBlink = Sprite( parent=self, name='powerblink', state=uiconst.UI_HIDDEN, texturePath= 'res:/UI/Texture/classes/ShipUI/capacitorCellGlow.png', align=uiconst.CENTERTOP, blendMode=trinity.TR2_SBM_ADDX2, color=COLOR_ORANGE) r, g, b = COLOR_ORANGE uicore.effect.BlinkSpriteRGB(self.powerBlink, r, g, b, 750, None) if visible != 0 and visible < totalCells: active = self.powerCells[visible - 1] self.powerBlink.SetParent(active.parent, 0) self.powerBlink.top = active.top self.powerBlink.width = active.width + 3 self.powerBlink.height = active.height self.powerBlink.state = uiconst.UI_DISABLED else: self.powerBlink.state = uiconst.UI_HIDDEN self.lastSetCapacitor = proportion
def SetAmmoColor(self): targetBall = self.GetEffectTargetBall() targetModel = getattr(targetBall, 'model', None) color = (1.0, 1.0, 1.0, 1.0) emitters = targetModel.Find('trinity.EveEmitterStatic') if len(emitters): if len(emitters[0].particleData): color = emitters[0].particleData[0].color self.turret.SetAmmoColor(trinity.TriColor(*color))
def SetSpriteColor(self, id, color): obj = self.GetSprite(id) if obj: c = trinity.TriColor() c.FromInt(color) obj.color = (c.r, c.g, c.b, c.a) if not self.retdata.has_key(id): self.retdata[id] = ('', None, 0) curr = self.retdata[id] self.retdata[id] = (curr[0], curr[1], color)
def SetHSV(self, id, hsv): if not self or self.destroyed: return obj = self.GetSprite(id) if obj: obj.color.SetHSV(*hsv) if not self.retdata.has_key(id): self.retdata[id] = ('', 0) curr = self.retdata[id] colInt = trinity.TriColor(*obj.color.GetRGBA()).AsInt() self.retdata[id] = (curr[0], curr[1], colInt)
def DrawToBuf(self, buf, bx0, by0, checkUnderline=1): x = 0 for t in self: advance = t[0] sbit = t[3] params = t[7] color = params.color or -1 if type(color) != types.IntType: tricol = trinity.TriColor(*color) color = tricol.AsInt() hasUnderline = bool(params.underline) if hasUnderline: extraSpace = advance - sbit.xadvance sbit.ToBufferWithUnderline(buf.data, buf.width, buf.height, buf.pitch, x + bx0, by0, color, extraSpace) else: sbit.ToBuffer(buf.data, buf.width, buf.height, buf.pitch, x + bx0, by0, color) x += t[0]
def Insert(self, params, text, idx, align=0): if not text: return None self._textDirty = True color = params.color or -1 if type(color) != types.IntType: tricol = trinity.TriColor(*color) color = tricol.AsInt() uicore.font.ResolveFontFamily(params) dpi_wordspace = int(params.wordspace * uicore.desktop.dpiScaling + 0.5) dpi_fontsize = int(params.fontsize * uicore.desktop.dpiScaling + 0.5) dpi_letterspace = int(params.letterspace * uicore.desktop.dpiScaling + 0.5) self.fontsize = dpi_fontsize lastFontIndex, lastGlyphIndex = (None, None) for char in text: if char == u'\xa0': rchar = u' ' else: rchar = char fontIndex, glyphIndex = trinity.fontMan.LookupGlyphIndex( params.font, params, ord(rchar)) if fontIndex != lastFontIndex: self.GetMetrics(fontIndex) self.baseLine = max(self.baseLine, self.asc) self.baseHeight = max(self.baseHeight, self.asc - self.des) kern = 0 else: kern = trinity.fontMan.LookupKerningXP(fontIndex, glyphIndex, lastGlyphIndex) lastFontIndex, lastGlyphIndex = fontIndex, glyphIndex sbit = trinity.fontMan.LookupSBit(fontIndex, dpi_fontsize, dpi_fontsize, glyphIndex) advance = sbit.xadvance + dpi_letterspace + kern if rchar == u' ': advance += dpi_wordspace self.insert(idx, (advance, align, color, sbit, char, self.asc, self.des, params.Copy())) idx += 1 self.width += advance
def LayoutTiles(self, size, sovereigntyInfo, changeList, colorByStandings = False): changedSystems = set([ info.solarSystemID for info in changeList ]) for info in self.systemInfoMap.itervalues(): if info.systemID in sovereigntyInfo: info.sovID = sovereigntyInfo[info.systemID] info.changed = info.systemID in changedSystems layout = self.GetLayout(size) self.nextTileNum = 0 for i, tile in enumerate(layout): if tile.IsEmpty(): continue tile.Update(colorByStandings) hex = self.GetNextGeom() hex.SetTile(tile) hex.index = i if self.firstUnusedTileNum is not None and self.firstUnusedTileNum > self.nextTileNum: for i in xrange(self.nextTileNum, self.firstUnusedTileNum): self.tilePool[i].Show(False) self.firstUnusedTileNum = self.nextTileNum self.currentLayout = layout self.currentSize = size if colorByStandings: self.legend = [LegendItem(0, localization.GetByLabel('UI/PeopleAndPlaces/GoodStanding'), trinity.TriColor(*COLOR_STANDINGS_GOOD), data=None), LegendItem(1, localization.GetByLabel('UI/PeopleAndPlaces/StandingNeutral'), trinity.TriColor(*COLOR_STANDINGS_NEUTRAL), data=None), LegendItem(2, localization.GetByLabel('UI/PeopleAndPlaces/BadStanding'), trinity.TriColor(*COLOR_STANDINGS_BAD), data=None)] else: legend = [ (tile.sovID, tile.color) for tile in self.currentLayout if tile.sovID is not None ] self.legend = [LegendItem(0, localization.GetByLabel('UI/Inflight/Brackets/SystemUnclaimed'), trinity.TriColor(*UNCLAIMED_TILE_COLOR), data=None), LegendItem(1, localization.GetByLabel('UI/Inflight/Brackets/SystemContested'), trinity.TriColor(*TIED_TILE_COLOR), data=None)] factions = [] for sovID, color in set(legend): name = cfg.eveowners.Get(sovID).name factions.append(LegendItem(2, name, trinity.TriColor(*color), data=sovID)) self.legend += factions self.highlightCurveSet.Play()
#Embedded file name: eve/client/script/ui/shared/maps\palette.py import uiprimitives import uicontrols import uthread import uiutil import trinity import util from eve.client.script.ui.control import entries as listentry import types import carbonui.const as uiconst import maputils import log import mapcommon from service import ROLE_GML import localization ROUTECOL = {'White': trinity.TriColor(1.0, 1.0, 1.0, 0.5), 'Red': trinity.TriColor(1.0, 0.0, 0.0, 0.5), 'Green': trinity.TriColor(0.0, 1.0, 0.0, 0.5), 'Blue': trinity.TriColor(0.0, 0.0, 1.0, 0.5), 'Yellow': trinity.TriColor(1.0, 1.0, 0.0, 0.5)} ILLEGALITY_AVOID_NONE = 0 ILLEGALITY_AVOID_STANDING_LOSS = 1 ILLEGALITY_AVOID_CONFISCATE = 2 ILLEGALITY_AVOID_ATTACK = 3 class MapPalette(uicontrols.Window): __guid__ = 'form.MapsPalette' __notifyevents__ = ['OnMapModeChangeDone', 'OnLoadWMCPSettings', 'OnFlattenModeChanged'] default_top = '__center__' default_width = 400 default_height = 320
def GetHSV(self): return trinity.TriColor(*self.GetRGBA()).GetHSV()
def CreateAlpha(outPath, sourcePaths, backgroundPath=None): rBmp = trinity.Tr2HostBitmap() rBmp.CreateFromFile(sourcePaths[0]) gBmp = trinity.Tr2HostBitmap() gBmp.CreateFromFile(sourcePaths[1]) bBmp = trinity.Tr2HostBitmap() bBmp.CreateFromFile(sourcePaths[2]) outputBmp = trinity.Tr2HostBitmap(rBmp.width, rBmp.height, 1, trinity.PIXEL_FORMAT.B8G8R8A8_UNORM) rTriCol = trinity.TriColor() gTriCol = trinity.TriColor() bTriCol = trinity.TriColor() BLACKALPHA0 = 0 HUERANGE = 60 REDHUE = 0 GREENHUE = 120 BLUEHUE = 240 addBackground = not backgroundPath == None if addBackground: myBg = trinity.Tr2HostBitmap() myBg.CreateFromFile(backgroundPath) bgTriCol = trinity.TriColor() for px in range(rBmp.width): for py in range(rBmp.height): if addBackground: bgPixelValue = myBg.GetPixel(px, py) bgTriCol.FromInt(bgPixelValue) rPixelValue = rBmp.GetPixel(px, py) gPixelValue = gBmp.GetPixel(px, py) bPixelValue = bBmp.GetPixel(px, py) rTriCol.FromInt(rPixelValue) gTriCol.FromInt(gPixelValue) bTriCol.FromInt(bPixelValue) rh, rs, rv = rTriCol.GetHSV() gh, gs, gv = gTriCol.GetHSV() bh, bs, bv = bTriCol.GetHSV() if (rTriCol.r, rTriCol.g, rTriCol.b) == (1.0, 0.0, 0.0) and ( gTriCol.r, gTriCol.g, gTriCol.b) == (0.0, 1.0, 0.0) and ( bTriCol.r, bTriCol.g, bTriCol.b) == (0.0, 0.0, 1.0): if addBackground: outputBmp.SetPixel(px, py, bgTriCol.AsInt()) else: outputBmp.SetPixel(px, py, BLACKALPHA0) elif GREENHUE - HUERANGE < gh < GREENHUE + HUERANGE and ( 360 - HUERANGE < rh <= 360 or REDHUE <= rh < REDHUE + HUERANGE) and BLUEHUE - HUERANGE < bh < BLUEHUE + HUERANGE: if gv == 1.0 and bv == 1.0 and rv == 1.0: gTriCol.SetRGB(gTriCol.r, rTriCol.g, gTriCol.b, 1.0) ch, cs, cv = gTriCol.GetHSV() gTriCol.a = cv gTriCol.r = min(1.0, gTriCol.r * 1.0 / cv) gTriCol.g = min(1.0, gTriCol.g * 1.0 / cv) gTriCol.b = min(1.0, gTriCol.b * 1.0 / cv) outputBmp.SetPixel(px, py, gTriCol.AsInt()) elif addBackground: alpha = 1.0 - gv invAlpha = 1 - alpha redColor = gTriCol.r * alpha + bgTriCol.r * invAlpha greenColor = rTriCol.g * alpha + bgTriCol.g * invAlpha blueColor = gTriCol.b * alpha + bgTriCol.b * invAlpha newAlpha = gTriCol.a * alpha + bgTriCol.a * invAlpha gTriCol.SetRGB(redColor, greenColor, blueColor, newAlpha) else: gTriCol.SetRGB(gTriCol.r, rTriCol.g, gTriCol.b, 1.0 - gv) outputBmp.SetPixel(px, py, gTriCol.AsInt()) else: gTriCol.a = 1.0 outputBmp.SetPixel(px, py, gTriCol.AsInt()) outputBmp.Save(outPath)
STARMODE_SERVICE_SecurityOffice = (STARMODE_SERVICE, const.stationServiceSecurityOffice) STARMODE_FILTER_FACWAR_ENEMY = -1 STARMODE_FILTER_FACWAR_MINE = -2 STARMODE_FILTER_EMPIRE = -3 STARMAP_SCALE = 1e-13 SYSTEMMAP_SCALE = 1e-10 ZOOM_MAX_STARMAP = 200000.0 ZOOM_MIN_STARMAP = 4000.0 ZOOM_FAR_SYSTEMMAP = 8000.0 ZOOM_NEAR_SYSTEMMAP = 1.0 LINESET_EFFECT = 'res:/Graphics/Effect/Managed/Space/SpecialFX/LinesAdditive.fx' LINESET_EFFECT_STARMAP = 'res:/Graphics/Effect/Managed/Space/SpecialFX/LinesAdditiveStarMap.fx' LINESET_3D_EFFECT_STARMAP = 'res:/Graphics/Effect/Managed/Space/SpecialFX/Lines3DStarMap.fx' COLORCURVE_SECURITY = [ trinity.TriColor(1.0, 0.0, 0.0, 1.0), trinity.TriColor(0.9, 0.2, 0.0, 1.0), trinity.TriColor(1.0, 0.3, 0.0, 1.0), trinity.TriColor(1.0, 0.4, 0.0, 1.0), trinity.TriColor(0.9, 0.5, 0.0, 1.0), trinity.TriColor(1.0, 1.0, 0.0, 1.0), trinity.TriColor(0.6, 1.0, 0.2, 1.0), trinity.TriColor(0.0, 1.0, 0.0, 1.0), trinity.TriColor(0.0, 1.0, 0.3, 1.0), trinity.TriColor(0.3, 1.0, 0.8, 1.0), trinity.TriColor(0.2, 1.0, 1.0, 1.0) ] COLOR_STANDINGS_NEUTRAL = (0.25, 0.25, 0.25) COLOR_STANDINGS_GOOD = (0.0, 1.0, 0.0) COLOR_STANDINGS_BAD = (1.0, 0.0, 0.0) NEUTRAL_COLOR = trinity.TriColor(0.25, 0.25, 0.25)
def GetSpriteColor(self, id): obj = self.GetSprite(id) if obj: return trinity.TriColor(*obj.color.GetRGBA()).AsInt()
def _EnhanceColor(rgb): color = trinity.TriColor(*rgb) h, s, v = color.GetHSV() s = min(s * 1.5, 1) color.SetHSV(h, s, v) return (color.r, color.g, color.b)
def ParseHTMLColor(colorstr, asTuple=0, error=0): colors = { 'Black': '0x000000', 'Green': '0x008000', 'Silver': '0xC0C0C0', 'Lime': '0x00FF00', 'Gray': '0x808080', 'Grey': '0x808080', 'Olive': '0x808000', 'White': '0xFFFFFF', 'Yellow': '0xFFFF00', 'Maroon': '0x800000', 'Navy': '0x000080', 'Red': '0xFF0000', 'Blue': '0x0000FF', 'Purple': '0x800080', 'Teal': '0x008080', 'Fuchsia': '0xFF00FF', 'Aqua': '0x00FFFF', 'Transparent': '0x00000000' } try: colorstr = colors.get(colorstr.capitalize(), colorstr).lower() except: sys.exc_clear() return colorstr if colorstr.startswith('#'): colorstr = colorstr.replace('#', '0x') r, g, b, a = (0.0, 255.0, 0.0, 255.0) if colorstr.startswith('0x'): try: if len(colorstr) == 8: r = eval('0x' + colorstr[2:4]) g = eval('0x' + colorstr[4:6]) b = eval('0x' + colorstr[6:8]) elif len(colorstr) == 10: a = eval('0x' + colorstr[2:4]) r = eval('0x' + colorstr[4:6]) g = eval('0x' + colorstr[6:8]) b = eval('0x' + colorstr[8:10]) else: log.LogWarn( 'Invalid color string, has to be in form of 0xffffff or 0xffffffff (with alpha). 0x can be replaced with # (%s)' % colorstr) if error: return except: log.LogWarn( 'Invalid color string, has to be in form of 0xffffff or 0xffffffff (with alpha). 0x can be replaced with # (%s)' % colorstr) if error: return else: log.LogError('Unknown color (' + colorstr + '), I only know: ' + strx(', '.join(colors.keys()))) if error: return col = (r / 255.0, g / 255.0, b / 255.0, a / 255.0) if asTuple: return col import trinity return trinity.TriColor(*col)
def SetHSV(self, h, s, v): c = trinity.TriColor() c.SetHSV(h, s, v) self.SetRGB(c.r, c.g, c.b)
def FromInt(self, val): c = trinity.TriColor() c.FromInt(val) self.sr.colorfill.SetRGBA(c.r, c.g, c.b, c.a) self.SetHSV(c.GetHSV())
#Embedded file name: c:/depot/games/branches/release/EVE-TRANQUILITY/eve/client/script/environment/spaceObject/DeployableSpaceObject.py import nodemanager import trinity import spaceObject RED = trinity.TriColor(1.0, 0.0, 0.0) GREEN = trinity.TriColor(0.27, 0.53, 0.22) YELLOW = trinity.TriColor(0.53, 0.53, 0.08) HDRScale = 3.0 class DeployableSpaceObject(spaceObject.SpaceObject): __guid__ = None def SetColorBasedOnStatus(self): if self.isFree == 1: self.SetColor('green') else: self.SetColor('red') def SetColor(self, col): mats = self.GetMaterial() if len(mats) == 0: return for glow in mats: if col == 'red': glow.v1 = RED.r * HDRScale glow.v2 = RED.g * HDRScale glow.v3 = RED.b * HDRScale elif col == 'yellow': glow.v1 = YELLOW.r * HDRScale glow.v2 = YELLOW.g * HDRScale
def GetRegionColor(self, regionID): color = trinity.TriColor() color.SetHSV(float(regionID) * 21 % 360.0, 0.5, 0.8) color.a = 0.75 return color
def SetHSV(self, hsv): self.orgcolor = trinity.TriColor(1.0, 0.0, 0.0) self.orgcolor.a = 1.0 if hsv is not None: self.orgcolor.SetHSV(*hsv)