Saving images in Python at a very high quality

If you are using Matplotlib and are trying to get good figures in a LaTeX document, save as an EPS. Specifically, try something like this after running the commands to plot the image: plt.savefig(‘destination_path.eps’, format=”eps”) I have found that EPS files work best and the dpi parameter is what really makes them look good in … Read more

Ball to Ball Collision – Detection and Handling

To detect whether two balls collide, just check whether the distance between their centers is less than two times the radius. To do a perfectly elastic collision between the balls, you only need to worry about the component of the velocity that is in the direction of the collision. The other component (tangent to the … Read more

How do I position one image on top of another in HTML?

Ok, after some time, here’s what I landed on: .parent { position: relative; top: 0; left: 0; } .image1 { position: relative; top: 0; left: 0; border: 1px red solid; } .image2 { position: absolute; top: 30px; left: 30px; border: 1px green solid; } <div class=”parent”> <img class=”image1″ src=”https://via.placeholder.com/50″ /> <img class=”image2″ src=”https://via.placeholder.com/100″ /> </div> … Read more

Creating a blurring overlay view

You can use UIVisualEffectView to achieve this effect. This is a native API that has been fine-tuned for performance and great battery life, plus it’s easy to implement. Swift: //only apply the blur if the user hasn’t disabled transparency effects if !UIAccessibility.isReduceTransparencyEnabled { view.backgroundColor = .clear let blurEffect = UIBlurEffect(style: .dark) let blurEffectView = UIVisualEffectView(effect: … Read more

How can I determine whether a 2D Point is within a Polygon?

For graphics, I’d rather not prefer integers. Many systems use integers for UI painting (pixels are ints after all), but macOS, for example, uses float for everything. macOS only knows points and a point can translate to one pixel, but depending on monitor resolution, it might translate to something else. On retina screens half a … Read more