04-27-2022 07:52 - edited 04-27-2022 07:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-27-2022 07:52 - edited 04-27-2022 07:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have a gradientRect as the back of my clockface svg. I want it to be rotated 45 degrees diagonally so the gradient goes from the top left to the bottom right not side to side. I've tried wrapping it in a g container
<g transform="rotate(45)">
<gradientRect id="bg" width="100%" height="100%" />
</g>
#bg {
gradient-type: "linear";
gradient-x1: "0";
gradient-y1: "50";
gradient-x2: "0";
gradient-y2: "100%-50";
gradient-color1: "magenta";
gradient-color2: "red";
}
It rotates the gradientrect but moves it out of place. I also need it to cover the whole screen. Any idea the best approach to have a diagonal linear gradient? Thanks!

04-28-2022 03:10 - edited 04-28-2022 05:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
04-28-2022 03:10 - edited 04-28-2022 05:48
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi, I think you might need to add a translate to the group, as its coordinates are the center of its rotation , then set your gradientRect's (x,y) to its (-width/2, -height/2) to place it centered.
To enlarge the rect to cover the whole screen you could calc the needed size using good old pythagoras.
04-28-2022 08:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-29-2022 01:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
04-29-2022 01:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
To get length of the diagonal, which would be width and height needed for a 45° rotated rect it's:
needed size = squareRoot(screenWidth * screenWidth + screenHeight * screenHeight)
Set outer g to (centerX,centerY)
the rect inside the g to (-neededSize/2, -neededSize/2)
09-09-2022 06:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 06:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi! Were you able to solve the problem? I'm stuck with this 😞

09-09-2022 08:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
09-09-2022 08:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi @Sebafit ,
What is your code and how does it look like in sim compared to what you want to achieve exactly?
Perhaps I can explain better...

09-09-2022 09:25 - edited 09-09-2022 09:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 09:25 - edited 09-09-2022 09:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I have two collision points rotating a "line" inside a box. With two coordinates I can put values into x1, y1, x2, y2 (setting the lowest into 1 and biggest into 2), but I can't simulate gradient rotation from 0 to 359 degrees 😕
I can move gradient angle inside -X, Y (first quarter) only...

09-09-2022 09:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 09:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
If I rotate the gradientRect, the gradient color stay in original direction

09-09-2022 09:55 - edited 09-09-2022 10:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
09-09-2022 09:55 - edited 09-09-2022 10:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Maybe this helps...
You can't create the gradient as diagonal, AFAIK. You need to rotate a group containing the gradient(with transform rotate)

09-09-2022 10:00 - edited 09-09-2022 10:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
09-09-2022 10:00 - edited 09-09-2022 10:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
oh, sounds like you want to animate the rotation angle?
This can be done on the group of course, but I don't know, if the hardware would like to render that. in that case you might perhaps try with an image instead (There has been a bug on rotating big images though cutting off parts, which could be workaround by cutting the image into pieces and arrange them inside the rotating g. Not sure, if this had been fixed meanwhile)

09-09-2022 12:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 12:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It's working now! I don't know why wasn't working before...
index.view
<svg>
<g id="gGradRectangle" pointer-events="visible" transform="translate(50%, 50%)">
<gradientRect id="gradRectangle" x="-238" y="-238" width="476" height="476"
gradient-type="linear"
gradient-x1="238" gradient-y1="0"
gradient-x2="238" gradient-y2="476"
gradient-color1="black"
gradient-color2="black"/>
</g>
</svg>
app/index.js
messaging.peerSocket.onmessage = evt => {
if (evt.data.key === "degreeGradient" && evt.data.newValue) {
let degrees = JSON.parse(evt.data.newValue);
document.getElementById("gGradRectangle").groupTransform.rotate.angle = degrees;
}
}

09-09-2022 12:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 12:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
On simulator works, but not into watch! T-T
It's like the "translate" is not working... it's decentered 😕

09-09-2022 13:12 - edited 09-09-2022 13:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


09-09-2022 13:12 - edited 09-09-2022 13:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Just a guess: try the translate with pixel values rather than %.
And/or, declare a rotate inside your transform, even if you don't need it initially.
Gondwana Software

09-09-2022 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 13:27
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Not working neither

09-09-2022 13:58 - edited 09-09-2022 14:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
09-09-2022 13:58 - edited 09-09-2022 14:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
My last idea fir today: In the transform, did you set the translate first? I think the order is important.
If that doesn't do, you finally could try to translate in app.js...

09-09-2022 14:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


09-09-2022 14:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Here's something that works for me (in a different context). I haven't tried changing the rotate angle in code.
<g transform="translate(100%,0) rotate(90)">
<gradientRect id="gradient" width="100%" height="100%" opacity="1"
gradient-type="linear"
gradient-x1="0" gradient-y1="0"
gradient-x2="100%" gradient-y2="100%"
gradient-color1="#102020" gradient-color2="#306060"
/>
</g>
Gondwana Software

09-09-2022 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 18:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It's a bug... visible background behind gradient rectangle has "artifacts"...

09-09-2022 19:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 19:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I put 2 sliders to move X and Y offset and note than the location works, but the "paint" of gradient fails... some area is well painted and some another has "visual glitch" or "artifacts".
I readed than rotation of g is bugged since 2014... 8 years... maybe developers don't fix it never 😞

09-09-2022 19:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


09-09-2022 19:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Elements that extend too far off the right side of the screen can appear cropped (ie, missing) on the left of the screen. Is that what you're seeing?
Gondwana Software

09-09-2022 19:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-09-2022 19:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Tomorrow I'll make some test with sizes, maybe we have a size limitation rotating by code. I'll test rotation directly into view too.

