本文整理汇总了C#中VRageMath.Color类的典型用法代码示例。如果您正苦于以下问题:C# Color类的具体用法?C# Color怎么用?C# Color使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Color类属于VRageMath命名空间,在下文中一共展示了Color类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Draw
internal void Draw(Rectangle rect, Color color, MyVideoRectangleFitMode fitMode)
{
int w = 0, h = 0;
byte [] data = m_wrapper.GetTextureData(ref w, ref h);
process_frame(data, w, h);
Rectangle dst = rect;
Rectangle src = new Rectangle(0, 0, w, h);
var videoSize = new Vector2(w, h);
float videoAspect = videoSize.X / videoSize.Y;
float rectAspect = (float)rect.Width / (float)rect.Height;
// Automatic decision based on ratios.
if (fitMode == MyVideoRectangleFitMode.AutoFit)
fitMode = (videoAspect > rectAspect) ? MyVideoRectangleFitMode.FitHeight : MyVideoRectangleFitMode.FitWidth;
float scaleRatio = 0.0f;
switch (fitMode)
{
case MyVideoRectangleFitMode.None:
break;
case MyVideoRectangleFitMode.FitWidth:
scaleRatio = (float)dst.Width / videoSize.X;
dst.Height = (int)(scaleRatio * videoSize.Y);
if (dst.Height > rect.Height)
{
var diff = dst.Height - rect.Height;
dst.Height = rect.Height;
diff = (int)(diff / scaleRatio);
src.Y += (int)(diff * 0.5f);
src.Height -= diff;
}
break;
case MyVideoRectangleFitMode.FitHeight:
scaleRatio = (float)dst.Height / videoSize.Y;
dst.Width = (int)(scaleRatio * videoSize.X);
if (dst.Width > rect.Width)
{
var diff = dst.Width - rect.Width;
dst.Width = rect.Width;
diff = (int)(diff / scaleRatio);
src.X += (int)(diff * 0.5f);
src.Width -= diff;
}
break;
}
dst.X = rect.Left + (rect.Width - dst.Width) / 2;
dst.Y = rect.Top + (rect.Height - dst.Height) / 2;
VRageMath.RectangleF destination = new VRageMath.RectangleF(dst.X, dst.Y, dst.Width, -dst.Height);
VRageMath.Rectangle? source = src;
Vector2 origin = new Vector2(src.Width / 2 * 0, src.Height);
MySpritesRenderer.AddSingleSprite(m_texture, videoSize, color, origin, Vector2.UnitX, source, destination);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:58,代码来源:MyVideoPlayer.cs
示例2: DrawTriangle
internal static void DrawTriangle(Vector3 v0, Vector3 v1, Vector3 v2, Color color)
{
var distance = ((v0 + v1 + v2) / 3f - MyEnvironment.CameraPosition).LengthSquared();
m_triangleSortDistance.Add(distance);
m_vertexList.Add(new MyVertexFormatPositionColor(v0, color));
m_vertexList.Add(new MyVertexFormatPositionColor(v1, color));
m_vertexList.Add(new MyVertexFormatPositionColor(v2, color));
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:9,代码来源:MyShapesRenderer.cs
示例3: AddQuad
internal void AddQuad(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Color color)
{
var bcolor = new Byte4(color.R, color.G, color.B, color.A);
Add(new MyVertexFormatPositionColor(v0, bcolor));
Add(new MyVertexFormatPositionColor(v1, bcolor));
Add(new MyVertexFormatPositionColor(v1, bcolor));
Add(new MyVertexFormatPositionColor(v2, bcolor));
Add(new MyVertexFormatPositionColor(v2, bcolor));
Add(new MyVertexFormatPositionColor(v3, bcolor));
Add(new MyVertexFormatPositionColor(v3, bcolor));
Add(new MyVertexFormatPositionColor(v0, bcolor));
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:16,代码来源:MyLinesRenderer.cs
示例4: AddPointBillboard
internal static void AddPointBillboard(string material,
Color color, Vector3D origin, float radius, float angle, int priority = 0, int customViewProjection = -1)
{
Debug.Assert(material != null);
origin.AssertIsValid();
angle.AssertIsValid();
MyQuadD quad;
if (MyUtils.GetBillboardQuadAdvancedRotated(out quad, origin, radius, angle, MyEnvironment.CameraPosition) != false)
{
MyBillboard billboard = SpawnBillboard();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
CreateBillboard(billboard, ref quad, material, ref color, ref origin);
}
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:20,代码来源:MyBillboardRenderer.cs
示例5: AddCone
internal void AddCone(Vector3 translation, Vector3 directionVec, Vector3 baseVec, int tessalation, Color color)
{
var axis = directionVec;
axis.Normalize();
var apex = translation + directionVec;
var steps = tessalation;
var stepsRcp = (float)(Math.PI * 2 / steps);
for (int i = 0; i < 32; i++)
{
float a0 = i * stepsRcp;
float a1 = (i + 1) * stepsRcp;
var A = translation + Vector3.Transform(baseVec, Matrix.CreateFromAxisAngle(axis, a0));
var B = translation + Vector3.Transform(baseVec, Matrix.CreateFromAxisAngle(axis, a1));
Add(A, B, color);
Add(A, apex, color);
}
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:21,代码来源:MyLinesRenderer.cs
示例6: AddBillboardOriented
internal static void AddBillboardOriented(string material,
Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, int customViewProjection = -1)
{
Debug.Assert(material != null);
origin.AssertIsValid();
leftVector.AssertIsValid();
upVector.AssertIsValid();
radius.AssertIsValid();
MyDebug.AssertDebug(radius > 0);
MyBillboard billboard = SpawnBillboard();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyQuadD quad;
MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);
CreateBillboard(billboard, ref quad, material, ref color, ref origin);
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:23,代码来源:MyBillboardRenderer.cs
示例7: CreateBillboard
// This method is like a constructor (which we can't use because billboards are allocated from a pool).
// It starts/initializes a billboard. Refs used only for optimalization
public static void CreateBillboard(VRageRender.MyBillboard billboard, ref MyQuadD quad, string material, string blendMaterial, float textureBlendRatio,
ref Color color, ref Vector3D origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false, float reflectivity = 0)
{
Debug.Assert(material != null);
if (string.IsNullOrEmpty(material) || !MyTransparentMaterials.ContainsMaterial(material))
{
material = "ErrorMaterial";
color = Vector4.One;
}
billboard.Material = material;
billboard.BlendMaterial = blendMaterial;
billboard.BlendTextureRatio = textureBlendRatio;
quad.Point0.AssertIsValid();
quad.Point1.AssertIsValid();
quad.Point2.AssertIsValid();
quad.Point3.AssertIsValid();
// Billboard vertexes
billboard.Position0 = quad.Point0;
billboard.Position1 = quad.Point1;
billboard.Position2 = quad.Point2;
billboard.Position3 = quad.Point3;
billboard.UVOffset = uvOffset;
EnableColorize = colorize;
if (EnableColorize)
billboard.Size = (float)(billboard.Position0 - billboard.Position2).Length();
// Distance for sorting
// IMPORTANT: Must be calculated before we do color and alpha misting, because we need distance there
billboard.DistanceSquared = (float)Vector3D.DistanceSquared(MyRenderCamera.Position, origin);
// Color
billboard.Color = color;
billboard.ColorIntensity = 1;
billboard.Reflectivity = reflectivity;
billboard.Near = near;
billboard.Lowres = lowres;
billboard.ParentID = -1;
// Alpha depends on distance to camera. Very close bilboards are more transparent, so player won't see billboard errors or rotating billboards
var mat = MyTransparentMaterials.GetMaterial(billboard.Material);
if (mat.AlphaMistingEnable)
billboard.Color *= MathHelper.Clamp(((float)Math.Sqrt(billboard.DistanceSquared) - mat.AlphaMistingStart) / (mat.AlphaMistingEnd - mat.AlphaMistingStart), 0, 1);
billboard.Color *= mat.Color;
billboard.ContainedBillboards.Clear();
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:58,代码来源:MyTransparentGeometry.cs
示例8: AddBillboardOriented
// Add billboard for one frame only. This billboard isn't particle (it doesn't survive this frame, doesn't have update/draw methods, etc).
// This billboard isn't facing the camera. It's always oriented in specified direction. May be used as thrusts, or inner light of reflector.
// It's used by other classes when they want to draw some billboard (e.g. rocket thrusts, reflector glare).
public static void AddBillboardOriented(string material,
Color color, Vector3D origin, Vector3 leftVector, Vector3 upVector, float radius, int priority = 0, bool colorize = false, int customViewProjection = -1)
{
Debug.Assert(material != null);
if (!IsEnabled) return;
origin.AssertIsValid();
leftVector.AssertIsValid();
upVector.AssertIsValid();
radius.AssertIsValid();
MyDebug.AssertDebug(radius > 0);
MyBillboard billboard = m_billboardOncePool.Allocate();
if (billboard == null)
return;
billboard.Priority = priority;
billboard.CustomViewProjection = customViewProjection;
MyQuadD quad;
MyUtils.GetBillboardQuadOriented(out quad, ref origin, radius, ref leftVector, ref upVector);
CreateBillboard(billboard, ref quad, material, ref color, ref origin, colorize);
m_billboardsOnce.Add(billboard);
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:31,代码来源:MyTransparentGeometry.cs
示例9: MyVertexFormatPositionColor
internal MyVertexFormatPositionColor(Vector3 position, Color color)
{
Position = position;
Color = new Byte4(color.PackedValue);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs
示例10: DrawQuadRowWise
internal static void DrawQuadRowWise(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Color color)
{
DrawTriangle(v0, v1, v2, color);
DrawTriangle(v1, v3, v2, color);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:5,代码来源:MyPrimitivesRenderer.cs
示例11: Draw6FacedConvexZ
// Assuming engine order (+Z first)
internal static unsafe void Draw6FacedConvexZ(Vector3* vertices, Color color, float alpha)
{
Color c = color;
c.A = (byte)(alpha * 255);
DrawQuadClockWise(vertices[0], vertices[1], vertices[2], vertices[3], c);
DrawQuadClockWise(vertices[4], vertices[5], vertices[6], vertices[7], c);
/* top left bottom right */
DrawQuadClockWise(vertices[0], vertices[1], vertices[5], vertices[4], c);
DrawQuadClockWise(vertices[0], vertices[3], vertices[7], vertices[4], c);
DrawQuadClockWise(vertices[3], vertices[2], vertices[6], vertices[7], c);
DrawQuadClockWise(vertices[2], vertices[1], vertices[5], vertices[6], c);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:15,代码来源:MyPrimitivesRenderer.cs
示例12: CreateRenderEntity
public static uint CreateRenderEntity(
string debugName,
string model,
MatrixD worldMatrix,
MyMeshDrawTechnique technique,
RenderFlags flags,
CullingOptions cullingOptions,
Color diffuseColor,
Vector3 colorMaskHsv,
float dithering = 0,
float maxViewDistance = float.MaxValue,
byte depthBias = 0
)
{
var message = MessagePool.Get<MyRenderMessageCreateRenderEntity>(MyRenderMessageEnum.CreateRenderEntity);
uint id = GetMessageId();
message.ID = id;
message.DebugName = debugName;
message.Model = model;
message.WorldMatrix = worldMatrix;
message.Technique = technique;
message.Flags = flags;
message.CullingOptions = cullingOptions;
message.MaxViewDistance = maxViewDistance;
message.DepthBias = depthBias;
EnqueueMessage(message);
UpdateRenderEntity(id, diffuseColor, colorMaskHsv, dithering);
return id;
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:33,代码来源:MyRenderProxy.cs
示例13: DrawString
public static void DrawString(
int fontIndex,
Vector2 screenCoord,
Color colorMask,
StringBuilder text,
float screenScale,
float screenMaxWidth)
{
var message = MessagePool.Get<MyRenderMessageDrawString>(MyRenderMessageEnum.DrawString);
message.Text.Clear().AppendStringBuilder(text);
message.FontIndex = fontIndex;
message.ScreenCoord = screenCoord;
message.ColorMask = colorMask;
message.ScreenScale = screenScale;
message.ScreenMaxWidth = screenMaxWidth;
EnqueueMessage(message);
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:18,代码来源:MyRenderProxy.cs
示例14: DrawSpriteAtlas
public static void DrawSpriteAtlas(string texture, Vector2 position, Vector2 textureOffset, Vector2 textureSize, Vector2 rightVector, Vector2 scale, Color color, Vector2 halfSize)
{
Debug.Assert(!string.IsNullOrEmpty(texture) && (texture.EndsWith(".dds") || texture.EndsWith(".png")));
var message = MessagePool.Get<MyRenderMessageDrawSpriteAtlas>(MyRenderMessageEnum.DrawSpriteAtlas);
message.Texture = texture;
message.Position = position;
message.TextureOffset = textureOffset;
message.TextureSize = textureSize;
message.RightVector = rightVector;
message.Scale = scale;
message.Color = color;
message.HalfSize = halfSize;
EnqueueMessage(message);
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:17,代码来源:MyRenderProxy.cs
示例15: Draw6FacedConvex
// Assuming natural order (+Y) first
internal static unsafe void Draw6FacedConvex(Vector3D* vertices, Color color, float alpha)
{
Color cc = color;
cc.A = (byte)(alpha * 255);
Vector3D c = MyRender11.Environment.CameraPosition;
Vector3D v0 = vertices[0] - c, v1 = vertices[1] - c, v2 = vertices[2] - c, v3 = vertices[3] - c, v4 = vertices[4] - c, v5 = vertices[5] - c, v6 = vertices[6] - c, v7 = vertices[7] - c;
DrawQuadRowWise(v0, v1, v2, v3, cc);
DrawQuadRowWise(v4, v5, v6, v7, cc);
DrawQuadRowWise(v0, v1, v4, v5, cc);
DrawQuadRowWise(v0, v2, v4, v6, cc);
DrawQuadRowWise(v2, v3, v6, v7, cc);
DrawQuadRowWise(v3, v1, v7, v5, cc);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:17,代码来源:MyPrimitivesRenderer.cs
示例16: UpdateRenderEntity
public static void UpdateRenderEntity(
uint id,
Color? diffuseColor,
Vector3? colorMaskHsv,
float dithering = 0
)
{
var message = MessagePool.Get<MyRenderMessageUpdateRenderEntity>(MyRenderMessageEnum.UpdateRenderEntity);
message.ID = id;
message.DiffuseColor = diffuseColor;
message.ColorMaskHSV = colorMaskHsv;
message.Dithering = dithering;
EnqueueMessage(message);
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:16,代码来源:MyRenderProxy.cs
示例17: DrawFrustum
internal static void DrawFrustum(BoundingFrustum frustum, Color color, float alpha)
{
var corners = frustum.GetCorners();
Draw6FacedConvexZ(corners, color, alpha);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:6,代码来源:MyPrimitivesRenderer.cs
示例18: DrawNetgraphLineBar
private void DrawNetgraphLineBar(int positionX, ref int positionY, long value, float sizeMultiplier, Color colorLine, Color colorTop)
{
float offset = value * sizeMultiplier;
int offsetI = (int)Math.Ceiling(offset);
VRageRender.MyRenderProxy.DebugDrawLine2D(
new Vector2(positionX, positionY),
new Vector2(positionX, positionY - offsetI),
colorLine,
colorLine);
// small dots above each bar
//if (offsetI > 0)
//{
//MyGuiManager.DrawSpriteBatch(MyGuiConstants.NETGRAPH_BG_TEXTURE.Texture,
// positionX,
// (positionY - offsetI - 1),
// 1,
// 1,
// top);
//VRageRender.MyRenderProxy.DebugDrawLine2D(
// new Vector2(positionX, positionY - offsetI),
// new Vector2(positionX, positionY - offsetI - 1),
// colorTop,
// colorTop);
//}
positionY -= (offsetI);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:29,代码来源:MyGuiScreenHudSpace.cs
示例19: MyVertexFormatPositionPackedColor
internal MyVertexFormatPositionPackedColor(Vector3 position, Color color)
{
Position = new HalfVector4(position.X, position.Y, position.Z, 1);
Color = new Byte4(color.PackedValue);
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyVertexFormats.cs
示例20: DrawNetgraphAverageLine
private void DrawNetgraphAverageLine(ref Vector2 position, float average1, float average2, float sizeMultiplier, Color color)
{
if (average1 != 0 || average2 != 0)
{
Vector2 pointFrom = new Vector2(position.X - 1, position.Y - average1 * sizeMultiplier);
Vector2 pointTo = new Vector2(position.X, position.Y - average2 * sizeMultiplier);
VRageRender.MyRenderProxy.DebugDrawLine2D(pointFrom, pointTo, color, color);
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:9,代码来源:MyGuiScreenHudSpace.cs
注:本文中的VRageMath.Color类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论