Skip to content

Commit

Permalink
Merge branch 'master' of github.com:iBeliever/qml-extras
Browse files Browse the repository at this point in the history
  • Loading branch information
iBelieve committed Jan 10, 2015
2 parents 76278ab + 6d1f003 commit d82ce86
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ install:
script:
- qmake
- make check

notifications:
slack: papyros:Dfl04xnx2RdvHLiue5Lm7v5R
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
QML Extras
==========

[![Build Status](https://travis-ci.org/quantum-os/qml-extras.svg)](https://travis-ci.org/quantum-os/qml-extras)
[![Build Status](https://travis-ci.org/papyros/qml-extras.svg)](https://travis-ci.org/papyros/qml-extras)

Extra types and utilities to make QML even more awesome

Expand Down
6 changes: 4 additions & 2 deletions modules/Material/Extras/CircleImage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,28 @@
*/

import QtQuick 2.3
import Material.Extras 0.1 as Extras
import QtGraphicalEffects 1.0

Item {
id: item

property alias source: image.source
property alias status: image.status
property alias averageColor: image.averageColor

width: image.implicitWidth
height: image.implicitHeight

Image {
Extras.Image {
id: image
anchors.fill: parent
smooth: true
visible: false
mipmap: true
}

Image {
Extras.Image {
id: mask
source: Qt.resolvedUrl("images/circle.png")
anchors.fill: image
Expand Down
37 changes: 37 additions & 0 deletions modules/Material/Extras/Image.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import QtQuick 2.3

Image {
id: image

property color averageColor

Canvas {
id: canvas

opacity: 0

onAvailableChanged: {
var imgSource = image.source;
canvas.loadImage(String(imgSource));
var context = canvas.getContext("2d"),
pixelInterval = 5,
count = 0,
i = -4,
rgba = {"r": 0, "g": 0, "b": 0, "a": 0},
data = context.createImageData(String(imgSource)).data,
length = data.length;
while ((i += pixelInterval * 4) < length) {
count++;
rgba.r += data[i];
rgba.g += data[i+1];
rgba.b += data[i+2];
rgba.a += data[i+3];
};
rgba.r = Math.floor(rgba.r/count);
rgba.g = Math.floor(rgba.g/count);
rgba.b = Math.floor(rgba.b/count);
rgba.a = Math.floor(rgba.a/count);
image.averageColor = Qt.rgba(rgba.r/255, rgba.g/255, rgba.b/255, rgba.a/255);
}
}
}
1 change: 1 addition & 0 deletions modules/Material/Extras/qmldir
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Material.Extras

CircleImage 0.1 CircleImage.qml
Image 0.1 Image.qml
ColumnFlow 0.1 ColumnFlow.qml
Document 0.1 Document.qml
Object 0.1 Object.qml
Expand Down

0 comments on commit d82ce86

Please sign in to comment.