javascript - How to create a hexagonal custom surface in famo.us -
javascript - How to create a hexagonal custom surface in famo.us -
i'm testing "famo.us" javascript framework, , don't know how "custom surfaces".
my goal create hexagonal surfaces (if possible rounded corners) , set surfaces next each other illustration :
but, need click on each surface , activate different actions depending on surface.
and set images on each surface !
right now, know how utilize rectangular famo.us surfaces, know how modify it, turn it, translate it, etc... possible create custom surfaces?
my project angular / famo.us project.
for moment thought create surfacecontainer 3 rectangular modified surfaces can't have rounded corners solutions, , it's not easy set images on it.
does 1 have idea? please share.
with skalár wag help, made hexagonal 3 rectangles, set border radius , set image on top. contained in "fa-container-surface" manage 1 event click hexagonal.
below code used :
<!-- hexa tile surface --> <fa-container-surface fa-click="onclickhexagontile(hexagon.idx)"> <!-- hexagon background --> <fa-modifier fa-opacity="hexagon.opacity"> <fa-container-surface> <fa-modifier ng-repeat="rect in rects" fa-origin="[0.5, 0.5]" fa-size="[csts.hexagontilewidth, 50]" fa-rotate-z="rect.rotatez"> <fa-surface fa-background-color="hexagon.color" class="hexagon-tile-rect"/> </fa-modifier> </fa-container-surface> </fa-modifier> <!-- image --> <fa-modifier fa-translate="[-30, -30, 0]" fa-size="[60, 40]"> <fa-image-surface fa-image-url="{{hexagon.img}}" fa-size="[60, 40]" class="hexagon-tile-img"/> </fa-modifier> <!-- text --> <fa-modifier fa-translate="[-30, 10, 0]" fa-size="[60, 20]"> <fa-surface class="hexagon-tile-text"> {{hexagon.text}} </fa-surface> </fa-modifier> </fa-container-surface>
and in controller :
/////////////////////////////// // define constants $scope.csts = { hexagontileheight: 75, hexagontilewidth: 80, hexagontilemargin: 5, }; /////////////////////////////// // define hexagonal definition // math.pi / 3 = 60° $scope.rects = [ {idx: 0, rotatez: 0}, {idx: 1, rotatez: math.pi / 3}, {idx: 2, rotatez: -math.pi / 3} ]; /////////////////////////////// // define hexagonal list $scope.hexagonlist = [ {idx: 0, column: 0, line: 0, color: "#43d0fa", opacity: 1, img: './img/1.png', text:'1'}, {idx: 1, column: 1, line: 0, color: "#14af59", opacity: 1, img: './img/2.png', text:'2'}, {idx: 2, column: 0, line: 1, color: "#e1553e", opacity: 1, img: './img/3.png', text:'3'} ]; /////////////////////////////// // hexagon tile events $scope.onclickhexagontile = function($hexagontileidx) { console.log('click on hexagon tile : ' + $hexagontileidx); };
javascript famo.us famous-angular
Comments
Post a Comment