shape

Using reshape in Python to reshape an array

自作多情 提交于 2019-12-04 12:52:32
I have an array that looks like below: array([[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7]]) How can I use reshape to divide it into 4 chucks, such that it looks like array([[[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], [[0, 0, 0, 0], [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7]], [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6], [7, 7, 7, 7]]]) I tried different integer

How to programmatically create or alter a drawable made of lines of different colors

只愿长相守 提交于 2019-12-04 12:29:52
问题 I have to draw a 3dp line to represent a level completion in a quizz game. This line must be of 2 colors. For example, if user has completed 40% of the level, the line will be red for the first 40% of the line, the other 60% being grey. I have managed to do that with a drawable : <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="line" > <size android:height="3dp" android:width="40dp"/> <stroke android

Create a complex CSS shape (speaking bubble)

依然范特西╮ 提交于 2019-12-04 11:20:32
What would be your best option or method to create a shape as seen in the attachment link full CSS and is that possible anyway?? I did research and testing with CSS parallelogram e.g. but not with any good succes yet. See the shape here -->> http://tinypic.com/r/352ge3b/6 I had this thing that it could be done with just one element - and it can be done, I just don't think it's exactly the best solution to do it like this. DEMO HTML : <div class='speech-bubble'>Hello!</div> CSS : .speech-bubble { position: relative; margin: .5em auto; padding: 1em; width: 10em; height: 4em; border-radius: .25em

How to change the shape of Floating Action Button (FAB) on android?

百般思念 提交于 2019-12-04 09:15:42
问题 In our android app we need to create a floating action button which isn't the default circle but a square with with three rounded corners. The fab looks like in the image below: I managed to create such a form but don't know how to apply it to my fab, or if it's even possible. The xml file for the shape looks like this: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/red" /> <corners android:topLeftRadius="90dp" android

Android shape background

主宰稳场 提交于 2019-12-04 08:48:03
问题 Is it possible to draw a shape in xml, and use a png as the background to that shape? I already have the shape (it's a square with rounded corners), and i would like to put a background to that square. 回答1: Yes you can use any shape file as background for any view. This sample create rounded background with white color and black border around the shape. Sample : rounded_corner.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android

Android Button's background as shape with Shadow

不羁岁月 提交于 2019-12-04 08:01:19
问题 I've made a button background from shapes and is looking quite good for my purpose. The only thing needed is to drop a bit of shadow for it. Here is the code: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape> <solid android:color="#343434" /> <stroke android:width="1dp" android:color="#171717" /> <corners android:radius="3dp" /> <padding android:bottom="10dp" android:left="10dp" android

Triangulation of 3D points with K vertices per face

你。 提交于 2019-12-04 07:38:05
I'm working with Three.js. I have a collection of 3D points (x, y, z) and a collection of faces. One face is composed of K points . It can be as well convex as concave. I found nothing that could help me in the Three.js documentation. One solution could be to triangulate those shapes, but so far I haven't found any simple 3D triangulation algorithm. The other solution would be doing something like that : var pointsGeometry = new THREE.Geometry(); pointsGeometry.vertices.push(new THREE.Vector3(10, 0, 0)); pointsGeometry.vertices.push(new THREE.Vector3(10, 10, 0)); pointsGeometry.vertices.push

Drawing a circle using Andengine

吃可爱长大的小学妹 提交于 2019-12-04 04:20:03
问题 I am searching a way to draw a circle using Andengine. As I can see, I can only draw lines, rectangles, and place sprites, but I cannot find a way to draw circles. How can I do this? 回答1: Indeed, you can't directly draw a circle. Alternatives are: Rendering a quad with a circle texture (see this link, for example) Rendering a circle that's actually a circle of connected triangles. You'd have to procedurally generate the geometry to approximate a circle. For a solid circle, that's not so hard.

Java - Create a shape from border around image

六月ゝ 毕业季﹏ 提交于 2019-12-04 04:09:23
问题 i have a class that draws a shape from a png image, so that i can use the shape to draw the border of custom buttons that i need for my project. here's the code for the class to draw the shape of an image: public class CreateShapeClass { public static Area createArea(BufferedImage image, int maxTransparency) { Area area = new Area(); Rectangle rectangle = new Rectangle(); for (int x = 0; x < image.getWidth(); x++) { for (int y = 0; y < image.getHeight(); y++) { int rgb = image.getRGB(x, y);

Click on given element in canvas

坚强是说给别人听的谎言 提交于 2019-12-04 03:58:35
问题 Is there any trick to determine if user clicks on given element rendered in canvas? For example I'm displaying rhombus from .png file with transparent background and i want to know if user click inside or outside that figure (like mouse-element collision). 回答1: There is no concept of individual elements in a canvas - it is simply just an area that you're drawing pixels onto. SVG on the other hand is made up of elements which you can then bind events to. However there are a few approaches you