void CompositionTarget_Rendering(object sender, EventArgs e) { // Change the opacity of the fromLayer and toLayer double opacity = -1; if (animatingLayer == fromLayer) { opacity = Math.Max(0, fromLayer.Opacity - .05); fromLayer.Opacity = opacity; } else { opacity = Math.Min(1, toLayer.Opacity + .05); toLayer.Opacity = opacity; } // When transition complete, set reset properties and unhook handler if (opacity == 1 || opacity == 0) { fromLayer.Opacity = 0; fromLayer.Visible = false; animatingLayer = null; CompositionTarget.Rendering -= CompositionTarget_Rendering; // If layer pending animation, start fading if (pendingLayer != null) Fade(toLayer, pendingLayer); pendingLayer = null; } }
public void Draw(Layer layer) { if (activeItem != null) { switch (activeItem.NextItem) { case TriggerType.MessageClose : break; default : SpriteBatch spriteBatch = GameState.spriteBatch; spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, Settings.spriteScale); foreach (TutorialPair pair in activeItem.PairList) { if (pair.Kind == PositionKind.POS_2D && layer == Layer.Layer3) { TextWrapping.DrawStringOnScreen(pair.Text, font, Settings.colorMainText, pair.Position.X, pair.Position.Y, spriteBatch, 50f); } else if (pair.Kind == PositionKind.POS_3D && layer == Layer.Layer1) { BoundingFrustum frustum = new BoundingFrustum(GameState.view * GameState.projection); ContainmentType containmentType = frustum.Contains(Vector3.Transform(new Vector3(0.0f, 0.0f, 0.0f), pair.World)); if (containmentType != ContainmentType.Disjoint) { Vector3 point3D = GameState.game.GraphicsDevice.Viewport.Project(new Vector3(0.0f, 0.0f, 0.0f), GameState.projection, GameState.view, pair.World); TextWrapping.DrawStringOnScreen(pair.Text, font, Settings.colorMainText, Settings.UnScaleW(point3D.X) + pair.Position.X, Settings.UnScaleH(point3D.Y) + pair.Position.Y, spriteBatch, 50f); } } } spriteBatch.End(); break; } } }
void NumberOfNeuronsChanged(Layer layer) { dgvTrainingSets.Rows.Clear(); dgvTrainingSets.Columns.Clear(); dgvValidationSets.Rows.Clear(); dgvValidationSets.Columns.Clear(); int c = 0; for (int i = 1; i <= NN.InputLayer.NumberOfNeurons; i++) { dgvTrainingSets.Columns.Add("col" + c++, "Input " + i); } for (int i = 1; i <= NN.OutputLayer.NumberOfNeurons; i++) { dgvTrainingSets.Columns.Add("col" + c++, "Output " + i); } c = 0; for (int i = 1; i <= NN.InputLayer.NumberOfNeurons; i++) { dgvValidationSets.Columns.Add("col" + c++, "Input " + i); } for (int i = 1; i <= NN.OutputLayer.NumberOfNeurons; i++) { dgvValidationSets.Columns.Add("col" + c++, "Output " + i); } }
public void Draw( Layer layer, Texture2D atlas, Rectangle offset, Vector2 position ) { Debug.Assert( atlas != null, "Texture must be valid" ); Debug.Assert( mSpritesToDraw.Count > (int) layer, "There is so such layer" ); mSpritesToDraw[(int)layer].Add( new SpriteRenderInfo( atlas, offset, position ) ); }
public void LayerTest() { TestManager.Helpers.CreateTestScene("LayerTest.scene"); IScene scene = EditorManager.Scene; Assert.IsTrue(scene.Save()); Assert.AreEqual(1,scene.Layers.Count); // default layer should be active Assert.IsNotNull(scene.ActiveLayer); Assert.AreEqual(1,scene.Layers.Count); Layer layer1 = new Layer("added1"); scene.AddLayer(layer1,false); Assert.AreEqual(2,scene.Layers.Count); Layer layer2 = new Layer("added2"); scene.AddLayer(layer2,true); Assert.AreEqual(3,scene.Layers.Count); Assert.AreEqual(layer2,scene.ActiveLayer); Assert.IsTrue(scene.RemoveLayer(layer2)); Assert.IsNotNull(scene.ActiveLayer); Assert.IsFalse(layer2==scene.ActiveLayer); TestManager.Helpers.CloseTestProject(); }
private void MoveCaravan(Layer layer, Caravan caravan) { var d = layer.Sections[1].gameObject.transform.position.x * -1; Vector3 normal; float y; layer.Sections[1].GetAt(d, out normal, out y); caravan.Followers[0].SetPosition(new Vector3(0, layer.Sections[1].gameObject.transform.position.y + y, 0)); caravan.Followers[0].SetRotation(new Vector3(0, 0, (float)(Mathf.Rad2Deg * Math.Atan2(normal.y, normal.x)) - 90)); for (int i = 1; i < caravan.Followers.Count; i++) { var del = (layer.Sections[1].gameObject.transform.position.x * -1) - i * 1.5f; if (del >= 0) { d = del; layer.Sections[1].GetAt(d, out normal, out y); caravan.Followers[i].SetPosition(new Vector3(0 - i * 1.5f, layer.Sections[1].gameObject.transform.position.y + y, 0)); caravan.Followers[i].SetRotation(new Vector3(0, 0, (float) (Mathf.Rad2Deg*Math.Atan2(normal.y, normal.x)) - 90)); } else { d = layer.SectionLength + del; layer.Sections[0].GetAt(d, out normal, out y); caravan.Followers[i].SetPosition(new Vector3(0 - i * 1.5f, layer.Sections[0].gameObject.transform.position.y + y, 0)); caravan.Followers[i].SetRotation(new Vector3(0, 0, (float) (Mathf.Rad2Deg*Math.Atan2(normal.y, normal.x)) - 90)); } } }
public virtual void OnLayerChanged(Layer newLayer, Layer oldLayer) { if (LayerChangedEventHandler != null) { LayerChangedEventHandler(this, new LayerChangedEventArgs { NewLayer = newLayer, OldLayer = oldLayer }); } }
public void Think_CausesEachNeuronInLayerToThink() { Layer layer = new Layer(numberOfNeurons: 2); // Give each neuron one input and one output. layer.Neurons[0].Inputs.Add(new Synapse { Weight = 1, Value = 4 }); layer.Neurons[1].Inputs.Add(new Synapse { Weight = 2, Value = 3 }); layer.Neurons[0].Outputs.Add(new Synapse()); layer.Neurons[1].Outputs.Add(new Synapse()); // Reset the biases since we know they are randomized, and we want to disregard them. layer.Neurons[0].Bias = layer.Neurons[1].Bias = 0; // Execute the code to test. layer.Think(); // Validate that each neuron sets the value for its output. // -4 is the sum of the neurons bias and all its inputs weights times their value. Assert.AreEqual( 1 / (1 + Math.Pow(Math.E, -4)), layer.Neurons[0].Outputs[0].Value, "First neuron output"); // -6 is the sum of the neurons bias and all its inputs weights times their value. Assert.AreEqual( 1 / (1 + Math.Pow(Math.E, -6)), layer.Neurons[1].Outputs[0].Value, "Second neuron output"); }
public DeleteLayerHistoryMemento(string name, ImageResource image, IHistoryWorkspace historyWorkspace, Layer deleteMe) : base(name, image) { this.historyWorkspace = historyWorkspace; this.index = historyWorkspace.Document.Layers.IndexOf(deleteMe); this.Data = new DeleteLayerHistoryMementoData(deleteMe); }
public Highlight() { Color = Color.White; Layer = SpriteManager.AddLayer(); Layer.Name = "GlueView Highlight shapes layer"; mHighlightShapes = new List<Polygon>(); }
public void Constructor_CreatesCorrectNumberOfNeurons() { Layer layer = new Layer(numberOfNeurons: 5); Assert.AreEqual(5, layer.Neurons.Count); Assert.IsTrue(layer.Neurons.All(n => n != null)); }
public AddBrick(LayerBrick layer, Layer.LayerItem brickOrGroup) { mBrickLayer = layer; mBrickOrGroup = brickOrGroup; // after setting the brick or group, call the init brick list function initBrickList(); }
public StateEditor(int Row, int Column) : base(StateID.Editor) { //Draw Cursor m_VisibleCursor = true; //Set Values BoardRow = Row; BoardColumn = Column; SelectedHeight = 1; SelectedWidth = 1; //Nulling Stuffs m_Data = null; m_Buttons = null; m_MenuButtons = null; m_Sky = null; m_SkyLayer = null; m_Arrow = null; m_Ships = null; m_Board = null; m_SideBar = null; m_SideBarPanel = null; m_Window = null; m_Help = null; }
private void Fade(Layer from, Layer to) { // If in process of animating if (animatingLayer != null) { pendingLayer = to; return; } pendingLayer = null; to.Opacity = 0; to.Visible = true; Dispatcher.BeginInvoke(() => { if (progress >= 97) StartFade(from, to); else // Wait for layer to load before fading to it { EventHandler<ProgressEventArgs> handler = null; handler = (s, e) => { if (e.Progress >= 97) { MyMap.Progress -= handler; StartFade(from, to); } }; MyMap.Progress += handler; } }); }
public ScalableElementRuntime(IElement elementSave, Layer layerProvidedByContainer, NamedObjectSave namedObjectSave, EventHandler<VariableSetArgs> onBeforeVariableSet, EventHandler<VariableSetArgs> onAfterVariableSet) : base(elementSave, layerProvidedByContainer, namedObjectSave, onBeforeVariableSet, onAfterVariableSet) { }
public ReactiveHud() { mMarkerLayer = SpriteManager.AddLayer(); #region Create the Sprite Over Marker mSpriteOverMarker = SpriteManager.AddSprite( FlatRedBallServices.Load<Texture2D>("Content/smallSquareClear.bmp", AppState.Self.PermanentContentManager), mMarkerLayer); mSpriteOverMarker.RelativeZ = -.0001f; mSpriteOverMarker.Visible = false; mSpriteOverMarker.Alpha = 100; #endregion #region Create the Current Emitter Marker mCurrentEmitterMarker = SpriteManager.AddSprite( FlatRedBallServices.Load<Texture2D>("Content/smallSquare.bmp", AppState.Self.PermanentContentManager), mMarkerLayer); mCurrentEmitterMarker.Visible = false; #endregion mEmissionAreaVisibleRepresentation = new EmissionAreaVisibleRepresentation(); }
public LayeredItem(Board board, Layer layer, int zm, int x, int y, int z) : base(board, x, y, z) { this.layer = layer; layer.Items.Add(this); this.zm = zm; }
public Background(GraphicsDeviceManager graphics, Color backgroundColor, Layer[] layerList) { _graphics = graphics; BackgroundColor = backgroundColor; _layerList = new List<Layer>(); _layerList.AddRange(layerList); }
public override bool Execute() { var layer = new Layer(SelectedLayer); ActiveImage.InsertLayer(layer, 0); if (_name != null) { layer.Name = _name; } else { var rx = new Regex(@"(.* copy)(.+)"); var m = rx.Match(layer.Name); if (m.Groups.Count == 3) { int nr = Convert.ToInt32("1") + 1; layer.Name = m.Groups[1] + " " + nr; } } ActiveDrawable = layer; SelectedLayer = layer; return true; }
/// <summary> /// This function adds a given layer to the tree. /// </summary> /// <param name="layer">The layer that is being added. </param> public void AddLayerToTree(Layer layer) { MenuItem root = new MenuItem() { Title = "Location" }; root.Items.Add(new MenuItem() { Title = "Time" }); //TreeViewItems.Add(root); //LayerView.Items.Add(root); }
//liczba warstw i neuronow w kazdej warstwie public Perceptron(int[] neurons) { layerList = new List<Layer>(); if (neurons == null) { throw new Exception("Bad parameters for perceptron constructor"); } int layers = neurons.Length; this.inputSize = neurons[0]; this.outputSize = neurons[layers - 1]; Random r = new Random(); for (int i = 0; i < layers; i++) { Layer l = new Layer(i,neurons[i]); layerList.Add(l); } /* for (int i = 0; i < layers-1; i++) { for (int j = 0; j < neurons[i+1]; j++) { List<Neuron> l = this.layerList[i].getNeuronList(); Neuron n = this.layerList[i+1].getNeuronIndex(j); for (int k = 0; k < l.Count; k++) { n.addToHashtable(l[k],0.1);//r.NextDouble() ); } } }*/ SetRandomWeights(); }
public AddLayer(string layerType, bool updateLayerView) { // update the view unless specified by the parameter. // This param can be null in case we want to create several layer and updating the view at the end (which is the case at startup) // but we won't keep that settings after the first redo mUpdateLayerView = updateLayerView ? UpdateViewType.FULL : UpdateViewType.NONE; mLayerType = layerType; // create the layer according to the type // if the layer does not exists switch (layerType) { case "LayerGrid": mLayerAdded = new LayerGrid(); break; case "LayerBrick": mLayerAdded = new LayerBrick(); break; case "LayerText": mLayerAdded = new LayerText(); break; case "LayerArea": mLayerAdded = new LayerArea(); break; case "LayerRuler": mLayerAdded = new LayerRuler(); break; } }
void CalcNoise(Layer layer) { // For each pixel in the texture... for (int x = 0; x < noiseTex.width; x++) { for (int y = layer.start[x]; y < layer.end[x]; y++) { // Get a sample from the corresponding position in the noise plane // and create a greyscale pixel from it. float xCoord = layer.xOff + Mathf.Abs((float)x / (noiseTex.width / 2) - 1.0f) * layer.scale; float yCoord = layer.yOff + (float)y / noiseTex.height * layer.scale; float sample = Mathf.PerlinNoise(xCoord, yCoord); for(int i = 0; i < colors.Length; ++i) { if (sample < colors[i].threshold) { //pix[y * noiseTex.width + x] = colors[i].color; pix[y * noiseTex.width + x] = Color.Lerp(colors[i].color, layer.color, layer.ratio); break; } } } } // Copy the pixel data to the texture and load it into the GPU. noiseTex.SetPixels(pix); noiseTex.Apply(); }
public int UpdateLayer(Layer layerInfo) { var command = string.Format(SqlUpdateLayer, layerInfo.Caption, layerInfo.Description, layerInfo.ID, layerInfo.Visible ? 1 : 0, layerInfo.LineWidth, layerInfo.BorderWidth, layerInfo.Opacity, layerInfo.LineColor, layerInfo.RegionColor, layerInfo.BorderColor); return adapter.ExecuteNonQuery(command); }
public BaseClothing( int itemID, Layer layer, int hue ) : base(itemID) { Layer = layer; Hue = hue; m_Quality = CraftQuality.Regular; }
private void buttonAddLayer_Click(object sender, EventArgs e) { if (treeViewLayers.SelectedNode != null) { if (treeViewLayers.SelectedNode.Parent != null) { int index = treeViewLayers.SelectedNode.Parent.Nodes.IndexOf(treeViewLayers.SelectedNode); TreeNode newNode = treeViewLayers.SelectedNode.Parent.Nodes.Insert(index + 1, "untitled"); Layer newLayer = new Layer((Layer)treeViewLayers.SelectedNode.Parent.Tag); newLayer.AttachToTreeNode(newNode); Layer parentLayer = (Layer)treeViewLayers.SelectedNode.Parent.Tag; _scene.Layers.Add(newLayer, parentLayer); } else { int index = treeViewLayers.Nodes.IndexOf(treeViewLayers.SelectedNode); TreeNode newNode = treeViewLayers.Nodes.Insert(index + 1, "untitled"); Layer newLayer = new Layer(null); newLayer.AttachToTreeNode(newNode); _scene.Layers.Add(newLayer); } } }
protected override void WriteAttributes(Layer layer) { base.WriteAttributes(layer); ArcGISDynamicMapServiceLayer dynamicLayer = layer as ArcGISDynamicMapServiceLayer; if (dynamicLayer != null) { WriteAttribute("Url", dynamicLayer.Url); if (!LayerExtensions.GetUsesProxy(layer)) { if (!string.IsNullOrEmpty(dynamicLayer.ProxyURL)) { WriteAttribute("ProxyURL", dynamicLayer.ProxyURL); } if (!string.IsNullOrEmpty(dynamicLayer.Token)) { WriteAttribute("Token", dynamicLayer.Token); } } if (dynamicLayer.VisibleLayers != null) { string visibleLayersStr = string.Empty; if (dynamicLayer.VisibleLayers.Length > 0) { foreach (int layerId in dynamicLayer.VisibleLayers) { visibleLayersStr += layerId.ToString() + ','; } visibleLayersStr = visibleLayersStr.TrimEnd(','); } WriteAttribute("VisibleLayers", visibleLayersStr); } } }
/// <summary> /// Initializes a new instance of the <see cref="RecurrentContext" /> class. /// </summary> /// <param name='sourceNode'> /// Source node. /// </param> /// <param name='rateOfUpdate'> /// Rate of update. /// </param> /// <param name='parentLayer'> /// Parent layer. /// </param> /// <param name='activationFunction'> /// Activation function. /// </param> public RecurrentContext(Base sourceNode, Double rateOfUpdate, Layer.Base parentLayer, ActivationFunction.Base activationFunction) : base(parentLayer, activationFunction) { _Value = 0.0f; _SourceNode = sourceNode; _RateOfUpdate = rateOfUpdate; }
public static Symbol GetDefaultSymbolForLayer(Layer layer) { GraphicsLayer graphicsLayer = layer as GraphicsLayer; if (graphicsLayer != null) { ClassBreaksRenderer renderer = graphicsLayer.Renderer as ClassBreaksRenderer; if (renderer != null) return renderer.DefaultSymbol; else { ConfigurableFeatureLayer featureLayer = layer as ConfigurableFeatureLayer; if (featureLayer != null) { if (featureLayer.FeatureSymbol != null) return featureLayer.FeatureSymbol; else { // All Graphics share the same symbol. Return a reference to the first one if (featureLayer.Graphics.Count > 0) return featureLayer.Graphics[0].Symbol; } } else { // All Graphics share the same symbol. Return a reference to the first one if (graphicsLayer.Graphics.Count > 0) return graphicsLayer.Graphics[0].Symbol; } } } return null; }
public override void Render(Image image, double x, double y, double w, double h) { if (_convert) { x *= _resolution; y *= _resolution; w *= _resolution; h *= _resolution; } int ix = (int) x; int iy = (int) y; int iw = (int) w; int ih = (int) h; var clone = RotateAndScale(image, w, h); int tw = clone.Width; int th = clone.Height; Layer layer = new Layer(clone.ActiveDrawable, _composed); ix += (iw - tw) / 2; iy += (ih - th) / 2; layer.Translate(ix, iy); // clone.Delete(); _composed.InsertLayer(layer, -1); }