Gradient drawn into a clipped context does not appear on simulators for iPhone 6 plus, 6s plus and 7 plus ONLY - ios-simulator

I have a custom UIView using draw rect in the typical way to draw. UIBezierPaths are created, used to clip/draw a gradient, and then code moves on to do more of the same.
While sublayers to this view DO show up, gradients drawn into the clipped context don't show up, but the problem is only in those 3 simulators. The gradients show up in all of the other simulators.

I decided to ask/answer this as it is the kind of thing that could take a long time to track down:
It turns out, just one of the UIBezierPaths was imperfect. I had edited the numbers by hand for that path. Once that imperfect path was involved, ALL of the gradients stopped working. Without that path, all was well.
For those who might be interested, here is the problematic path:
let groundPath = UIBezierPath()
groundPath.move(to: CGPoint(x: 0, y: 5))
groundPath.addLine(to: CGPoint(x: 7700, y: 5))
groundPath.addCurve(to: CGPoint(x: 8096, y: 135), controlPoint1: CGPoint(x: 8052, y: 5), controlPoint2: CGPoint(x: 8096, y: 50))
groundPath.addLine(to: CGPoint(x: 0, y: 135))
groundPath.addLine(to: CGPoint(x: 0, y: 5))
groundPath.close()
return groundPath
I had edited the control points by hand, and it looked how I wanted, but something did not sit well with the plus iPhones.

Related

Alternate between two elements in an infinite loop in framer-motion

I have an animation containing one svg element that rotates and then changes color during rotation.
What I want is that, at the second rotation it fades out and a new svg image takes it's place and then the same happens in reverse.
So, Imagine I have SvgA and SvgB, I want to make SvgA rotate, then wait, rotate again and when the rotation finishes SvgB should be at it's place to do exactly the same on an infinite loop.
Animations can happen infinitely using a transition, but that only applies to a single component. I think I could use AnimatePresence and AnimateSharedLayout to swap between the components, but I am unsure about how to "toggle" between them on an infinite loop.
Maybe I can use variants + animation controls and an infinite asynchronous loop to run them as long as the component exists, but I am not sure how to orchestrate it.
This is the animation that I have so far:
// primary and secondary are defined colors
const animation = {
scale: [1, 2, 2, 1, 1],
rotate: [0, 0, 360, 360, 0],
color: [primary, primary, secondary, secondary, primary],
};
const transition = {
duration: 2,
ease: "easeInOut",
times: [0, 0.2, 0.5, 0.8, 1],
loop: Infinity,
repeatDelay: 1,
};
<motion.div animate={animation} transition={transition}>
<IconA className={css.icon} />
</motion.div>
<motion.div transition={ default: {repeat: Infinity} } />
This will make sure your element will loop through the animation for ever

Issue with background color of an image inside a button SwiftUi

image inside the button appears blue. I cant figure out how to fix it.
Button(action: {self.count += 1}) {
Circle()
.fill(LinearGradient(gradient: Gradient(colors: [Color("linkAccount1"), Color("linkAccount2")]), startPoint: UnitPoint(x: 0, y: 0.2), endPoint: UnitPoint(x: 1, y: 1)))
.frame(width: 80, height: 80)
.shadow(color: Color("shadowColor1"), radius: 7, y: 7)
.overlay(
//issue with image backgroud or foregroundColor
Image("linkAccount")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 60, height: 60))
}
Solution:
Image("linkAcount").renderingMode(.original)
As per my comment above, the issue is caused by the rendering mode of the Image.
You can overcome the tinting problem by using the .renderingMode() modifier, and setting the mode to be .original. This tells the image to ignore the tint.
Image("linkAcount").renderingMode(.original)
Images and Text contained within a button get rendred in accent colour, which by default is blue, just apply:
.accentColor(.white)
to your Button to have the image drawn in white.

Mozilla AFRAME a-frame not able to set offset or repeat for material

I have ran across a big problem in AFRAME. In my current project, the user is able to change the scale of a plane with a texture mapped onto it by the press of a button. Of course, I then need to change the tiling (or repeat, how it is called in AFRAME) - but no matter how I try to do it, I can not get the repeat or offset to change. The wierd thing is, when I try to change the materials color, it works fine. I think the problem is that AFRAME is somehow not updating the repeat at runtime?! Maybe I also pass the parameters X and Y in a wrong way?
This is what I tried so far:
//document.querySelector('#wall-1').setAttribute('material', {color: 'red', offset: {x: 22, y: 22}});
//document.querySelector('#wall-1').setAttribute('material', {color: 'red', repeat: 12});
//document.querySelector('#wall-1').setAttribute('material', {color: 'red', repeat: {type: 'vec2', value: {x: 22, y: 22}}});
//document.querySelector('#wall-1').setAttribute('material', {repeat: {value: {x: 1, y: 1}}});
//document.querySelector('#wall-1').setAttribute('repeat', {type: 'vec2', value: {x: 22, y: 22}});
//document.querySelector('#wall-1').setAttribute('material.repeat', {type: 'vec2', value: {x: 22, y: 22}});
//document.querySelector('#wall-1').setAttribute('material', 'repeat', '{x:22, y:22}');
I would be glad for ANY help!
Thanks a bunch & best,
- Max
There was a bug, but this was fixed at https://github.com/aframevr/aframe/pull/2253
Try this build: https://rawgit.com/aframevr/aframe/64d772a/dist/aframe-master.min.js
I was also unable to repeat textures when using a-assets on an a-entity.
I could on an a-box, but had to call the .jpg directly inline when using a-entity instead of using the a-assests. I know this takes up more memory, and file space if used a lot, but at least it started working.
Using <a-box> for everything worked for me,
as did inline links in <a-entity> without using <a-assets>.
Here is a small fiddle showing it working:
https://jsfiddle.net/RonK/tjfwhdsd/16/

drawing text in PlayN doesn't appear

I'm trying to draw a rectangle with text on it, but all I see is the rectangle, there is no text. Am I doing something wrong?
This is the part of the code that does the drawing:
CanvasImage image = PlayN.graphics().createImage(100, 50);
Canvas canvas = image.canvas();
canvas.setFillColor(color);
canvas.fillRect(0, 0, 100, 50);
canvas.setFillColor(textColor);
canvas.setStrokeColor(textColor);
canvas.drawText("test", 0, 0);
layer.surface().drawImage(image, 0, 0);
Thanks
btw, I'm running the HTML version.
The problem was that the text is drawen up from the y coordinate and I was setting y to 0 so the text wasn't shown.

Rotate a drawn rectangle in flex

i wrote the following code for drawing a rotate rectangle
var s:UIComponent = new UIComponent();
s.graphics.lineStyle(1, 0x0000FF);
s.graphics.drawRect(50, 50, 200, 200);
s.rotation = 30;
template.addChild(s);
where template is a canvas. Its rotate nicely but the problem is the position is not in right place. i.e. it is not in (50,50) after rotate. How can i solve this problem?
Thanks in advance.
What you're seeing is the default rotation around the origin in Flex (in your case the X,Y coordinates of 50,50) I am assuming that you want to rotate around the center (as I recently had to do). There is the jury rig way to do it, by adjusting the origin point based on rotation angle. Then there is the rotate effect:
import mx.effects.Rotate;
var s:UIComponent = new UIComponent();
var rotator:Rotate = new Rotate(s);
s.graphics.lineStyle(1, 0x0000FF);
s.graphics.drawRect(50, 50, 200, 200);
rotator.angleFrom = 0;
rotator.angleTo = 30;
rotator.originX = s.width/2;
rotator.originY = s.height/2;
template.addChild(s);
rotator.play();
Now I've noticed some problems with this that required me to set the width and height of the rotated object again after the play() method, but other than that I get the ideal rotation situation.
Another downside to this is that it's an effect, which means it visually rotates the object. I will post back when I correct that, if you don't want to see the object rotate.
The Answer is duration
just by adding rotator.duration = 1 before play it happens so quick the user won't see it. 1 being 1 millisecond. I tried 0, but that resulted in no rotation occurring. Obviously if you want to see the effect in action you can increase that length of time by using any value in milliseconds.

Resources