void Update() { if (Input.touchCount > 0) { touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Began) { line.points2.Clear(); line.Draw(); previousPosition = touch.position; line.points2.Add(touch.position); canDraw = true; } else if (touch.phase == TouchPhase.Moved && (touch.position - previousPosition).sqrMagnitude > sqrMinPixelMove && canDraw) { previousPosition = touch.position; line.points2.Add(touch.position); if (line.points2.Count >= maxPoints) { canDraw = false; } line.Draw(); } } }
void MakeGrid2() { List <Vector2> points2 = new List <Vector2>(); Rect realRect = DrawHelper.GetRealRect(camera2d); float xMin = realRect.xMin; float xMax = realRect.xMax; List <float> widths = new List <float>(); int startX = (int)xMin % gridUnit == 0? (int)xMin : ((int)xMin / gridUnit) * gridUnit; for (float x = startX; x <= xMax; x = x + gridUnit) { float pixelX = (x - xMin) / DrawHelper.Scale; points2.Add(new Vector2(pixelX, 0)); points2.Add(new Vector2(pixelX, camera2d.pixelHeight - 1)); if (Mathf.Approximately(x, 0)) { widths.Add(4.0f); } else { widths.Add(1.0f); } } float yMin = realRect.yMin; float yMax = realRect.yMax; int startY = (int)yMin % gridUnit == 0? (int)yMin : ((int)yMin / gridUnit) * gridUnit; for (float y = startY; y <= yMax; y = y + gridUnit) { float pixelY = (y - yMin) / DrawHelper.Scale; points2.Add(new Vector2(0, pixelY)); points2.Add(new Vector2(camera2d.pixelWidth - 1, pixelY)); if (Mathf.Approximately(y, 0)) { widths.Add(4.0f); } else { widths.Add(1.0f); } } gridLine.Resize(points2.Count); for (int i = 0; i < points2.Count; i++) { gridLine.points2[i] = points2[i]; } gridLine.SetWidths(widths); gridLine.SetColor(Color.gray); gridLine.Draw(); }
public void Update() { //NOTE: needs optimization - check for change if (_Model.Path != null && _Model.Path.Count > 0) { List <Vector2> pathPoints = ShanghaiUtils.GetScreenCoordsFromCellKeys(_Model.Path, _Model.CellPositions); if (pathPoints.Count >= 2) { _ColourPath.Resize(pathPoints.ToArray()); _OutlinePath.Resize(pathPoints.ToArray()); _ColourPathMaterial.SetColor("_TintColor", ShanghaiUtils.GetColour(_Model.PathColour)); _ColourPath.active = true; _ColourPath.Draw(); _OutlinePath.active = true; _OutlinePath.Draw(); } } else { _ColourPath.active = false; _ColourPath.Draw(); _OutlinePath.active = false; _OutlinePath.Draw(); } }
public void UpdateLine(int objectNumber, Vector2 pos, GameObject go) { var oldPos = controlLine.points2[objectNumber]; // Get previous position, so we can make the control point move with the anchor point controlLine.points2[objectNumber] = pos; int curveNumber = objectNumber / 4; int curveIndex = curveNumber * 4; line.MakeCurve(controlLine.points2[curveIndex], controlLine.points2[curveIndex + 1], controlLine.points2[curveIndex + 2], controlLine.points2[curveIndex + 3], segments, curveNumber * (segments + 1)); // If it's an anchor point... if (objectNumber % 2 == 0) { // Move control point also controlLine.points2[objectNumber + 1] += pos - oldPos; go.GetComponent <CurvePointControl>().controlObject.transform.position = cam.ScreenToViewportPoint(controlLine.points2[objectNumber + 1]); // If it's not an end anchor point, move the next anchor/control points as well, and update the next curve if (objectNumber > 0 && objectNumber < controlLine.points2.Count - 2) { controlLine.points2[objectNumber + 2] = pos; controlLine.points2[objectNumber + 3] += pos - oldPos; go.GetComponent <CurvePointControl>().controlObject2.transform.position = cam.ScreenToViewportPoint(controlLine.points2[objectNumber + 3]); line.MakeCurve(controlLine.points2[curveIndex + 4], controlLine.points2[curveIndex + 5], controlLine.points2[curveIndex + 6], controlLine.points2[curveIndex + 7], segments, (curveNumber + 1) * (segments + 1)); } } line.Draw(); controlLine.Draw(); }
public void DestroySelf() { pathLine.points2.Clear(); pathLine.Draw(); GameEvents.current.onAnimationStart -= ClearDrawing; GameEvents.current.onAnimationEnd -= DrawDotLine; Destroy(this.gameObject); }
public void TransformGrid() { mat.SetRow(0, new Vector4(int.Parse(i1.text), int.Parse(i2.text), 0, 0)); mat.SetRow(1, new Vector4(int.Parse(i3.text), int.Parse(i4.text), 0, 0)); gridLine.matrix = mat; gridLine.Draw(); det.text = mat.determinant.ToString(); }
public void TransformGrid() { mat.SetRow(0, new Vector4(int.Parse(matin[0].text), int.Parse(matin[1].text), int.Parse(matin[2].text), int.Parse(matin[3].text))); mat.SetRow(1, new Vector4(int.Parse(matin[4].text), int.Parse(matin[5].text), int.Parse(matin[6].text), int.Parse(matin[7].text))); mat.SetRow(2, new Vector4(int.Parse(matin[8].text), int.Parse(matin[9].text), int.Parse(matin[10].text), int.Parse(matin[11].text))); mat.SetRow(3, new Vector4(int.Parse(matin[12].text), int.Parse(matin[13].text), int.Parse(matin[14].text), int.Parse(matin[15].text))); gridLine.matrix = mat; gridLine.Draw(); det.text = mat.determinant.ToString(); }
/// <summary> /// 绘制批注线 /// </summary> /// <param name="_vStart"></param> /// <param name="_vEnd"></param> private void DrawLine(Vector2 _vStart, Vector2 _vEnd) { points[0] = _vStart; points[1] = _vEnd; m_curline.Resize(points); m_curline.Draw(); }
public void UpdateLine() { if (myLine != null) { myLine.drawStart = currentPoint; //Si el waypoint actual no es el final... if (followPoints.Count > 0) { //myLine = new VectorLine("Line", followPoints, 2.0f,LineType.Continuous,Joins.Weld); // C# myLine.MakeSpline(followPoints.ToArray(), followPoints.Count); if (_Data.userType == UserController.UserType.Azul) { myLine.SetColor(Color.blue); } if (_Data.userType == UserController.UserType.Amarillo) { myLine.SetColor(Color.yellow); } if (_Data.userType == UserController.UserType.Green) { myLine.SetColor(Color.green); } if (_Data.userType == UserController.UserType.Rojo) { myLine.SetColor(Color.red); } myLine.Draw(); } } }
public void updatePts() { int i = 0; if (_isEnabled == false) { return; } _pts = new List <Vector2>(_points); /* * foreach (Vector2 pt in _points) * { * Vector2 tmpPt = new Vector2(); * tmpPt.y = pt.y * 3f; * tmpPt.x = pt.x; * tmpPt.x -= getMinX(); * // if (i == 0) * // Logger.Log(tmpPt); * _pts[i] = tmpPt; * i++; * } */ //_line.drawStart = 0; //_line.drawEnd = _points.Count - 1; _line.Draw(); }
void Start() { VectorLine.SetEndCap("arrow", EndCap.Front, lineTex, frontTex); VectorLine.SetEndCap("arrow2", EndCap.Both, lineTex2, frontTex, backTex); VectorLine.SetEndCap("rounded", EndCap.Mirror, lineTex3, capTex); var line1 = new VectorLine("Arrow", new List <Vector2>(50), 30.0f, LineType.Continuous, Joins.Weld); line1.useViewportCoords = true; var splinePoints = new Vector2[] { new Vector2(.1f, .15f), new Vector2(.3f, .5f), new Vector2(.5f, .6f), new Vector2(.7f, .5f), new Vector2(.9f, .15f) }; line1.MakeSpline(splinePoints); line1.endCap = "arrow"; line1.Draw(); var line2 = new VectorLine("Arrow2", new List <Vector2>(50), 40.0f, LineType.Continuous, Joins.Weld); line2.useViewportCoords = true; splinePoints = new Vector2[] { new Vector2(.1f, .85f), new Vector2(.3f, .5f), new Vector2(.5f, .4f), new Vector2(.7f, .5f), new Vector2(.9f, .85f) }; line2.MakeSpline(splinePoints); line2.endCap = "arrow2"; line2.continuousTexture = true; line2.Draw(); var line3 = new VectorLine("Rounded", new List <Vector2> { new Vector2(.1f, .5f), new Vector2(.9f, .5f) }, 20.0f); line3.useViewportCoords = true; line3.endCap = "rounded"; line3.Draw(); }
void Start() { use = this; // Reference to this script, so FindObjectOfType etc. are not needed cam = Camera.main; oldWidth = Screen.width; oldSegments = segments; // Set up initial curve points (also used for drawing the green lines that connect control points to anchor points) var curvePoints = new List <Vector2>(); curvePoints.Add(new Vector2(Screen.width * .25f, Screen.height * .25f)); curvePoints.Add(new Vector2(Screen.width * .125f, Screen.height * .5f)); curvePoints.Add(new Vector2(Screen.width - Screen.width * .25f, Screen.height - Screen.height * .25f)); curvePoints.Add(new Vector2(Screen.width - Screen.width * .125f, Screen.height * .5f)); // Make the control lines controlLine = new VectorLine("Control Line", curvePoints, 2.0f); controlLine.color = new Color(0.0f, .75f, .1f, .6f); controlLine.Draw(); // Make the line object for the curve line = new VectorLine("Curve", new List <Vector2>(segments + 1), lineTexture, 5.0f, LineType.Continuous, Joins.Weld); // Create a curve in the VectorLine object line.MakeCurve(curvePoints[0], curvePoints[1], curvePoints[2], curvePoints[3], segments); line.Draw(); // Make the GUITexture objects for anchor and control points (two anchor points and two control points) AddControlObjects(); AddControlObjects(); }
void Update() { if (Input.GetMouseButtonDown(0)) { Debug.Log("Down"); pos1 = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane + 0.5f); pos1 = Camera.main.ScreenToWorldPoint(pos1); pos2 = pos1; } if (Input.GetMouseButton(0)) { pos2 = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane + 0.5f); pos2 = Camera.main.ScreenToWorldPoint(pos2); } // Draw the Vectrosity arrow. arrow.points3.Clear(); arrow.points3.Add(pos2); arrow.points3.Add(pos1); arrow.Draw(); arrow.textureOffset = Time.time * AnimationSpeed % 1; }
// Token: 0x06000B67 RID: 2919 RVA: 0x00034550 File Offset: 0x00032950 private IEnumerator Start() { List <Vector2> splinePoints = new List <Vector2>(); int i = 1; var arg = "Sphere"; int num; i = (num = i) + 1; GameObject obj = GameObject.Find(arg + num); while (obj != null) { splinePoints.Add(Camera.main.WorldToScreenPoint(obj.transform.position)); var arg2 = "Sphere"; i = (num = i) + 1; obj = GameObject.Find(arg2 + num); } VectorLine line = new VectorLine("Spline", new List <Vector2>(this.segments + 1), 2f, LineType.Continuous); line.MakeSpline(splinePoints.ToArray(), this.segments, this.loop); line.Draw(); do { for (float dist = 0f; dist < 1f; dist += Time.deltaTime * this.speed) { Vector2 splinePoint = line.GetPoint01(dist); this.cube.position = Camera.main.ScreenToWorldPoint(new Vector3(splinePoint.x, splinePoint.y, 10f)); yield return(null); } }while (this.loop); yield break; }
void Update() { // Move this transform around in a circle, and the line uses the same movement since it's using this transform with .drawTransform t = Mathf.Repeat(t + Time.deltaTime, 360.0f); transform.position = new Vector2(startPos.x, startPos.y + Mathf.Cos(t) * 4); spikeLine.Draw(); }
public ActiveMissionViewController(ActiveMission actMission, Material material) { _Model = GameModel.Instance; _ActMission = actMission; _TrackPathMaterial = new Material(material); _ColourPathMaterial = new Material(material); _OutlinePathMaterial = new Material(material); _ColourPathPoints = ShanghaiUtils.GetScreenCoordsFromCellKeys(_ActMission.Path, _Model.CellPositions); _ColourPathMaterial.SetColor("_TintColor", ShanghaiUtils.GetColour(_ActMission.Source.PaintColour)); _ColourPath = new VectorLine("Colour Path", _ColourPathPoints.ToArray(), _ColourPathMaterial, 10.0f, LineType.Continuous, Joins.Weld); _ColourPath.Draw(); _OutlinePathMaterial.SetColor("_TintColor", Color.black); _OutlinePath = new VectorLine("Colour Path", _ColourPathPoints.ToArray(), _OutlinePathMaterial, 15.0f, LineType.Continuous, Joins.Weld); _OutlinePath.Draw(); Vector2[] linePoints = new Vector2[2]; linePoints[0] = new Vector2(0, 0); linePoints[1] = new Vector2(Screen.width, Screen.height); _TrackPathMaterial.SetColor("_TintColor", Color.black); _TrackPath = new VectorLine("Active Path", _ColourPathPoints.ToArray(), _TrackPathMaterial, 5.0f, LineType.Continuous, Joins.Weld); _TrackPath.Draw(); }
void Start () { // Make a bunch of points in a spherical distribution var starPoints = new Vector3[numberOfStars]; for (int i = 0; i < numberOfStars; i++) { starPoints[i] = Random.onUnitSphere * 100.0f; } // Make each star have a size ranging from 1.5 to 2.5 var starSizes = new float[numberOfStars]; for (int i = 0; i < numberOfStars; i++) { starSizes[i] = Random.Range (1.5f, 2.5f); } // Make each star have a random shade of grey var starColors = new Color32[numberOfStars]; for (int i = 0; i < numberOfStars; i++) { var greyValue = Random.value * .75f + .25f; starColors[i] = new Color(greyValue, greyValue, greyValue); } stars = new VectorLine("Stars", new List<Vector3>(starPoints), 1.0f, LineType.Points); stars.SetColors (new List<Color32>(starColors)); stars.SetWidths (new List<float>(starSizes)); stars.Draw(); // We want the stars to be drawn behind 3D objects, like a skybox. So we use SetCanvasCamera, // which makes the canvas draw with RenderMode.OverlayCamera using Camera.main. // Note that SetCanvasCamera should be called after the VectorLine is drawn, // or else the VectorLine won't be drawn correctly. VectorLine.SetCanvasCamera (Camera.main); VectorLine.canvas.planeDistance = Camera.main.farClipPlane-1; }
void Update() { // 在一个圆中移动这个变换,并且该行使用相同的移动,因为它使用这个变换。 t = Mathf.Repeat(t + Time.deltaTime, 360.0f); transform.position = new Vector2(startPos.x, startPos.y + Mathf.Cos(t) * 4); spikeLine.Draw(); }
/*! * \brief Redraws the line */ public override void redraw() { if (null != _vectorline) { _vectorline.Draw(); } }
public IEnumerator TreeGrowing() { //odd가 freeVertex가 아니였던거시다! //그러면 even이랑 odd가 tight가 됬으니 두 트리를 합치자! //이 경우 even이랑 odd는 사실 이미 tight인 상태! edge_info tt = new edge_info(select_even, select_odd, vert[select_even].position, vert[select_odd].position); //merge(select_even, select_odd); //odd가 freeVertex가 아니였다. //x는 이미 T에 속하니까 y랑 x`을 T에 추가하자. for (int i = 0; i < Match_edges.Count; ++i) { if (Match_edges[i].v2 == select_odd) { tree_vert[select_odd] = true; tree_vert[Match_edges[i].v1] = true; break; } } //선긋는 애니메이션 추가 Vector3[] t_V = { vert[select_even].position, vert[select_odd].position }; VectorLine VL = new VectorLine("tight_edges_" + (Tight_edges.Count + 1), t_V, linematerial, width, LineType.Continuous); VL.textureScale = 2f; VL.SetColor(t_color); VL.Draw(); tight_path.Add(VL); yield return(null); }
private void Start() { List <Vector3> vector3List = new List <Vector3>(); int num1 = 1; int num2 = num1 + 1; // ISSUE: variable of a boxed type __Boxed <int> local = (ValueType)num1; for (GameObject gameObject = GameObject.Find("Sphere" + (object)local); Object.op_Inequality((Object)gameObject, (Object)null); gameObject = GameObject.Find("Sphere" + (object)num2++)) { vector3List.Add(gameObject.get_transform().get_position()); } if (this.usePoints) { VectorLine vectorLine = new VectorLine("Spline", new List <Vector3>(this.segments + 1), 2f, (LineType)2); vectorLine.MakeSpline(vector3List.ToArray(), this.segments, this.loop); vectorLine.Draw(); } else { VectorLine vectorLine = new VectorLine("Spline", new List <Vector3>(this.segments + 1), 2f, (LineType)0); vectorLine.MakeSpline(vector3List.ToArray(), this.segments, this.loop); vectorLine.Draw3D(); } }
void DrawFace() { Vector3 pos = faceCursor.transform.position; bar.MakeArc(pos, radius, radius, -90.0f, 90.0f); bar.Draw(); }
void Update() { // Since we can rotate the transform, get the local space for the current point, so the mouse position won't be rotated with the line var mousePos = transform.InverseTransformPoint(Input.mousePosition); // Add a line point when the mouse is clicked if (Input.GetMouseButtonDown(0) && canClick && !endReached) { line.points2.Add(mousePos); // Start off with 2 points if (line.points2.Count == 1) { line.points2.Add(Vector2.zero); } if (line.points2.Count == maxPoints) { endReached = true; } } // The last line point should always be where the mouse is; only draw when there are enough points if (line.points2.Count >= 2) { line.points2[line.points2.Count - 1] = mousePos; line.Draw(); } // Rotate around midpoint of screen transform.RotateAround(new Vector2(Screen.width / 2, Screen.height / 2), Vector3.forward, Time.deltaTime * rotateSpeed * Input.GetAxis("Horizontal")); }
public void drawGrid() { gridLines.points3.Clear(); float xLength = gridProperties[(int)GridProperty.X_LENGTH]; float yLength = gridProperties[(int)GridProperty.Y_LENGTH]; Vector3 point1; Vector3 point2; for (int i = 0; i < numGridLines * 2; i++) { int lineIndex = gridLineOrder[i]; int jIndex; if (lineIndex < numGridLines) { jIndex = originLineIndex - lineIndex; point1 = origin.position + new Vector3(jIndex * xLength, originLineIndex * yLength); point2 = origin.position + new Vector3(jIndex * xLength, -originLineIndex * yLength); } else { jIndex = originLineIndex - (lineIndex - numGridLines); point1 = origin.position + new Vector3(originLineIndex * xLength, jIndex * yLength); point2 = origin.position + new Vector3(-originLineIndex * xLength, jIndex * yLength); } gridLines.points3.Add(point1); gridLines.points3.Add(point2); } colorGridLines(); gridLines.Draw(); drawGridNums(); }
private void Start() { VectorLine vectorLine = new VectorLine("Line", new List <Vector2>(this.segments + 1), this.lineTexture, 3f, (LineType)0); vectorLine.MakeEllipse(Vector2.op_Implicit(new Vector2((float)(Screen.get_width() / 2), (float)(Screen.get_height() / 2))), this.xRadius, this.yRadius, this.segments, this.pointRotation); vectorLine.Draw(); }
void Start() { var splinePoints = new List <Vector3>(); var i = 1; var obj = GameObject.Find("Sphere" + (i++)); while (obj != null) { splinePoints.Add(obj.transform.position); obj = GameObject.Find("Sphere" + (i++)); } if (usePoints) { var dotLine = new VectorLine("Spline", new List <Vector3>(segments + 1), 2.0f, LineType.Points); dotLine.MakeSpline(splinePoints.ToArray(), segments, loop); dotLine.Draw(); } else { var spline = new VectorLine("Spline", new List <Vector3>(segments + 1), 2.0f, LineType.Continuous); spline.MakeSpline(splinePoints.ToArray(), segments, loop); spline.Draw3D(); } }
static void CreateLine() { var points2 = new List <Vector2>() { new Vector2(Screen.width / 2 - 100, Screen.height / 2), new Vector2(Screen.width / 2 + 100, Screen.height / 2) }; var line = new VectorLine("Line", points2, 2.0f, LineType.Continuous); Undo.RegisterCreatedObjectUndo(line.rectTransform.gameObject, "Create VectorLine"); var useVectorCanvas = true; var selectedObj = Selection.activeObject as GameObject; if (selectedObj != null) { var canvas = selectedObj.GetComponent <Canvas>(); if (canvas != null && canvas.renderMode != RenderMode.WorldSpace) { line.SetCanvas(canvas); useVectorCanvas = false; } } line.Draw(); if (useVectorCanvas) { if (VectorLine.canvas.gameObject.GetComponent <CanvasScaler>() == null) { VectorLine.canvas.gameObject.AddComponent <CanvasScaler>(); } } Selection.activeGameObject = line.rectTransform.gameObject; }
void UpdateSecond() { if (activeEntry > -1) { FundamentalDiagram fd = GameObject.Find("FundamentalDiagram").GetComponent <FundamentalDiagram> (); fd.removeFundamentalDiagram(); PlaybackControl pc = GameObject.Find("PlaybackControl").GetComponent <PlaybackControl> (); float tx = ((float)(pc.current_time / pc.total_time)) * diagramPosition.width + diagramPosition.x; timeIndicator.points2 = new Vector2[] { new Vector2(tx, diagramPosition.y - 2), new Vector2(tx, diagramPosition.y + 8 + diagramPosition.height) }; timeIndicator.depth = 100; timeIndicator.Draw(); Vector2[] dp = dataPoints.points2; try { dp[((int)pc.current_time) - 1] = new Vector2(diagramPosition.x + diagramPosition.width * ((float)(pc.current_time / pc.total_time)), diagramPosition.y + Mathf.Min(1.0f, (infos[activeEntry].value / infos[activeEntry].maxValue)) * diagramPosition.height); dataPoints.points2 = dp; dataPoints.Draw(); } catch (System.IndexOutOfRangeException) { } } }
IEnumerator Start() { var splinePoints = new List <Vector2>(); var i = 1; var obj = GameObject.Find("Sphere" + (i++)); while (obj != null) { splinePoints.Add(Camera.main.WorldToScreenPoint(obj.transform.position)); obj = GameObject.Find("Sphere" + (i++)); } var line = new VectorLine("Spline", new List <Vector2>(segments + 1), 2.0f, LineType.Continuous); line.MakeSpline(splinePoints.ToArray(), segments, loop); line.Draw(); // Make the cube "ride" the spline at a constant speed do { for (var dist = 0.0f; dist < 1.0f; dist += Time.deltaTime * speed) { var splinePoint = line.GetPoint01(dist); cube.position = Camera.main.ScreenToWorldPoint(new Vector3(splinePoint.x, splinePoint.y, 10.0f)); yield return(null); } } while (loop); }
void tutorialLine (){ helperLine = new VectorLine("tutorial_line", new List<Vector3>(), lineMaterial, 12.0f,LineType.Continuous); helperLine.points3.Add(Camera.main.ScreenToWorldPoint(rightHelper.transform.position)); helperLine.points3.Add(Camera.main.ScreenToWorldPoint(rightMenu.transform.position)); helperLine.textureScale = 1.0f; helperLine.Draw(); }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); //rope_renderer = GetComponent<LineRenderer>(); rope_renderer = new VectorLine("Rope", new List <Vector3> { new Vector3(), new Vector3(), new Vector3() }, RopeWidth, LineType.Continuous); rope_renderer.Draw(); VectorLine.canvas.renderMode = RenderMode.ScreenSpaceCamera; VectorLine.SetCanvasCamera(Camera.main); VectorLine.canvas.sortingLayerName = "Projectile"; //Debug.Log(string.Format("{0}", VectorLine.canvas.sortingLayerName)); // initiate two anchors for (int i = 0; i < NUM_ANCHORS; i++) { GameObject anchor = Instantiate <GameObject>(ProjectilePrefab); anchor.GetComponent <SpriteRenderer>().enabled = false; anchor.GetComponent <Rigidbody2D>().simulated = false; anchor.GetComponent <projectile_flying>().Shooter = gameObject; Anchors.Add(anchor); sqL0.Add(SquareMaxRopeLength); } }
void drawOrange(){ uiPath_1 = new VectorLine("dragLine_0", new List<Vector3>(), lineMaterial, 22.0f,LineType.Continuous); uiPath_1.textureScale = 1.0f; uiPath_1.points3.Add(Camera.main.ScreenToWorldPoint(orangeBox.transform.position)); uiPath_1.points3.Add(Camera.main.ScreenToWorldPoint(edge_1.transform.position)); uiPath_1.color = Color.black; uiPath_1.Draw(); }
void AddGrid() { float rowCount = 12.0f; float colCount = 16.0f; float colStep = Screen.width / colCount; float rowStep = Screen.height / rowCount; // Debug.Log (colStep + " " + rowStep); // Debug.Log (Screen.width + " " + Screen.height); // // for (int i = 0; i < rowCount; i++) { // // // Vector2 a = new Vector2 (0, i * rowStep); // // Vector2 b = new Vector2 (Screen.width, i * rowStep); // // // Debug.DrawLine (a, b, Color.red); // // } // // // for (int j = 0; j < 16; j++) { // // Vector2 a = new Vector2 (j * colStep, 0); // Vector2 b = new Vector2 (j * colStep, Screen.height); // // Debug.DrawLine (a, b, Color.red); // } for (int i = 0; i < rowCount; i++) { Vector2 a = new Vector2 (0, i * rowStep); Vector2 b = new Vector2 (Screen.width, i * rowStep); VectorLine line = new VectorLine ("row" + i, new Vector2[]{a,b}, null, 1.0f); line.SetColor (Color.green); line.Draw (); } for (int j = 0; j < 16; j++) { Vector2 a = new Vector2 (j * colStep, 0); Vector2 b = new Vector2 (j * colStep, Screen.height); VectorLine line = new VectorLine ("col" + j, new Vector2[]{a,b}, null, 1.0f); line.SetColor (Color.green); line.Draw (); } }
void InitializeHPBar () { float y = Screen.height - yOffset; Vector2 start = new Vector2(xOffset + margin, y); float x = (xOffset + Value)*multiplier + margin; Vector2 end = new Vector2(x, y); hpLine = VectorLine.SetLine(hpColor, new Vector2[] { start, end }); hpLine.lineWidth = bgThickness - (2 * margin); hpLine.sortingOrder = 2; hpLine.Draw(); }
/// <summary> /// 绘制矩形 /// </summary> private void CreateRect(float posX, float posY, float width, float height, Color color) { VectorLine squareLine = new VectorLine ("Square", new Vector2[8], null, 1.0f, LineType.Discrete, Joins.Weld); squareLine.MakeRect (new Rect (posX, posY, width, height)); squareLine.SetColor (color); squareLine.Draw (); }
void DrawBackground () { float y = Screen.height - yOffset; Vector2 start = new Vector2(xOffset, y); float x = (xOffset + BackgroundValue)*multiplier + 2 * margin; Vector2 end = new Vector2(x, y); bgLine = VectorLine.SetLine(bgColor, new Vector2[] { start, end }); bgLine.lineWidth = bgThickness; bgLine.sortingOrder = 1; bgLine.Draw(); }
void drawOrangePath(){ if(dragThrow.canRight){ answerPath_orange = new VectorLine("dragLine_orange", new List<Vector3>(), lineMaterial, lineWidth,LineType.Continuous); answerPath_orange.textureScale = 1.0f; answerPath_orange.color = dragThrow.orangeBox.GetComponent<SpriteRenderer>().color; for (int i = 0; i < dragThrow.orange_ans.Length; i++) { answerPath_orange.points3.Add(dragThrow.orange_ans[i]); } answerPath_orange.Draw(); } }
void drawRedPath(){ if(dragThrow.canLeft){ answerPath_red = new VectorLine("dragLine_red", new List<Vector3>(), lineMaterial, lineWidth,LineType.Continuous); answerPath_red.textureScale = 1.0f; answerPath_red.color = dragThrow.redBox.GetComponent<SpriteRenderer>().color; for (int i = 0; i < dragThrow.red_ans.Length; i++) { answerPath_red.points3.Add(dragThrow.red_ans[i]); } answerPath_red.Draw(); } }
// Update is called once per frame void Update() { if( ctrl==true && mkLine.finish==true){ Camera cam = VectorLine.SetCameraRenderTexture (renderTexture, Color.white, true); line = new VectorLine("Line",mkLine.linePoints,Color.black, null, 10.0f,LineType.Continuous); line.maxDrawIndex=2*mkLine.canerinIndex+1; line.Draw(); cam.Render(); VectorLine.SetCameraRenderTexture (null); //line.Draw(); ctrl=false; } }
public void drawLines() { VectorLine myLine; List<Vector3> linePoints = new List<Vector3>(); // C# Vector3 tmp = new Vector3(0f,0f,0f); Vector3 last = new Vector3(0f,0f,0f); myLine = new VectorLine("MyLine", linePoints, null, 2.0f, LineType.Continuous); for (int i=0; i< gcodes.Count; i++) { GCode g = gcodes[i]; float _pos; if (g.containsKey("X") && g.getf ("X", out _pos)){ tmp.x = _pos; } else { tmp.x = last.x; } if (g.containsKey("Y") && g.getf ("Y", out _pos)){ tmp.z = _pos; } else { tmp.z = last.z; } if (g.containsKey("Z") && g.getf ("Z", out _pos)){ tmp.y = _pos; } else { tmp.y = last.y; } if (g.isMove ()){ if (g.extrudes()){ // draw line from last to tmp print ("LINE "+last +" - " + tmp +" : "+g); } else { print ("move "+last +" - " + tmp+" : "+g); } last = tmp; linePoints.Add (tmp); } } myLine.Draw(); }
void Start () { //VectorLine.SetCamera3D(); //Vector2[] linePoints = {new Vector2(0,0),new Vector2(1,1)}; //VectorLine myline = new VectorLine.SetLine(Color.green, new Vector2(0, 0), new Vector2(1, 1)); Vector2[] linePoints = { new Vector2(0, 0),new Vector2(1, 1)}; Material line = (Material)Resources.Load("Line"); VectorLine myline = new VectorLine("MyLine",linePoints,null,0.05f,LineType.Continuous); //VectorLine.SetCanvasCamera (Camera.main); //c.re Rect r = new Rect(0,0,2,1); //myline.make myline.MakeRoundedRect(r, 0.2f,10); myline.SetColor(Color.black); myline.Draw(); }
List<GameObject> planets; //destination objects, the earth and moon #endregion Fields #region Methods public void PlotTrajectory(Vector3 start, Vector3 startVelocity, float timestep, float maxTime) { //Vector2[] curvePoints = new Vector2[(int)Mathf.Ceil(maxTime/timestep+1)]; List<Vector2> curvePoints = new List<Vector2> (); Vector3 prev = start; for (int i = 1; ; i++) { float t = timestep * i; if (t > maxTime) break; Vector2 pos = PlotTrajectoryAtTime(start, startVelocity, t); if (Physics.Linecast(prev, pos)) break; Debug.DrawLine(prev, pos, Color.red); Debug.Log(pos); curvePoints.Add(Camera.main.WorldToViewportPoint(pos)); //curvePoints.Add(pos); prev = pos; } line = new VectorLine("Spline", new List<Vector2>(curvePoints.Count+1), 2.0f, LineType.Continuous, Joins.Weld); //line.useViewportCoords = true; //Vector2[] curvePoints = new Vector2[(int)Mathf.Ceil(maxTime / timestep + 1)] if (curvePoints.Count > 0) { Debug.Log(curvePoints.Count); line.MakeSpline(curvePoints.ToArray()); line.continuousTexture = true; line.Draw(); } /* VectorLine line2 = new VectorLine("Arrow2", new List<Vector2>(50), 40.0f, LineType.Continuous, Joins.Weld); line2.useViewportCoords = true; Vector2[] splinePoints = new Vector2[] { new Vector2(0.1f, 0.85f), new Vector2(0.3f, 0.5f), new Vector2(0.5f, 0.4f), new Vector2(0.7f, 0.5f), new Vector2(0.9f, 0.85f) }; line2.MakeSpline(curvePoints.ToArray()); //line2.endCap = "arrow2"; line2.continuousTexture = true; line2.Draw(); */ }
// Use this for initialization void Start() { refY = minH; refX = minW; time = minW; index = 0; oldWidth = Screen.width; finish = false; CizimBasladi = false; CizimBitti = false; instantiated = false; inside = false; textVectors=new VectorLine[50]; for (int i=0; i<50; i++) { textVectors[i]=new VectorLine("Text"+i,new Vector2[2]{new Vector2(0,0),new Vector2(0,0)},null,2f,LineType.Discrete,Joins.Weld); } textVec=new VectorLine("GuideText",new Vector2[2]{new Vector2(0,0),new Vector2(0,0)},null,2f,LineType.Discrete,Joins.Weld); maxH = Screen.height - 2 * minH; maxW = Screen.width - 2 * minW; linePoints= new Vector2[100]; for (int i=0; i<100; i++) { linePoints[i]=Vector2.zero; } atGraphAfterVtPoints = new Vector2[100]; for(int i=0;i<100;i++){ atGraphAfterVtPoints[i]=Vector2.zero; } canerinArray = new Vector2[49]; for (int i=0; i<49; i++) { canerinArray[i]=Vector2.zero; } VelocityArray=new Vector2[50]; for (int i=0; i<49; i++) { VelocityArray[i]=Vector2.zero; } dotPoints = new Vector2[50]; for(int i=0;i<50;i++){ dotPoints[i]=Vector2.zero; } numberOfDots = 0; dots = new VectorPoints ("Dots", dotPoints, Color.red, null, 10f); dots.maxDrawIndex = numberOfDots; linePointsX=new Vector2[(maxW/snToPixel)*4]; for (int i =0; i<=maxW/snToPixel*2; i+=2) { linePointsX[i].x=minW+i*snToPixel/2; linePointsX[i].y=(Screen.height/2)-5; linePointsX[i+1].x=minW+i*snToPixel/2; linePointsX[i+1].y=(Screen.height/2)+5; } //snToPixel en az 5 olabilir ise. linePointsY=new Vector2[(maxH/5)*4]; for (int i =0; i<=maxH / snToPixel * 2+2; i+=2) { linePointsY[i].x=minW-5; linePointsY[i].y=minH+i*snToPixel/2; linePointsY[i+1].x=minW+5; linePointsY[i+1].y=minH+i*snToPixel/2; } //Numara yazımı linePointsYNmb=new VectorLine[(maxH/5)*2]; for (int i =0; i<=maxH / snToPixel*2+2; i+=2) { linePointsYNmb[i/2]=new VectorLine("Numb"+i/2,new Vector2[2]{new Vector2(minW-15,minH+i*snToPixel/2),new Vector2(minW,minH+i*snToPixel/2)},null,2f,LineType.Discrete,Joins.Weld); if(i/2*snToPixel>maxH/2) linePointsYNmb[i/2].MakeText(""+(i/2*snToPixel-maxH/2)/snToPixel,new Vector2(minW-15,minH+i*snToPixel/2),10f); else linePointsYNmb[i/2].MakeText(""+(maxH/2-(i/2-1)*snToPixel)/snToPixel*-1 ,new Vector2(minW-25,minH+i*snToPixel/2),10f); linePointsYNmb[i/2].Draw(); } VectorLine.Destroy (ref textVec); textVec=new VectorLine("Text"+(index),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); if(refY>Screen.height/2) textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(mousePos.y-minH-maxH/2)/snToPixel+")",new Vector2(mousePos.x,mousePos.y+25),10f); else textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(maxH/2-(mousePos.y-minH))/snToPixel*-1+")",new Vector2(mousePos.x,mousePos.y+25),10f); textVec.Draw(); gecici = new VectorLine("gecici", new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH)}, Color.white, null, 2f, LineType.Discrete); gecici.Draw(); guideY = new VectorLine ("guideY",new Vector2[2]{new Vector2(time,minH),new Vector2(time,maxH+minH)},Color.red,null,2f,LineType.Discrete); guideY.Draw (); allGuide=new VectorLine("Guide",new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,maxH+minH),new Vector2(minW,Screen.height/2),new Vector2(maxW+minW,Screen.height/2)},null,3f,LineType.Discrete); allGuide.Draw (); /* plane.transform.localScale = new Vector3 ((float)(1.35f*maxW)/(float)(Screen.width),0.1f,(float)(Screen.height-minH*2)/(float)Screen.height); plane.transform.position = new Vector3(plane.transform.position.x,plane.transform.position.y,Camera.main.transform.position.z+1); */ box.x = -Screen.width/2+minW; box.y= -Screen.height/2+minH; box.width = maxW; box.height = maxH; bg.pixelInset = box; rectV = new VectorLine ("Rectangle",new Vector2[8],Color.black,null,4f); rectV.capLength = 2; rectV.MakeRect (new Rect (minW, Screen.height - minH, maxW, maxH)); rectV.Draw(); SetLine(); }
public void DrawLine() { IsEnabled = true; // Cleanup old Line VectorLine.Destroy(ref _line); // Create new Line _line = new VectorLine("Line", new List<Vector2>(), null, LineWidth, LineType.Discrete, Joins.Weld); _line.color = LineColor; _line.drawDepth = LineOrder; Vector2 lastPoint = Vector2.zero; // Draw all segments and connection lines for(var i = 0; i < Cells.Length; i++) { var cell = Cells[i]; // Part 0 // Add Line's Head if (i == 0) { lastPoint = GetLineStart(cell); } // Part 1 _line.points2.Add(lastPoint); MathLine line = new MathLine().CalculateLineByPoints(lastPoint, cell.Center); SideType side = SideType.None; if (cell.Visible) { cell.GetExternalIntersectionPoint(line, cell.Center, lastPoint - cell.Center, 0f, out side, out lastPoint); } else { // Prepare line for Stump cell.GetExternalIntersectionPoint(line, cell.Center, lastPoint - cell.Center, LineWidth / 3f, out side, out lastPoint); } _line.points2.Add(lastPoint); // Part 2 if (cell.Visible) { // Draw line through cell center _line.points2.Add(lastPoint); _line.points2.Add(cell.Center); } else { // Draw Stump to have nice line ending _line.points2.Add(lastPoint); _line.points2.Add(lastPoint + LineWidth / 4f * GetStumpVector(side)); } // Part 3 Vector2 nextPoint; // If current point is the last one, take Right Cell's point if (i == Cells.Length - 1) { nextPoint = GetLineEnding(cell); } // Otherwise take next Cell's center as point else { Cell nextCell = Cells[i + 1]; nextPoint = nextCell.Center; } line = new MathLine().CalculateLineByPoints(cell.Center, nextPoint); if (cell.Visible) { cell.GetInternalIntersectionPoint(line, cell.Center, nextPoint - cell.Center, 0f, out side, out lastPoint); // Start line from Cell's center _line.points2.Add(cell.Center); _line.points2.Add(lastPoint); } else { cell.GetInternalIntersectionPoint(line, cell.Center, nextPoint - cell.Center, LineWidth / 3f, out side, out lastPoint); // Draw Stump _line.points2.Add(lastPoint + LineWidth / 4f * GetStumpVector(side)); _line.points2.Add(lastPoint); } // Part 4 // Add Line tail if (i == Cells.Length - 1) { _line.points2.Add(lastPoint); _line.points2.Add(nextPoint); } } _line.Draw(); }
// Use this for initialization void Start() { //vectorCam = VectorLine.GetCamera(); maxH = Screen.height - 2 * minH; maxW = Screen.width - 2 * minW; linePoints= new Vector2[100]; for (int i=0; i<100; i++) { linePoints[i]=Vector2.zero; } canerinArray = new Vector2[49]; for (int i=0; i<49; i++) { canerinArray[i]=Vector2.zero; } VelocityArray=new Vector2[50]; for (int i=0; i<49; i++) { VelocityArray[i]=Vector2.zero; } linePointsX=new Vector2[(maxW/snToPixel)*4]; for (int i =0; i<=maxW/snToPixel*2; i+=2) { linePointsX[i].x=minW+i*snToPixel/2; linePointsX[i].y=(Screen.height/2)-5; linePointsX[i+1].x=minW+i*snToPixel/2; linePointsX[i+1].y=(Screen.height/2)+5; } linePointsY=new Vector2[(maxH/snToPixel)*4]; for (int i =0; i<=maxH / snToPixel * 2+2; i+=2) { linePointsY[i].x=minW-5; linePointsY[i].y=minH+i*snToPixel/2; linePointsY[i+1].x=minW+5; linePointsY[i+1].y=minH+i*snToPixel/2; } refY = minH; refX = minW; time = minW; index = 0; oldWidth = Screen.width; SetLine(); finish = false; CizimBasladi = false; CizimBitti = false; instantiated = false; inside = false; gecici = new VectorLine("gecici", new Vector2[2]{new Vector2(minW,minH),new Vector2(minW,minH)}, Color.white, lineMaterial, 2f, LineType.Discrete); gecici.Draw(); guideY = new VectorLine ("guideY",new Vector2[2]{new Vector2(time,minH),new Vector2(time,maxH+minH)},Color.red,null,2f,LineType.Discrete); guideY.Draw (); allGuide=new VectorLine("Guide",new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,maxH+minH),new Vector2(minW,Screen.height/2),new Vector2(maxW+minW,Screen.height/2)},null,3f,LineType.Discrete); allGuide.Draw (); /* plane.transform.localScale = new Vector3 ((float)(1.35f*maxW)/(float)(Screen.width),0.1f,(float)(Screen.height-minH*2)/(float)Screen.height); plane.transform.position = new Vector3(plane.transform.position.x,plane.transform.position.y,Camera.main.transform.position.z+1); */ box.x = -Screen.width/2+minW; box.y= -Screen.height/2+minH; box.width = maxW; box.height = maxH; BG.guiTexture.pixelInset = box; rectV = new VectorLine ("Rectangle",new Vector2[8],Color.black,null,4f); rectV.capLength = 2; rectV.MakeRect (new Rect (minW, Screen.height - minH, maxW, maxH)); rectV.Draw(); }
// Update is called once per frame void Update() { timer += Time.deltaTime; minutes = Mathf.Floor(timer / 59); seconds =timer%59; if(seconds>2){ mousePos = transform.InverseTransformPoint(Input.mousePosition); if (mousePos.y < Screen.height - minH && mousePos.y > minH && mousePos.x>minW &&mousePos.x<Screen.width-minW) inside = true; else inside = false; if (finish==false&&inside==true) refPointSche.transform.position = camera.ScreenToWorldPoint (new Vector3 (refX, mousePos.y, 1)); if (CizimBasladi == true && refX<mousePos.x&&inside==true) { guideY.points2 = new Vector2[2]{new Vector2 (mousePos.x, minH),new Vector2 (mousePos.x, maxH+minH)}; guideY.Draw(); gecici.points2 = new Vector2[2]{new Vector2 (refX,refY),new Vector2 (mousePos.x,refY)}; gecici.Draw(); if (finish==false) refPointSche.transform.position = camera.ScreenToWorldPoint (new Vector3 (mousePos.x, refY, 1)); if(instantiated){ Instantiate (startPointPref,camera.ScreenToWorldPoint(new Vector3(refX,refY,1)),Quaternion.identity);//ilk nokta. instantiated=false;} CizimBitti=true; } if (Input.GetMouseButtonDown (0) && finish==false &&inside==true) { instantiated=true; CizimBasladi=true; refY=mousePos.y; } if (Input.GetMouseButtonUp(0) && finish==false &&inside==true) { gecici.points2 = new Vector2[2]{new Vector2 (minW,minH),new Vector2 (minW,minH)}; gecici.Draw(); linePoints[2*index] = new Vector2(refX,refY); if(refX<mousePos.x){ refX=mousePos.x; } else{ Instantiate (startPointPref,camera.ScreenToWorldPoint(new Vector3(refX,refY,1)),Quaternion.identity);//ilk nokta. refX+=snToPixel; } linePoints[2*index+1] =new Vector2(refX,refY); Instantiate (startPointPref,camera.ScreenToWorldPoint(new Vector3(refX,refY,1)),Quaternion.identity);//2. nokta. line.maxDrawIndex = 2*index+1; index++; guideY.points2 = new Vector2[2]{new Vector2 (refX, minH),new Vector2 (refX, maxH+minH)}; guideY.Draw(); CizimBitti=true; CizimBasladi=false; } if (finish==false && CizimBitti == true &&inside==true) { line.Draw (); CizimBitti = false; } if (oldWidth != Screen.width) { oldWidth = Screen.width; VectorLine.SetCamera(); } /*if (Input.GetKeyDown (KeyCode.Escape)) { finish=true; VectorLine.Destroy (ref guideY); StartCoroutine ("SetArray"); refPointSche.transform.renderer.enabled=false; }*/ if (finish == true && Input.GetKeyDown (KeyCode.A)) { VelocityArray[0]=Vector2.zero;//initial velocity given int maxheight=0; float snToPixelH=snToPixel; for(int i=0;i<=canerinIndex+1;i++) {VelocityArray[i+1]= new Vector2(canerinArray[i].x*snToPixel,VelocityArray[i].y+canerinArray[i].x*canerinArray[i].y*snToPixelH); if(Mathf.Abs(VelocityArray[maxheight].y)<Mathf.Abs(VelocityArray[i+1].y)) maxheight=i+1; } if(Mathf.Abs(VelocityArray[maxheight].y)>maxH/2 ) { snToPixelH=(maxH/2)/Mathf.Abs(VelocityArray[maxheight].y/snToPixelH); } for(int i=0;i<=canerinIndex+1;i++) { VelocityArray[i+1]= new Vector2(canerinArray[i].x*snToPixel,(VelocityArray[i].y+canerinArray[i].x*canerinArray[i].y*snToPixelH)); } for(int i=0;i<=canerinIndex+1;i++) { VelocityArray[i]= new Vector2(VelocityArray[i].x+minW,VelocityArray[i].y+maxH/2+minH); } vtGraph= new VectorLine("V-t Graph",VelocityArray,Color.yellow,null,5f,LineType.Continuous); vtGraph.maxDrawIndex=canerinIndex+1; vtGraph.Draw(); linePointsY=new Vector2[(maxH/(int)snToPixelH)*10]; for (int i =0; i<=(maxH/snToPixelH)*2+2; i+=2) { linePointsY[i].x=minW-5; linePointsY[i].y=minH+i*snToPixelH/2; linePointsY[i+1].x=minW+5; linePointsY[i+1].y=minH+i*snToPixelH/2; } refPointsOnY.points2=linePointsY; refPointsOnY.Draw(); } } }
void OnGUI() { // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed if (!showDrawingTools) { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Start Drawing")) { showDrawingTools = true; } } else if (!drawingDone) { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Done")) { drawingDone = true; } } else if (!showVectorDrawing) { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 100, 150, 50), "Draw V-T Graph")) { showVectorDrawing = true; } if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Back To The Schene")) { //Buraya Kamera değiştirme scripti gelcek. VectorLine.Destroy (ref allGuide); VectorLine.Destroy (ref atGraphAfterVt); VectorLine.Destroy (ref gecici); VectorLine.Destroy (ref guideY); VectorLine.Destroy (ref line); VectorLine.Destroy (ref rectV); VectorLine.Destroy (ref refPointsOnX); VectorLine.Destroy (ref refPointsOnY); VectorLine.Destroy (ref textVec); VectorLine.Destroy (ref vtGraph); VectorPoints.Destroy (ref dots); for (int i =0; i<linePointsYNmb.Length;i++) { VectorLine.Destroy (ref linePointsYNmb[i]); } for (int i =0; i<textVectors.Length;i++){ VectorLine.Destroy (ref textVectors[i]); } finish = true; walkOrDraw.btnClicked=false; } } else { if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 100, 150, 50), "Reset")) { showDrawingTools=false; showVectorDrawing=false; drawingDone=false; VectorLine.Destroy(ref dots); VectorLine.Destroy(ref line); VectorLine.Destroy(ref vtGraph); VectorLine.Destroy(ref atGraphAfterVt); VectorLine.Destroy(ref refPointsOnX); VectorLine.Destroy(ref refPointsOnY); for (int i=0; i<50; i++) { VectorLine.Destroy(ref textVectors[i]); textVectors[i]=new VectorLine("Text"+i,new Vector2[2]{new Vector2(0,0),new Vector2(0,0)},null,2f,LineType.Discrete,Joins.Weld); } for (int i=0; i<100; i++) { linePoints[i]=Vector2.zero; } for(int i=0;i<100;i++){ atGraphAfterVtPoints[i]=Vector2.zero; } for (int i=0; i<49; i++) { canerinArray[i]=Vector2.zero; } for (int i=0; i<49; i++) { VelocityArray[i]=Vector2.zero; } for(int i=0;i<50;i++){ dotPoints[i]=Vector2.zero; } numberOfDots = 0; dots = new VectorPoints ("Dots", dotPoints, Color.red, null, 10f); dots.maxDrawIndex = numberOfDots; linePointsX=new Vector2[(maxW/snToPixel)*4]; for (int i =0; i<=maxW/snToPixel*2; i+=2) { linePointsX[i].x=minW+i*snToPixel/2; linePointsX[i].y=(Screen.height/2)-5; linePointsX[i+1].x=minW+i*snToPixel/2; linePointsX[i+1].y=(Screen.height/2)+5; } //snToPixel en az 5 olabilir ise. linePointsY=new Vector2[(maxH/5)*4]; for (int i =0; i<=maxH / snToPixel * 2+2; i+=2) { linePointsY[i].x=minW-5; linePointsY[i].y=minH+i*snToPixel/2; linePointsY[i+1].x=minW+5; linePointsY[i+1].y=minH+i*snToPixel/2; } //Numara yazımı for (int i =0; i<(maxH/5)*2; i+=2) { VectorLine.Destroy(ref linePointsYNmb[i/2]); } for (int i =0; i<=maxH / snToPixel*2+2; i+=2) { linePointsYNmb[i/2]=new VectorLine("Numb"+i/2,new Vector2[2]{new Vector2(minW-15,minH+i*snToPixel/2),new Vector2(minW,minH+i*snToPixel/2)},null,2f,LineType.Discrete,Joins.Weld); if(i/2*snToPixel>maxH/2) linePointsYNmb[i/2].MakeText(""+(i/2*snToPixel-maxH/2)/snToPixel,new Vector2(minW-15,minH+i*snToPixel/2),10f); else linePointsYNmb[i/2].MakeText(""+(maxH/2-(i/2-1)*snToPixel)/snToPixel*-1 ,new Vector2(minW-25,minH+i*snToPixel/2),10f); linePointsYNmb[i/2].Draw(); } VectorLine.Destroy (ref textVec); textVec=new VectorLine("Text"+(index),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); if(refY>Screen.height/2) textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(mousePos.y-minH-maxH/2)/snToPixel+")",new Vector2(mousePos.x,mousePos.y+25),10f); else textVec.MakeText("(t="+(mousePos.x-minW)/snToPixel+",a="+(maxH/2-(mousePos.y-minH))/snToPixel*-1+")",new Vector2(mousePos.x,mousePos.y+25),10f); refY = minH; refX = minW; time = minW; index = 0; oldWidth = Screen.width; SetLine(); finish = false; CizimBasladi = false; CizimBitti = false; instantiated = false; inside = false; gecici = new VectorLine("gecici", new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH),new Vector2(minW,minH)}, Color.white, null, 2f, LineType.Discrete); gecici.Draw(); guideY = new VectorLine ("guideY",new Vector2[2]{new Vector2(time,minH),new Vector2(time,maxH+minH)},Color.red,null,2f,LineType.Discrete); guideY.Draw (); allGuide=new VectorLine("Guide",new Vector2[4]{new Vector2(minW,minH),new Vector2(minW,maxH+minH),new Vector2(minW,Screen.height/2),new Vector2(maxW+minW,Screen.height/2)},null,3f,LineType.Discrete); allGuide.Draw (); /* plane.transform.localScale = new Vector3 ((float)(1.35f*maxW)/(float)(Screen.width),0.1f,(float)(Screen.height-minH*2)/(float)Screen.height); plane.transform.position = new Vector3(plane.transform.position.x,plane.transform.position.y,Camera.main.transform.position.z+1); */ box.x = -Screen.width/2+minW; box.y= -Screen.height/2+minH; box.width = maxW; box.height = maxH; bg.pixelInset = box; rectV = new VectorLine ("Rectangle",new Vector2[8],Color.black,null,4f); rectV.capLength = 2; rectV.MakeRect (new Rect (minW, Screen.height - minH, maxW, maxH)); rectV.Draw(); } if (GUI.Button (new Rect (Screen.width - 150, Screen.height - 50, 150, 50), "Back To The Schene")) { //Buraya Kamera değiştirme scripti gelcek. VectorLine.Destroy (ref allGuide); VectorLine.Destroy (ref atGraphAfterVt); VectorLine.Destroy (ref gecici); VectorLine.Destroy (ref guideY); VectorLine.Destroy (ref line); VectorLine.Destroy (ref rectV); VectorLine.Destroy (ref refPointsOnX); VectorLine.Destroy (ref refPointsOnY); VectorLine.Destroy (ref textVec); VectorLine.Destroy (ref vtGraph); VectorPoints.Destroy (ref dots); for (int i =0; i<linePointsYNmb.Length;i++) { VectorLine.Destroy (ref linePointsYNmb[i]); } for (int i =0; i<textVectors.Length;i++){ VectorLine.Destroy (ref textVectors[i]); } finish = true; walkOrDraw.btnClicked=false; } } }
private void DrawPanel() { int pointCount = 8; // Build debug panel line with proper parameters debugPanelLine = new VectorLine("DebugPanelLine", new Vector2[pointCount], null, 2, LineType.Discrete, Joins.Weld); debugPanelLine.color = gridviewParameters.panelColor; //Get panel size Vector2 size = new Vector2(panel.finalClipRegion.z, panel.finalClipRegion.w); //Get panel position Vector2 position = new Vector2(panel.finalClipRegion.x + panel.transform.localPosition.x + Screen.width / 2f - size.x / 2f, panel.finalClipRegion.y + panel.transform.localPosition.y + Screen.height / 2f - size.y / 2f); //Draw panel rect Rect rect = new Rect(position, size); debugPanelLine.MakeRect(rect); debugPanelLine.Draw(); }
void SetLine() { VectorLine.Destroy (ref line); line = new VectorLine("Line", linePoints, Color.white, lineMaterial, 2f, LineType.Continuous, Joins.Weld); line.drawTransform = transform; endReached = false; print (linePointsX[1]); refPointsOnX = new VectorLine ("refPointsOnX",linePointsX,Color.white,lineMaterial,2f,LineType.Discrete); refPointsOnX.Draw (); refPointsOnY = new VectorLine ("refPointsOnY",linePointsY,Color.white,lineMaterial,2f,LineType.Discrete); refPointsOnY.Draw (); }
// Update is called once per frame void Update() { if (showDrawingTools) { mousePos = transform.InverseTransformPoint (Input.mousePosition); if (mousePos.y < Screen.height - minH && mousePos.y > minH && mousePos.x > minW && mousePos.x < Screen.width - minW) inside = true; else inside = false; if (CizimBasladi == true && refX < mousePos.x && inside == true) { if (!(Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift)))//false ise refY = mousePos.y;//sonrada ivmeyi değiştirebilmek için if ((Input.GetKey (KeyCode.LeftShift) || Input.GetKey (KeyCode.RightShift))) { gecici.points2 = new Vector2[4] { new Vector2 (refX, refYx), new Vector2 (refX, refY), new Vector2 (refX, refY), new Vector2 (mousePos.x, refY) }; } else if (index > 0)//ilk line çizildimi? ilk line da y'de çizgi yok. gecici.points2 = new Vector2[4] { new Vector2 (refX, refYx), new Vector2 (refX, mousePos.y), new Vector2 (refX, refY), new Vector2 (mousePos.x, refY) }; else gecici.points2 = new Vector2[4] { new Vector2 (mousePos.x, mousePos.y), new Vector2 (mousePos.x, mousePos.y), new Vector2 (refX, refY), new Vector2 (mousePos.x, refY) }; gecici.Draw (); VectorLine.Destroy (ref textVec); textVec = new VectorLine ("Text" + (index), new Vector2[2]{new Vector2 (refX, refY - 5),new Vector2 (refX + 15, refY + 15)}, Color.black, null, 2f, LineType.Discrete, Joins.Weld); if (refY > Screen.height / 2) textVec.MakeText ("(t=" + (mousePos.x - minW) / snToPixel + ",a=" + (refY - minH - maxH / 2) / snToPixel + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); else textVec.MakeText ("(t=" + (mousePos.x - minW) / snToPixel + ",a=" + (maxH / 2 - (refY - minH)) / snToPixel * -1 + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); textVec.Draw (); guideY.points2 = new Vector2[2]{new Vector2 (mousePos.x, minH),new Vector2 (mousePos.x, maxH + minH)}; guideY.Draw (); CizimBitti = true; } if (Input.GetMouseButtonDown (0) && finish == false && inside == true) { instantiated = true; CizimBasladi = true; refY = mousePos.y; } if (Input.GetMouseButtonUp (0) && finish == false && inside == true) { dotPoints [numberOfDots] = new Vector2 (refX, refY);//önce ilk değeri index olarak kullanıp sonra arttırır (ex ++i) dots.maxDrawIndex = numberOfDots; numberOfDots++; dots.drawTransform = transform; dots.Draw (); /* textVectors[numberOfDots-1]= new VectorLine("Text"+(numberOfDots-1),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); textVectors[numberOfDots-1].MakeText("("+refX/snToPixel+","+refY/snToPixel+")",new Vector2(refX,refY+25),10f); textVectors[numberOfDots-1].Draw(); */ /*point yazdırma textVector=new VectorLine("Text",new Vector2(refX,refY),null,5f); textVector.MakeText ("sdfgdfad",new Vector2(refX,refY),30f); */ refYx = mousePos.y; gecici.points2 = new Vector2[4] { new Vector2 (minW, minH), new Vector2 (minW, minH), new Vector2 (minW, minH), new Vector2 (minW, minH) }; gecici.Draw (); linePoints [2 * index] = new Vector2 (refX, refY); if (refX < mousePos.x) { refX = mousePos.x; } else { refX += snToPixel; } linePoints [2 * index + 1] = new Vector2 (refX, refY); line.maxDrawIndex = 2 * index + 1; index++; guideY.points2 = new Vector2[2]{new Vector2 (refX, minH),new Vector2 (refX, maxH + minH)}; guideY.Draw (); dotPoints [numberOfDots] = new Vector2 (refX, refY);//önce ilk değeri index olarak kullanıp sonra arttırır (ex ++i) dots.maxDrawIndex = numberOfDots; numberOfDots++; dots.drawTransform = transform; dots.Draw (); VectorLine.Destroy (ref textVec); textVectors [numberOfDots] = new VectorLine ("Text" + (index), new Vector2[2] { new Vector2 (refX, refY - 5), new Vector2 (refX + 15, refY + 15) }, Color.black, null, 2f, LineType.Discrete, Joins.Weld); if (refY > Screen.height / 2) textVectors [numberOfDots].MakeText ("(t=" + (refX - minW) / snToPixel + ",a=" + (refY - minH - maxH / 2) / snToPixel + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); else textVectors [numberOfDots].MakeText ("(t=" + (refX - minW) / snToPixel + ",a=" + (maxH / 2 - (refY - minH)) / snToPixel * -1 + ")", new Vector2 (mousePos.x, mousePos.y + 25), 10f); textVectors [numberOfDots].Draw (); /* if(linePoints[i*2+1].y>Screen.height/2) canerinArray[i].y=((linePoints[i*2+1].y)-minH-maxH/2)/snToPixel; else canerinArray[i].y=((maxH/2-(linePoints[i*2+1].y-minH))/snToPixel)*-1; canerinArray[i].x=(linePoints[i*2+1].x-minW)/snToPixel; */ /* textVectors[numberOfDots-1]= new VectorLine("Text"+(numberOfDots-1),new Vector2[2]{new Vector2(refX,refY-5),new Vector2(refX+15,refY+15)},Color.black,null,2f,LineType.Discrete,Joins.Weld); textVectors[numberOfDots-1].MakeText("("+refX/snToPixel+","+refY/snToPixel+")",new Vector2(refX,refY+25),10f); textVectors[numberOfDots-1].Draw(); */ CizimBitti = true; CizimBasladi = false; } if (finish == false && CizimBitti == true && inside == true) { line.Draw (); CizimBitti = false; } if (oldWidth != Screen.width) { oldWidth = Screen.width; VectorLine.SetCamera (); } if (drawingDone) { VectorLine.Destroy (ref guideY); StartCoroutine ("SetArray"); } if (showVectorDrawing) { VelocityArray [0] = Vector2.zero;//initial velocity given int maxheight = 0; float snToPixelH = snToPixel; for (int i=0; i<=canerinIndex+1; i++) { VelocityArray [i + 1] = new Vector2 (canerinArray [i].x * snToPixel, VelocityArray [i].y + canerinArray [i].x * canerinArray [i].y * snToPixelH); if (Mathf.Abs (VelocityArray [maxheight].y) < Mathf.Abs (VelocityArray [i + 1].y)) maxheight = i + 1; } //Minimum 5 pixel olmak zorunda if (Mathf.Abs (VelocityArray [maxheight].y) > maxH / 2 && snToPixelH > 5) { snToPixelH = (maxH / 2) / Mathf.Abs (VelocityArray [maxheight].y / snToPixelH); } //hız değerleri. ilknokta farklı hesaplanıyor. VelocityArray [1] = new Vector2 (canerinArray [0].x * snToPixel, (VelocityArray [0].y + canerinArray [0].x * canerinArray [0].y * snToPixelH)); for (int i=1; i<=canerinIndex+1; i++) { VelocityArray [i + 1] = new Vector2 (canerinArray [i].x * snToPixel, (VelocityArray [i].y + (canerinArray [i].x - canerinArray [i - 1].x) * canerinArray [i].y * snToPixelH)); //debuging //print (canerinArray[i].x*snToPixel+"=time"+VelocityArray[i].y+"(ilk hız)+"+canerinArray[i].x+"(time)*"+canerinArray[i].y+"(hız)*"+snToPixelH+"snToPixelH"); } //0 noktasından çizlen grafiği taşır for (int i=0; i<=canerinIndex+1; i++) { VelocityArray [i] = new Vector2 (VelocityArray [i].x + minW, VelocityArray [i].y + maxH / 2 + minH); } VectorLine.Destroy(ref vtGraph); vtGraph = new VectorLine ("V-t Graph", VelocityArray, Color.yellow, null, 5f, LineType.Continuous); vtGraph.maxDrawIndex = canerinIndex + 1; vtGraph.Draw (); for (int i =0; i<=(maxH/snToPixelH)*2+2; i+=2) { linePointsY [i].x = minW - 5; linePointsY [i].y = minH + i * snToPixelH / 2; linePointsY [i + 1].x = minW + 5; linePointsY [i + 1].y = minH + i * snToPixelH / 2; } refPointsOnY.points2 = linePointsY; refPointsOnY.Draw (); //Numara yazımı for (int i =0; i<=maxH / snToPixelH*2+2; i+=2) { VectorLine.Destroy (ref linePointsYNmb [i / 2]); linePointsYNmb [i / 2] = new VectorLine ("Numb" + i / 2, new Vector2[2] { new Vector2 (minW - 15, minH + i * snToPixelH / 2), new Vector2 (minW, minH + i * snToPixelH / 2) }, Color.yellow, null, 2f, LineType.Discrete, Joins.Weld); if (Mathf.Round (((i / 2) * snToPixelH - maxH / 2) / snToPixelH) % 5 == 0) { if (i / 2 * snToPixel > maxH / 2) linePointsYNmb [i / 2].MakeText ("" + Mathf.Round ((i / 2 * snToPixelH - maxH / 2) / snToPixelH), new Vector2 (minW - 40, minH + i * snToPixelH / 2), 10f); else linePointsYNmb [i / 2].MakeText ("" + Mathf.Round ((maxH / 2 - (i / 2 - 1) * snToPixelH) / snToPixelH * -1), new Vector2 (minW - 50, minH + i * snToPixelH / 2), 10f); linePointsYNmb [i / 2].Draw (); } else VectorLine.Destroy (ref linePointsYNmb [i / 2]); } int newIndex = 0; for (int i=0; i<100; i++) { atGraphAfterVtPoints [i] = new Vector2 (linePoints [i].x, linePoints [i].y / snToPixel * snToPixelH + (Screen.height / 2 - (Screen.height / 2 / snToPixel * snToPixelH)) - snToPixelH); if (linePoints [i] != Vector2.zero) newIndex++; } VectorLine.Destroy(ref atGraphAfterVt); atGraphAfterVt = new VectorLine ("Line", atGraphAfterVtPoints, Color.white, null, 2f, LineType.Continuous, Joins.Weld); atGraphAfterVt.maxDrawIndex = newIndex - 1; atGraphAfterVt.drawTransform = transform; VectorLine.Destroy (ref line); atGraphAfterVt.Draw (); for (int i=0; i<numberOfDots; i++) { dotPoints [i] = new Vector2 (linePoints [i].x, linePoints [i].y / snToPixel * snToPixelH + (Screen.height / 2 - (Screen.height / 2 / snToPixel * snToPixelH)) - snToPixelH); } VectorLine.Destroy (ref dots); dots = new VectorPoints ("Dots", dotPoints, Color.red, null, 10f); dots.maxDrawIndex = numberOfDots - 1; dots.points2 = dotPoints; dots.Draw (); } } }
/// <summary> /// Draw cells for debugging purposes only /// </summary> /// <param name="cells">Cells.</param> private void DrawCells(List<Cell> cells) { // Calculate point count for Discrete type of line that will contain Rects int pointCount = cells.Count * 8; // Clear all debug lines each time (no exception if null) VectorLine.Destroy(ref debugCellLine); VectorLine.Destroy(ref debugPaddingLine); // Build line with proper parameters debugCellLine = new VectorLine("DebugCellLine", new Vector2[pointCount], null, 2, LineType.Discrete, Joins.Weld); debugCellLine.color = gridviewParameters.gridColor; debugPaddingLine = new VectorLine("DebugPaddingCellLine", new Vector2[pointCount], null, 2, LineType.Discrete, Joins.Weld); debugPaddingLine.color = gridviewParameters.paddingCellColor; // Build each Cell for(int i = 0; i < cells.Count; i++) { Cell cell = cells[i]; debugCellLine.MakeRect(cell.GetRectPoints(), i*8); debugPaddingLine.MakeRect(cell.GetPaddinRectPosition(), i*8); } // Show results debugCellLine.Draw(); debugPaddingLine.Draw(); }
void drawYellowPath(){ if(dragThrow.canUp){ answerPath_yellow = new VectorLine("dragLine_yellow", new List<Vector3>(), lineMaterial, lineWidth,LineType.Continuous); answerPath_yellow.textureScale = 1.0f; answerPath_yellow.color = dragThrow.yellowBox.GetComponent<SpriteRenderer>().color; for (int i = 0; i < dragThrow.yellow_ans.Length; i++) { answerPath_yellow.points3.Add(dragThrow.yellow_ans[i]); } answerPath_yellow.Draw(); } }
/// <summary> /// 画出网格 /// </summary> public void DrawGrid() { for (int i = 0; i <= MAX_ROW; i++) { Vector2 a = new Vector2 (0, Screen.height - i * rowStep); Vector2 b = new Vector2 (Screen.width, Screen.height - i * rowStep); VectorLine line = new VectorLine ("row" + i, new Vector2[]{a,b}, null, 1.0f); line.SetColor (Color.red); line.Draw (); } for (int j = 0; j <=MAX_COL; j++) { Vector2 a = new Vector2 (j * colStep, 0); Vector2 b = new Vector2 (j * colStep, Screen.height); VectorLine line = new VectorLine ("col" + j, new Vector2[]{a,b}, null, 1.0f); line.SetColor (Color.red); line.Draw (); } }
public static VectorLine SetRay(Color color, float time, Vector3 origin, Vector3 direction) { var line = new VectorLine("SetRay", new Vector3[] {origin, new Ray(origin, direction).GetPoint(direction.magnitude)}, color, null, 1.0f, LineType.Continuous, Joins.None); if (time > 0.0f) { lineManager.DisableLine(line, time); } line.Draw(); return line; }
public static VectorLine SetLine(Color color, float time, params Vector3[] points) { if (points.Length < 2) { LogError("VectorLine.SetLine needs at least two points"); return null; } var line = new VectorLine("SetLine", points, color, null, 1.0f, LineType.Continuous, Joins.None); if (time > 0.0f) { lineManager.DisableLine(line, time); } line.Draw(); return line; }
void DrawPath(List<Path> paths, Material material, int pathOffset) { foreach(Path path in paths){ List<Vector3> linePoints = new List<Vector3>(); // for(int i = 0; i < path.nodes.Count-1; i+=2){ // Vector3 prev = new Vector3((path.nodes[i].col-1) * spriteSize, (path.nodes[i].row-1) * spriteSize, -1); // Vector3 next = new Vector3((path.nodes[i+1].col-1) * spriteSize, (path.nodes[i+1].row-1) * spriteSize, -1); // // if(prev.y == next.y){ // prev = new Vector3(prev.x + pathOffset, prev.y+pathOffset, prev.z); // next = new Vector3(next.x + pathOffset, next.y+pathOffset, next.z); // } // // linePoints.Add(prev); // linePoints.Add(next); // // } foreach(Node node in path.nodes){ linePoints.Add(new Vector3((node.col-1) * spriteSize + pathOffset, (node.row-1) * spriteSize - pathOffset, -1)); } VectorLine pathLine = new VectorLine("ScoreLine", linePoints, material, pathHighlightWeight, LineType.Continuous, Joins.Weld); pathLine.Draw(); scoreLines.Add(pathLine); } }