How to edit a bezier path in xcode after view loads - xcode

I need to be able to update the three points of my bezier path in xcode after the view has loaded.I would like to update my bezier path by a NSTimer. I am able to draw the initial bezier path, but I can't figure out how to change it after the initial loading! I am making a slingshot, so that's why I need to change my bezier path often. ANY Suggestions?

NSBezierPath is an immutable path. Rather than changing an existing one, you need to create a new one with the updated points.

Related

How to select an object and move camera into to another position?

I have a problem I don't known how I can select the position of the selected inside scene and move camera into it
I found a project sample, and I want to build an example like it
Sample project
Thank you so much!
You basically solve this problem in two steps:
First, you have to make 3D objects selectable which can be done via raycasting. There are many official examples that demonstrate 3D interaction based on raycasting, for example:
https://threejs.org/examples/webgl_interactive_cubes
If you know that a certain 3D object was clicked, you animate the camera from its current position to a defined target position. The possible target positions can be defined prior or you compute the in some way on the fly based on the object's bounding volume and the current camera position. The actual animation can be done in many ways. One approach is using a tweening engine like tween.js. Check out the following example to see how it is used together with three.js:
https://threejs.org/examples/css3d_periodictable

Add triangles along path with D3

I am trying to replicate the image below using OpenLayers and D3.js.
I have tried to add triangles along the path using getPointAtLength() and just adding them as SVG elements, but that does not take care of the orientation of the line. To get this working I would need to find the slope and rotate each triangle.
I have also taken a look at this StackOverflow answer:
How to place arrow head triangles on SVG lines?
This looks great but unfortunately it only works for polylines. However, since I am using D3.js together with OpenLayers it seems like I have to use paths and not polylines since I need the d3.geo.path function to transform all features on the map.
As for now it seems like I have the following options:
Add triangles along the path by calculating the slope at every point. Is there an easy way to calculate slope along a path?
Somehow combine D3.js og and OpenLayers and use polylines instead of paths. Is this possible?
Somehow convert my path to a polyline and draw that one instead of the path. Is there a function for doing this?
Are there other options that I can test out?
You could call getPointAtLength at two points separated by a delta. The slope of the two points would be the slope of the path if the delta is small enough.

Is there a way to look at position without moving the vertices? (move the verts so it appears like it)

I need my object to look in a direction(lookAt), but also reposition verts so that they appear not to move.
I can't seem to find a way to do this.
this.part[this.part.length-1].lookAt(vector);
Okay, I managed to figure out how to do it.
I replaced the line with the following
this.part[this.part.length-1].children[0].geometry.applyMatrix( new THREE.Matrix4().makeRotationFromQuaternion( mesh.quaternion ) );
It applies the transformation to the vertices in the geometry as far as I know, based on the orientation of the provided object(mesh).
It solved my problem, but to be more specific to the question; you'd have to store the quaternion before lookat, and then apply this after to move back the vertices. I think.

How to change texture coord after a TriangleMesh was created in JavaFx?

I created a TriangleMesh in JavaFx. The vertices were assigned some initial texture coordinates. I want to animate the texture on the mesh by changing the texture coordinates of the vertices slowly over time. Is this possible? If so, how to do it? If not, what is the best way to achieve this effect?
It is possible...
One approach would be to create a property Double for uvStartX, uvStartY (u,v) ..
Override invalidated method, in the invalidated method, call setMesh(meshMethod)
change those values in a timeline..
I've done something similar with points, meshdivisions etc...
It works and is rather smooth too.
Hard part is making sure all your code maps to a point between 0-1.0 and keeping those points
lined up to each other.

polyline with gradient

Is there a way to draw a line along a curved path with a gradient that varies in a direction perpendicular to the direction of the line? I am using the GDI+ framework for my graphics.
The simple answer is no. You can create a GraphicsPath in order to describe what you would like to draw, using AddPoint/AddLine/AddBezier and so forth as needed to describe the complex path of what you want to draw. When you draw the path you can provide a Brush which can be something like LinearGradientBrush or RadialGradientBrush. Neither of those gradient brushes reacts to the actual path being drawn in the sense of changing direction as the drawing occurs. You have to specify the angles etc as constant for the entire gradient area.
One possible method you can use is to set the clip region of the Graphics object to be that of the line only. Then draw a Linear Gradient over the extremes of the line e.g.
GraphicsPath gp = new GraphicsPath();
gp.AddArc(); // etc...
graphics.SetClip( gp );
graphics.FillRectangle( myLinearGradientBrush, gp.GetBounds());
The above code might give you what you are looking for.

Resources