void Update() { if (Input.GetKeyDown(triggerBypass)) { bypass = !bypass; } if (Input.GetKeyDown(triggerNext)) { int blendModeIndex = (int)blendMode + 1; if (blendModeIndex >= blendModesCount) { blendModeIndex = 0; } blendMode = (BlendModes)blendModeIndex; SendBlendmodeChange(blendMode); } if (Input.GetKeyDown(triggerPrevious)) { int blendModeIndex = (int)blendMode - 1; if (blendModeIndex < 0) { blendModeIndex = blendModesCount - 1; } blendMode = (BlendModes)blendModeIndex; SendBlendmodeChange(blendMode); } if (deltaBlendMode != blendMode) { material.SetFloat("blendMode", (int)blendMode); } deltaBlendMode = blendMode; }
/// <summary> /// Draws an image on screen. /// </summary> /// <param name="image">Image to draw.</param> /// <param name="position">Drawing position.</param> /// <param name="size">Drawing size.</param> /// <param name="blend">Blend mode.</param> /// <param name="sourceRect">Source rectangle to draw.</param> /// <param name="origin">Rotation and source position origin (relative to size).</param> /// <param name="rotation">Rotation, in degrees.</param> /// <param name="color">Tint color.</param> public void DrawImage(ImageAsset image, PointF position, PointI size, BlendModes blend, RectangleI sourceRect, PointF origin, float rotation, Color color) { if (!image.HaveHandle) { throw new Exception("Tried to render an image without handle!"); } _BonEngineBind.BON_Gfx_DrawImageEx(image._handle, position.X, position.Y, size.X, size.Y, (int)blend, sourceRect.X, sourceRect.Y, sourceRect.Width, sourceRect.Height, origin.X, origin.Y, rotation, color.R, color.G, color.B, color.A); }
/// <summary> /// Draws an image on screen. /// </summary> /// <param name="image">Image to draw.</param> /// <param name="position">Drawing position.</param> /// <param name="size">Drawing size.</param> /// <param name="blend">Blend mode.</param> public void DrawImage(ImageAsset image, PointF position, PointI size, BlendModes blend = BlendModes.AlphaBlend) { if (!image.HaveHandle) { throw new Exception("Tried to render an image without handle!"); } _BonEngineBind.BON_Gfx_DrawImage(image._handle, position.X, position.Y, size.X, size.Y, (int)blend); }
void Update() { if (Input.GetKeyDown(KeyCode.M)) { bypass = !bypass; } if (Input.GetKeyDown(KeyCode.RightBracket)) { int blendModeIndex = (int)blendMode + 1; if (blendModeIndex >= blendModesCount) { blendModeIndex = 0; } blendMode = (BlendModes)blendModeIndex; SendBlendmodeChange(blendMode); } if (Input.GetKeyDown(KeyCode.LeftBracket)) { int blendModeIndex = (int)blendMode - 1; if (blendModeIndex < 0) { blendModeIndex = blendModesCount - 1; } blendMode = (BlendModes)blendModeIndex; SendBlendmodeChange(blendMode); } if (deltaBlendMode != blendMode) { material.SetFloat("blendMode", (int)blendMode); } deltaBlendMode = blendMode; }
void SendBlendmodeChange(BlendModes b) { if (OnSwitched != null) OnSwitched(b); }
public LWF(Data lwfData, IRendererFactory r) #endif { m_data = lwfData; interactive = m_data.buttonConditions.Length > 0; m_frameRate = m_data.header.frameRate; m_execLimit = 3; m_frameSkip = true; m_tick = 1.0f / m_frameRate; m_roundOffTick = m_tick * ROUND_OFF_TICK_RATE; m_attachVisible = true; m_interceptByNotAllowOrDenyButtons = true; m_intercepted = false; scaleByStage = 1.0f; m_needsUpdate = false; m_needsUpdateForAttachLWF = false; m_pointX = Single.MinValue; m_pointY = Single.MinValue; m_pressing = false; m_instanceId = ++m_instanceOffset; m_alive = true; #if LWF_USE_LUA m_luaState = l; m_instanceIdString = instanceId.ToString(); InitLua(); #endif if (!interactive && m_data.frames.Length == 1) DisableExec(); m_property = new Property(this); m_instances = new IObject[m_data.instanceNames.Length]; InitEvent(); m_movieCommands = new MovieCommands(); m_programObjectConstructors = new ProgramObjectConstructor[m_data.programObjects.Length]; m_textDictionary = new TextDictionary(); m_matrix = new Matrix(); m_matrixIdentity = new Matrix(); m_execMatrix = new Matrix(); m_colorTransform = new ColorTransform(); m_colorTransformIdentity = new ColorTransform(); m_execColorTransform = new ColorTransform(); m_blendModes = new BlendModes(); m_maskModes = new MaskModes(); Init(); SetRendererFactory(r); }
public void SetBlendMode(int mode) { _mode = (BlendModes)mode; switch (_mode) { case BlendModes.Blend: _states.BlendMode = BlendMode.Alpha; break; case BlendModes.Replace: _states.BlendMode = BlendMode.None; break; case BlendModes.Add: _states.BlendMode = BlendMode.Add; break; case BlendModes.Multiply: _states.BlendMode = BlendMode.Multiply; break; } _batch.Flush(); _batch.SetBlendMode(_states.BlendMode); }
void Update() { #if UNITY_EDITOR if (Application.isPlaying!=true) { SCShader = Shader.Find("Custom/MomoMirror"); } #endif if (Input.GetKeyDown(KeyCode.M)) { bypass = !bypass; } if (Input.GetKeyDown(KeyCode.RightBracket)) { int blendModeIndex = (int)blendMode + 1; if (blendModeIndex >= blendModesCount) { blendModeIndex = 0; } blendMode = (BlendModes)blendModeIndex; } if (Input.GetKeyDown(KeyCode.LeftBracket)) { int blendModeIndex = (int)blendMode - 1; if (blendModeIndex < 0) { blendModeIndex = blendModesCount - 1; } blendMode = (BlendModes)blendModeIndex; } if (deltaBlendMode != blendMode) { material.SetFloat("blendMode", (int)blendMode); UpdateLabel(); } deltaBlendMode = blendMode; }
private void Init() { PopulateFunctions(); _tex = new Texture((uint)_width, (uint)_height); _tex.Smooth = GlobalProps.SmoothTextures; Update(); _mode = BlendModes.Blend; DefineProperty("width", new PropertyDescriptor((int)_width, PropertyAttributes.Sealed), true); DefineProperty("height", new PropertyDescriptor((int)_height, PropertyAttributes.Sealed), true); }
public void SetBlendMode(int mode) { _mode = (BlendModes)mode; }
public static void SetPixelFast(byte* buffer, int offset, int c2, BlendModes m) { int* p = (int*)buffer + offset; if (m == BlendModes.Blend) { int c1 = *p; float w = (float)(c2 >> 24 & 0xff) / 255; int a1 = (c1 >> 24 & 0xff); int b1 = ((c1 & 0xff0000) >> 16); int g1 = ((c1 & 0xff00) >> 8); int r1 = (c1 & 0xff); int a2 = (c2 >> 24 & 0xff); int b2 = ((c2 & 0xff0000) >> 16); int g2 = ((c2 & 0xff00) >> 8); int r2 = (c2 & 0xff); int a = a1 > a2 ? a1 : a2; int b = (int)(w * (b2 - b1) + b1); int g = (int)(w * (g2 - g1) + g1); int r = (int)(w * (r2 - r1) + r1); *p = a << 24 | b << 16 | g << 8 | r; } else *p = c2; }
/// <summary> /// Draws an image on screen. /// </summary> /// <param name="image">Image to draw.</param> /// <param name="position">Drawing position.</param> /// <param name="size">Drawing size.</param> /// <param name="blend">Blend mode.</param> /// <param name="sourceRect">Source rectangle to draw.</param> public void DrawImage(ImageAsset image, PointF position, PointI size, BlendModes blend, RectangleI sourceRect) { DrawImage(image, position, size, blend, sourceRect, PointF.Zero, 0.0f, Color.White); }
/// <summary> /// Draws an image on screen. /// </summary> /// <param name="image">Image to draw.</param> /// <param name="position">Drawing position.</param> /// <param name="size">Drawing size.</param> /// <param name="blend">Blend mode.</param> public void DrawImage(ImageAsset image, PointF position, PointI size, BlendModes blend = BlendModes.AlphaBlend) { _BonEngineBind.BON_Gfx_DrawImage(image._handle, position.X, position.Y, size.X, size.Y, (int)blend); }
/// <summary> /// Draws a circle. /// </summary> /// <param name="center">Circle center.</param> /// <param name="radius">Circle radius.</param> /// <param name="color">Drawing color.</param> /// <param name="filled">Draw filled / hollow circle.</param> /// <param name="blend">Blend mode.</param> public void DrawCircle(PointI center, int radius, Color color, bool filled, BlendModes blend = BlendModes.AlphaBlend) { _BonEngineBind.BON_Gfx_DrawCircle(center.X, center.Y, radius, color.R, color.G, color.B, color.A, filled, (int)blend); }
/// <summary> /// Draws a rectangle. /// </summary> /// <param name="rectangle">Rectangle to draw.</param> /// <param name="color">Drawing color.</param> /// <param name="filled">Draw filled / hollow rectangle.</param> /// <param name="blend">Blend mode.</param> public void DrawRectangle(RectangleI rectangle, Color color, bool filled, BlendModes blend = BlendModes.AlphaBlend) { _BonEngineBind.BON_Gfx_DrawRectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, color.R, color.G, color.B, color.A, filled, (int)blend); }
/// <summary> /// Draws an image on screen. /// </summary> /// <param name="image">Image to draw.</param> /// <param name="position">Drawing position.</param> /// <param name="blend">Blend mode.</param> public void DrawImage(ImageAsset image, PointF position, BlendModes blend = BlendModes.AlphaBlend) { DrawImage(image, position, PointI.Zero, blend); }