I'm developing an html5 canvas image application where you could make basic transformation like 90º rotation, flip horizontal and vertical.
I use the following matrix to paint the image:
matrix.scale(flipHorizontal, flipVertical); // Where each flip could be 1 or -1
matrix.rotateZ(angle); // Angle could be 0,90,180 or 270º
Everything looks fine at the beginning but when I make a rotate90º and after an horizontal flip it just acts like a vertical flip.
Any idea how to fix it?
example http://img688.imageshack.us/img688/1570/73811955.jpg
Try this plugin
Demo: http://dmadan.in/imageflip.html
Source: https://github.com/dmadan86/imageflip
It works in both css3 and Canvas.
Cannot tell from the code snippet you have given. Could be a mistake inside the functions or when you call the functions. Might be something to do with how the axes are being handled.
A horizontal flip is a reflection in the y (vertical axis). After rotation the y axis of your image is now horizontal, so unless you correctly deal with the axes a 'horizontal flip' will reflect in the y axis which is now horizontal producing the image as given.
Related
Is it possible to change x-axis label orientation like marked area on the screenshot? I was trying rotate labels with afterCalculateTickRotation but they weren't flipped. Mirror option doesn't work also.
Example code
I managed to do what you are asking for but it's not beautiful because chart.js lacks support to do it properly. So I solved it with some hard coded padding.
https://codesandbox.io/s/vue-template-4ygr1
It's the minRotation and maxRotation you should work with. The labels anchoring point should shift when the rotation goes below zero but they don't. Instead they rotate into the chart but this can be avoided with padding.
A side effect of the padding is that the legend placement broke so i put it in the top instead.
Another unwanted behavior is that the text is aligned to the right. There is an open issue about that: https://github.com/chartjs/Chart.js/issues/4193
I work with Forge Autodesk, and I want to apply a texture to some rectangle object. In fact I just needed some plan, but I was given a rectangle. So I want to apply my image on the main face of the rectangle.
const mytex = THREE.ImageUtils.loadTexture(mytexture)
// Repeat image through object
mytex.wrapS = THREE.RepeatWrapping //ClampToEdgeWrapping //MirroredRepeatWrapping //RepeatWrapping
mytex.wrapT = THREE.RepeatWrapping //ClampToEdgeWrapping //MirroredRepeatWrapping //RepeatWrapping
mytex.mapping = THREE.UVMapping
mytex.repeat.set (0.05, 0.05)
console.log("applied texture")
But I get this problem : a part of my image appears on the right upper side (upper and right corners are cut, so not on the rectangle), but the left and bottom sides are stretched across the rest of the rectangle face.
I would like to adapt my image so that its dimension fit the rectangle's dimensions, and not just repeat it.
I read this and this. I think my code is correctly written, but I may be missing a parameter or set the wrong one... The 2 images I am testing are 676x676 and 1024x484 pixels. I cannot access the rectangle dimensions from my function (I don't think so).
I tried to just repeat the image too but it does not work either...
Any idea ?
I'm having a trouble getting the X and Y of a canvas. So originally this is my canvas.
And I'm using a scale() to zoom my canvas, and when I use it, it will become like this.
My goal is to get the X and Y of this part of my zoomed canvas
I tried to get the the width and height of my canvas, however I can't show the object that I locate to the zoomed canvas. I need to zoom it out just to show it. I want to get the x and y of that part of my canvas so even I zoom in or zoom out the canvas, it will stay there. How can I do that? Thank you.
That value is just width/scale, isn't it?
Think about it this way: if your canvas is 1000 pixels wide, and you then call scale(2), what coordinate will be in the upper-right corner? Since you've scaled by 2, the new coordinate will be 500, which is 1000 / 2, or width / scale. Note that you have to keep track of the scale value yourself.
I'm pretty sure this pattern holds no matter what the width or scale is. I'd recommend putting together some example programs to test whether the point shows up where you expect it to. If not, please post a MCVE and we'll go from there.
First I am explaining the above image. Image is marking with 1, 2 and 3.
1 - This is the rectangle shape.
2 - This is the rectangle shape.
3 - This is the circle shape (draw with destination-in global composite operation).
Every shape draw using HTML5 canvas.
Now I want to same draw using threejs with WebGLRenderer. So is it possible to draw? If yes then how?
3rd shape can be anything (for ex - circle, rectangle, polygon).
Any suggestion?
We can erase an area in threejs by set the blending property. In threejs different types of blending property available. For example THREE.SubtractiveBlending which is use to subtract the area.
For details -
1) http://threejs.org/docs/#Reference/Constants/Materials
2) http://threejs.org/examples/#webgl_materials_blending
3) http://threejs.org/examples/#webgl_materials_blending_custom
To draw using WebGLRenderer, is basically changing the canvas by:
renderer = new THREE.WebGLRenderer();
Just beware of the methods of Canvas that do not exist in WebGLRenderer.
If you show as part of the code, it would be good to give more precision. But anything, just comment here!
How do i fill some BitmapData image with other image pattern in as 3.0? For example, i have an white image with black square at the center which would be "square:BitmapData" and the other image with little(2x2) blue circle which i would call "circle:BitmapData". I want to fill that square with this blue circles, is there any way to do this?
UPDATE
Here i found the example of what i need to do:
This is two images (left is like my square, right is like the blue circle)
http://pix.samoucka.ru/img/content/graphics/thewebschedule/8/466.gif
And this is how it would look after filling
http://pix.samoucka.ru/img/content/graphics/thewebschedule/8/467.gif
You can try using copyPixels() and iterating though x and y to tile the whole thing, copyPixels() is very fast.
Or
It might be simpler to create a Sprite and use graphics.beginBitmapFill() then graphics.drawRect() with the correct size, then draw() to the BitmapData in the correct position.
If you need to determine the size and position of the black square, getColorBoundsRect() should do the job.