public static void DrawRectangle(this SpriteBatch s, Rectangle rect, RectStyle style, Color color, float thickness = 1, float layer = 0) { DrawLine(s, (rect.Location.ToVector2(), new Vector2(rect.Right, rect.Top)), color, thickness, style, layer); DrawLine(s, (new Vector2(rect.Right, rect.Top), new Vector2(rect.Right, rect.Bottom)), color, thickness, style, layer); DrawLine(s, (new Vector2(rect.Right, rect.Bottom), new Vector2(rect.Left, rect.Bottom)), color, thickness, style, layer); DrawLine(s, (new Vector2(rect.Left, rect.Bottom), rect.Location.ToVector2()), color, thickness, style, layer); }
/// <summary> /// Draws a rectangle with the thickness provided /// </summary> /// <param name="spriteBatch">The destination drawing surface</param> /// <param name="rect">The rectangle to draw</param> /// <param name="color">The color to draw the rectangle in</param> /// <param name="thickness">The thickness of the lines</param> public static Action <SpriteBatch> DrawRectangle(this Rectangle rect, Color color, float thickness) { // TODO: Handle rotations // TODO: Figure out the pattern for the offsets required and then handle it in the line instead of here return((sp) => { DrawLine(new Vector2(rect.X, rect.Y), new Vector2(rect.Right, rect.Y), color, thickness)(sp); // top DrawLine(new Vector2(rect.X + 1f, rect.Y), new Vector2(rect.X + 1f, rect.Bottom + thickness), color, thickness)(sp); // left DrawLine(new Vector2(rect.X, rect.Bottom), new Vector2(rect.Right, rect.Bottom), color, thickness)(sp); // bottom DrawLine(new Vector2(rect.Right + 1f, rect.Y), new Vector2(rect.Right + 1f, rect.Bottom + thickness), color, thickness)(sp); // right }); }
/// <summary> /// Draws a line from point1 to point2 with an offset /// </summary> /// <param name="spriteBatch">The destination drawing surface</param> /// <param name="point1">The first point</param> /// <param name="point2">The second point</param> /// <param name="color">The color to use</param> /// <param name="thickness">The thickness of the line</param> public static Action <SpriteBatch> DrawLine(this Vector2 point1, Vector2 point2, Color color, float thickness) { return((sp) => { // calculate the distance between the two vectors float distance = Vector2.Distance(point1, point2); // calculate the angle between the two vectors float angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X); DrawLine(point1, distance, angle, color, thickness)(sp); }); }
/// <summary> /// Draws a list of connecting points /// </summary> /// <param name="spriteBatch">The destination drawing surface</param> /// /// <param name="position">Where to position the points</param> /// <param name="points">The points to connect with lines</param> /// <param name="color">The color to use</param> /// <param name="thickness">The thickness of the lines</param> private static Action <SpriteBatch> DrawPoints(Vector2 position, List <Vector2> points, Color color, float thickness) { return((sp) => { if (points.Count < 2) { return; } for (int i = 1; i < points.Count; i++) { DrawLine(points[i - 1] + position, points[i] + position, color, thickness)(sp); } }); }
void Start() { //use find because cells dynamically generated controlSc = GameObject.Find("InputHandler").GetComponent <Control>(); gameSc = GameObject.Find("GameController").GetComponent <Game>(); drawerSc = GameObject.Find("Drawer").GetComponent <DrawLine>(); }
void OnLinkClick(GameObject target) { var link = Instantiate(points, new Vector3(mouseWorldSpace.x, mouseWorldSpace.y, 0f), transform.rotation) as GameObject; len = GameObject.FindGameObjectsWithTag("Point"); bool pointWithNameFound = false; for (int x = 0; x < len.Length; x++) { for (int z = 0; z < len.Length; z++) { if (GameObject.FindGameObjectsWithTag("Point")[z].name == ("Point" + (x + 1))) { pointWithNameFound = true; } } if (!pointWithNameFound) { link.name = "Point" + (x + 1); } pointWithNameFound = false; } DrawLine liner = link.GetComponent <DrawLine>(); liner.target = target; }
private void picBox_MouseUp(object sender, MouseEventArgs e) { _endPoint = new Point(e.X, e.Y); var action = new DrawLine(); var bitmap = new Bitmap(picBox.Image); action.UndoAction = delegate { picBox.Image = bitmap; picBox.Refresh(); }; action.ExecuteAction = delegate { var buffer = new Bitmap(picBox.Image); using (var graphics = Graphics.FromImage(buffer)) { graphics.DrawLine(Pens.Black, _startPoint, _endPoint); picBox.Image = buffer; picBox.Refresh(); } }; AddAction(action); action.ExecuteAction(); }//뒤로 가기버튼(그림판 기능)
void Awake() { if (instance == null) { instance = this; } }
private Vector3 memoryPosition; // 引く時のPositionを private void Start() { input = new PlayerInput(); move = new PlayerTeleport(); drawLine = new DrawLine(line); rope = new DrawrRope(line); pull = new ControllerPull(); cursorFunction = new CursorPosition(); runaway = new PlayerRunaway(); anchorAction = new AnchorShoot(); postProcess = eye.GetComponent <PostProcessingBehaviour>(); cameraFade = new CameraFade(); playerMap = new PlayerMap( ); lineMt = line.GetComponent <Renderer>().material; banCurcor.SetActive(false); cursor = pointCursor; goleMapSwitch = true; arrowCursor.SetActive(false); hibana.gameObject.SetActive(false); pullBody.SetActive(false); map.SetActive(false); particle.SetActive(false); viveDevice = SteamVR_Controller.Input((int)viveRightController.GetComponent <SteamVR_RenderModel>().index); fadeMt = fadeObject.GetComponent <MeshRenderer>().material; FadeInStart(); }
private void button5_Click(object sender, EventArgs e) { Image2D imageLines = new Image2D(200, 200); int type = Convert.ToInt32(textBox3.Text); switch (type) { case 1: line = ImageProcessor.line1; break; case 2: line = ImageProcessor.line2; break; case 3: line = ImageProcessor.line3; break; case 4: line = ImageProcessor.line4; break; } for (int i = 0; i < 13; i++) { double alpha = 2 * i * Math.PI / 13; line(100, 100, Convert.ToInt32(100 + 95 * Math.Cos(alpha)), Convert.ToInt32(100 + 95 * Math.Sin(alpha)), imageLines, new ColorRGB(255, 0, 0)); } Bitmap resultImageLines = ImageProcessor.Image2DtoBitmap(imageLines); pictureBox1.Image = resultImageLines; }
void MyGUI(SceneView sv) { DrawLine dl = target as DrawLine; if (dl == null || dl.GameObjects == null) { return; } Vector3 center = dl.transform.position; for (int i = 0; i < dl.GameObjects.Length; i++) { if (dl.GameObjects[i] != null) { Handles.DrawLine(center, dl.GameObjects[i].transform.position); } } Handles.BeginGUI(); GUILayout.BeginArea(new Rect(10, 10, 100, 100)); if (GUILayout.Button("Reset")) { Debug.Log("I'm active"); dl.transform.position = Vector3.zero; } GUILayout.EndArea(); Handles.EndGUI(); Handles.color = CustomColors.puce; Handles.DrawWireArc(dl.transform.position, dl.transform.up, -dl.transform.right, dl.shieldArc, dl.shieldArea); dl.shieldArea = Handles.ScaleValueHandle(dl.shieldArea, dl.transform.position + dl.transform.forward * dl.shieldArea, dl.transform.rotation, 2, Handles.ConeCap, 1); }
void Start() { ShipRes = GameObject.Find("Ship").GetComponent <ShipRes>(); fuelBar = GameObject.Find("FuelBar").transform.Find("Status Fill 01").GetComponent <SimpleHealthBar>(); foodBar = GameObject.Find("FoodBar").transform.Find("Status Fill 01").GetComponent <SimpleHealthBar>(); DrawLine = GameObject.Find("Grabber").GetComponent <DrawLine>(); }
private void OnTriggerEnter(Collider other) { // If the InkProjector GameObject enters this trigger. DrawLine otherDL = other.GetComponent <DrawLine>(); if (otherDL) { // Change the width of the interacting InkProjector and activate/deactivate meshes. otherDL.curWidth = width; if (width == .025f) { otherDL.needleMeshes[1].enabled = false; otherDL.needleMeshes[2].enabled = false; } else if (width == .05f) { otherDL.needleMeshes[1].enabled = true; otherDL.needleMeshes[2].enabled = false; } else if (width == .1f) { otherDL.needleMeshes[1].enabled = true; otherDL.needleMeshes[2].enabled = true; } } }
public void CheckVisibleTiles() { GameObject DrawLine = GameObject.Find("LineRenderer"); DrawLine drawLine = DrawLine.GetComponent <DrawLine> (); visibleTiles = new List <Node>(); drawLine.skillDistance = 20; GameObject Player = GameObject.Find(selecterPlayer); PlayableCharacter player = Player.GetComponent <PlayableCharacter> (); // player.VisibleNodes = null; GameObject[] Tiles = GameObject.FindGameObjectsWithTag("Hex"); foreach (GameObject tile in Tiles) { ClickableTile clickableTile = tile.GetComponent <ClickableTile> (); bool allowed = drawLine.CalculateLine(player.PlayerClass.TileX, player.PlayerClass.TileY, clickableTile.tileX, clickableTile.tileY); if (allowed) { // clickableTile.hexVisible = true; visibleTiles.Add(graph[clickableTile.tileX, clickableTile.tileY]); } else { // clickableTile.hexVisible = false; } } player.VisibleNodes = visibleTiles; }
private void Awake() { _instance = this; lineRenderer = GetComponent <LineRenderer>(); lineRenderer.startWidth = 0.05f; lineRenderer.endWidth = 0.05f; }
// Start is called before the first frame update void Start() { rbody = GetComponent <Rigidbody>(); mGroundCheck = GetComponent <GroundedCheck>(); groundCollider = GetComponent <Collider>(); mTrajectory = GetComponent <DrawLine>(); }
void Awake() { if (!Instance) { Instance = this; } }
// Update is called once per frame void Update() { if (GameObject.Find("RightHand").GetComponent <DrawLine>().Nodelete == true) { } //TODO:這可能是個地雷,需要改名 & 想一下是不是全部考慮到 else { FinalErase = GameObject.Find("RightHand").gameObject.GetComponent <DrawLine>(); Object = GameObject.Find("Eraser"); // sound_clear=GameObject.Find("clear_sound"); string[] stringSeparators = new string[] { "TEST" }; string[] result = gameObject.transform.name.Split(stringSeparators, StringSplitOptions.None); int a = int.Parse(result[1]); //sound_clear.transform.gameObject.SetActive(false);///嘗試 if (Object != null) { for (int i = 0; i < VerticeTransform.vertices.Length; i++) { float distance = Vector2.Distance(Object.transform.position, VerticeTransform.vertices[i]); if (distance < 0.02f) { // sound_clear.transform.gameObject.SetActive(true);///嘗試 Destroy(gameObject); Destroy(GameObject.Find("KDtree" + a)); FinalErase.RestartArray(a, Button); Button = false; } } } } //sound_clear.transform.gameObject.SetActive(false);///嘗試 }
/// <summary> /// Draws a line of the content. /// </summary> /// <param name="e">Event arguments.</param> protected virtual void OnDrawLine(DrawNodeLineEventArgs e) { DrawLine?.Invoke(this, e); if (e.Handled) { return; } var eContent = new GetLineContentsEventArgs(e.Node, e.LineIndex, Color.Empty); OnGetLineContents(eContent); if (eContent.ShowBar) { // Free space indicator using (Brush bBarBack = new SolidBrush(BarBackColor)) using (Brush bBarFill = new SolidBrush(!eContent.Color.IsEmpty ? eContent.Color : eContent.BarPercentage > BarCriticalPercentage ? BarCriticalFillColor : BarFillColor)) using (Pen pBarBorder = new Pen(BarBorderColor)) { e.Graphics.FillRectangle(bBarBack, e.Bounds); e.Graphics.FillRectangle(bBarFill, new RectangleF(e.Bounds.Left, e.Bounds.Top, e.Bounds.Width * eContent.BarPercentage, e.Bounds.Height)); e.Graphics.DrawRectangle(pBarBorder, Utility.ToRectangle(e.Bounds)); } } else { using (Brush brush = new SolidBrush(!eContent.Color.IsEmpty ? eContent.Color : e.LineIndex == 0 ? ForeColor : DetailTextColor)) using (StringFormat stringFormat = new StringFormat()) { e.Graphics.DrawString(eContent.Contents, Font, brush, e.Bounds, stringFormat); } } }
public void DrawLineROI(double row1 = 100, double col1 = 100, double row2 = 100, double col2 = 200) { if (bDrawing) { MessageHelper.ShowWarning("显示界面正在进行ROI操作!"); return; } if (Image == null) { return; } if (line == null) { line = new DrawLine(Window, Image, row1, col1, row2, col2); } else { line.Row1 = row1; line.Col1 = col1; line.Row2 = row2; line.Col2 = col2; } bDrawing = true; DrawingShape = ROIShape.Line; BindingLineROIEvent(); line.CreateROI(); }
// Start is called before the first frame update void Start() { pmove = GetComponent <PlayerMovement>(); mLine = GetComponent <LineRenderer>(); mDrawLine = GetComponent <DrawLine>(); oldLineMat = mLine.material; mLine.material = newLineMat; }
public void DrawFigure(DrawLine visLineFunc) { for (int i = 0; i < Points.Count; i++) { var j = (i + 1) % Points.Count; visLineFunc(Points[i].x, Points[i].y, Points[j].x, Points[j].y, Color.Black); } }
void Start() { GameObject go = GameObject.Find("Stone_Dungeon_Floor"); DrawLine drawLineObject = go.GetComponent <DrawLine> (); pointsList = drawLineObject.pointsList; line = drawLineObject.line; }
public FunctionThread(FunctionExecute functionExecute, DrawLine dl, double xStart, Dispatcher dispatcher) { this.m_FunctionExecute = functionExecute; this.m_DrawLine = dl; this.m_XStart = xStart; this.m_Dispatcher = dispatcher; m_From = m_FunctionExecute.Range.From; }
void Initialize() { _init = true; //Run Once DrawLine drawLineCache = GameObject.Find("DrawLine").GetComponent <DrawLine>(); this._splinePointDict = drawLineCache.GetSplineDict(); }
// Start is called before the first frame update void Start() { SpawnBall(); levelText.text = "Level 1"; drawScript = GetComponent <DrawLine>(); Time.timeScale = 0; bgRenderer.sprite = backgrounds[0]; }
// Start is called before the first frame update void Start() { StatsManager.OnGameOver += DisableOnGameOver; DrawLine = GetComponentInChildren <DrawLine>(); collider2D = GetComponent <CircleCollider2D>(); rb = GetComponent <Rigidbody2D>(); orbit = GetComponent <Orbit>(); }
// Start is called before the first frame update void Awake() { S = this; line = GetComponent <LineRenderer> (); line.enabled = false; points = new List <Vector3> (); }
void Start() { IsDrawLines = false; instance = this; Lines = new List <GameObject>(); linePoints = new Dictionary <int, List <string> >(); //points = new List<string>(); }
void Update() { if (Global_Variables.TimeStop) { DrawLine Line = GetComponentInChildren <DrawLine>(); Line.Dforward = TVelocity.normalized; Line.DScale = TVelocity.magnitude; } }
private void Awake () { if(lineDrawer == null) { lineDrawer = GetComponentInChildren<DrawLine>(); } if(lineDrawer != null) { lineDrawer.OnLinePointAdded += OnLinePointAdded; lineDrawer.OnLineDrawingStopped += OnDrawingStopped; } if(ritualNodes.Count < 1) { RitualNode[] nodes = GetComponentsInChildren<RitualNode>(); ritualNodes.AddRange(nodes); } nodeParent.SetActive (false); }
void Awake() { Instance = this; thisCamera = Camera.main; lineRenderer = GetComponent<LineRenderer>(); point = Resources.Load("Point") as GameObject; lineCollider = GetComponent<EdgeCollider2D>(); }
// Use this for initialization void Start() { lineDrawer = GetComponent<DrawLine> (); lineRenderer = GetComponent<LineRenderer> (); }
public void AddGraphPort(IGraphPort aPort) { SetPixelHandler += new NewTOAPIA.Drawing.SetPixel(aPort.SetPixel); DrawLineHandler += new DrawLine(aPort.DrawLine); DrawLinesHandler += new DrawLines(aPort.DrawLines); DrawRectangleHandler += new NewTOAPIA.Drawing.DrawRectangle(aPort.DrawRectangle); DrawRectanglesHandler += new NewTOAPIA.Drawing.DrawRectangles(aPort.DrawRectangles); FillRectangleHandler += new NewTOAPIA.Drawing.FillRectangle(aPort.FillRectangle); DrawEllipseHandler += new NewTOAPIA.Drawing.DrawEllipse(aPort.DrawEllipse); FillEllipseHandler += new NewTOAPIA.Drawing.FillEllipse(aPort.FillEllipse); DrawRoundRectHandler += new NewTOAPIA.Drawing.DrawRoundRect(aPort.DrawRoundRect); PolygonHandler += new NewTOAPIA.Drawing.Polygon(aPort.Polygon); DrawBeziersHandler += new NewTOAPIA.Drawing.DrawBeziers(aPort.DrawBeziers); DrawPathHandler += new NewTOAPIA.Drawing.DrawPath(aPort.DrawPath); FillPathHandler += new FillPath(aPort.FillPath); //// Gradient fills //DrawGradientRectangleHandler += new NewTOAPIA.Drawing.DrawGradientRectangle(aPort.DrawGradientRectangle); //// Drawing Text DrawStringHandler += new NewTOAPIA.Drawing.DrawString(aPort.DrawString); ///// Draw bitmaps PixBltHandler += new NewTOAPIA.Drawing.PixBlt(aPort.PixBlt); //PixmapShardBltHandler += new NewTOAPIA.Drawing.PixmapShardBlt(aPort.PixmapShardBlt); //AlphaBlendHandler += new NewTOAPIA.Drawing.AlphaBlend(aPort.AlphaBlend); // Path handling //DrawPathHandler += new NewTOAPIA.Drawing.DrawPath(aPort.DrawPath); //SetPathAsClipRegionHandler += new NewTOAPIA.Drawing.SetPathAsClipRegion(aPort.SetPathAsClipRegion); //// Setting some objects SetPenHandler += new NewTOAPIA.Drawing.SetPen(aPort.SetPen); SetBrushHandler += new SetBrush(aPort.SetBrush); SetFontHandler += new SetFont(aPort.SetFont); //SelectStockObjectHandler += new NewTOAPIA.Drawing.SelectStockObject(aPort.SelectStockObject); SelectUniqueObjectHandler += new NewTOAPIA.Drawing.SelectUniqueObject(aPort.SelectUniqueObject); //// State Management FlushHandler += new NewTOAPIA.Drawing.Flush(aPort.Flush); SaveStateHandler += new NewTOAPIA.Drawing.SaveState(aPort.SaveState); ResetStateHandler += new NewTOAPIA.Drawing.ResetState(aPort.ResetState); RestoreStateHandler += new NewTOAPIA.Drawing.RestoreState(aPort.RestoreState); //// Setting Attributes and modes SetTextColorHandler += new NewTOAPIA.Drawing.SetTextColor(aPort.SetTextColor); //// Setting some modes SetBkColorHandler += new NewTOAPIA.Drawing.SetBkColor(aPort.SetBkColor); SetBkModeHandler += new NewTOAPIA.Drawing.SetBkMode(aPort.SetBkMode); SetMappingModeHandler += new NewTOAPIA.Drawing.SetMappingMode(aPort.SetMappingMode); SetPolyFillModeHandler += new NewTOAPIA.Drawing.SetPolyFillMode(aPort.SetPolyFillMode); SetROP2Handler += new NewTOAPIA.Drawing.SetROP2(aPort.SetROP2); SetClipRectangleHandler += new SetClipRectangle(aPort.SetClipRectangle); // World transform management SetWorldTransformHandler += new NewTOAPIA.Drawing.SetWorldTransform(aPort.SetWorldTransform); TranslateTransformHandler += new TranslateTransform(aPort.TranslateTransform); ScaleTransformHandler += new ScaleTransform(aPort.ScaleTransform); RotateTransformHandler += new RotateTransform(aPort.RotateTransform); }