Created
February 24, 2017 09:52
-
-
Save JavaCS3/e00b795d8c9a99812e19cc9cfc0e718a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.4 | |
Image { | |
property color color | |
property int top_left_radius | |
property int top_right_radius | |
property int bottom_left_radius | |
property int bottom_right_radius | |
function rounded_rect(x, y, w, h, top_left_r, top_right_r, bottom_right_r, bottom_left_r) { | |
return "M" + (x + top_left_r) + "," + y | |
+ "h" + (w - top_left_r - top_right_r) | |
+ "a" + top_right_r + "," + top_right_r + " 0 0 1 " + top_right_r + "," + top_right_r | |
+ "v" + (h - top_right_r - bottom_right_r) | |
+ "a" + bottom_right_r + "," + bottom_right_r + " 0 0 1 " + -bottom_right_r + "," + bottom_right_r | |
+ "h" + (bottom_left_r + bottom_right_r - w) | |
+ "a" + bottom_left_r + "," + bottom_left_r + " 0 0 1 " + -bottom_left_r + "," + -bottom_left_r | |
+ "v" + (bottom_left_r + top_left_r - h) | |
+ "a" + top_left_r + "," + top_left_r + " 0 0 1 " + top_left_r + "," + -top_left_r | |
+ "z"; | |
} | |
source: 'data:image/svg;charset=utf-8,<svg><g><path d="%1" fill="%2"/></g></svg>'.arg(rounded_rect(0, 0, width, height, top_left_radius, top_right_radius, bottom_right_radius, bottom_left_radius)).arg(color.toString()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment