小编vim*_*984的帖子

html5 canvas strokeStyle?

我试图将图像映射到使用strokeStyle和canvas模拟布料的"3d"网格,我有包含的图像,但它目前充当背景图像而不是实际上流动的"布",因为是涟漪,IE当网格流动时,图像是静态的.这里是自我解释的jsfiddle(仅适用于Chrome).任何帮助深表感谢.这里是将图像渲染到背景中的javascript,如何停止渲染为背景图像并仅使其填充网格?:

function update() {

    var img = new Image();
    img.src = 'http://free-textures.got3d.com/architectural/free-stone-wall-   textures/images/free-stone-wall-texture-002.jpg';
    img.onload = function() {

        // create pattern
        var ptrn = ctx.createPattern(img, 'repeat');

        ctx.clearRect(0, 0, canvas.width, canvas.height);

        physics.update();

        ctx.strokeStyle = ptrn;
        ctx.beginPath();
        var i = points.length;
        while (i--) points[i].draw();
        ctx.stroke();

        requestAnimFrame(update);
    }
}
Run Code Online (Sandbox Code Playgroud)

她是我工作的原始代码.`更新小提琴与图像外侧的功能更新():目前,它似乎确实填补细胞以及把它当成一个背景图像.有没有办法阻止它成为背景图像,只应用它来填充网格?我试过这个:
ctx.fillStyle = ptrn; 并删除第260行:
ctx.strokeStyle = ptrn; 但它似乎删除了背景图像只是将其显示为黑色网格...再次感谢您的耐心

javascript html5 2d canvas

25
推荐指数
1
解决办法
4651
查看次数

关闭所有信息窗口谷歌地图API V3?

如何在关闭另一个引脚或单击地图时关闭所有信息窗口?我正在使用http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html 和kml叠加层.继到我的JS到目前为止:

jQuery(document).ready(function ($) {
    function initialize() {
        google.maps.visualRefresh = true;
        var myLatlng = new google.maps.LatLng(51.201465, -0.30244);
        var mapOptions = {
            zoom: 12,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        var map = new google.maps.Map(document.getElementById('map-canvas'),
        mapOptions);

        var kmlLayer = new google.maps.KmlLayer({
            url: 'http://***.com/new/wp-content/themes/required-starter/CGAGolfAcademies.kml?rand=' + (new Date()).valueOf(),
            suppressInfoWindows: true,
            map: map
        });

        google.maps.event.addListener(kmlLayer, 'click', function (kmlEvent) {
            showInContentWindow(kmlEvent.latLng, kmlEvent.featureData.description);
        });

        function showInContentWindow(position, text) {
            var content = "<div class='info_win'><p>" + text + "</p></div>";
            var infowindow =new InfoBox({
                 content: content,
                 disableAutoPan: false,
                 maxWidth: …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3

15
推荐指数
2
解决办法
3万
查看次数

检测是否启用了cors?

如何通过javascript检测是否在html5音频元素的远程文件上启用了cors?

我想仅在音频标签的远程src文件启用了cors的情况下输出附加到AudioContext的可视化工具。

javascript cors

5
推荐指数
1
解决办法
6112
查看次数

具有自定义分类的WP-API自定义帖子类型

我正在与https://github.com/WP-API/WP-API作斗争我正在尝试使用名为listing_categy的自定义分类法添加自定义帖子类型:查询此终结点:

http://example.com/subfolder/wp-json/taxonomies/listing_categy/terms

给我这个:

[
  {
    "ID": 9,
    "name": "buying",
    "slug": "buying-2",
    "description": "",
    "parent": null,
    "count": 1,
    "link": "http:\/\/example.com\/subfolder\/listing_categy\/buying-2\/",
    "meta": {
      "links": {
        "collection": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms",
        "self": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms\/7"
      }
    }
  },
  {
    "ID": 10,
    "name": "selling",
    "slug": "selling-2",
    "description": "",
    "parent": null,
    "count": 0,
    "link": "http:\/\/example.com\/subfolder\/listing_categy\/selling-2\/",
    "meta": {
      "links": {
        "collection": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms",
        "self": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms\/8"
      }
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

处理发布的php文件是https://github.com/WP-API/WP-API/blob/master/lib/class-wp-json-posts.php:

  /**
   * Create a new post for any registered post type.
   *
   * @since 3.4.0
   * @internal 'data' …
Run Code Online (Sandbox Code Playgroud)

rest wordpress json wordpress-plugin

4
推荐指数
2
解决办法
6653
查看次数

NG-Repeat使用过滤器与当前日期进行比较?

好吧,我有一个包含日期列表的对象,我正在遍历它:

<select ng-click="monthpicker()" >
<option class="animate-repeat" ng-repeat="returnpicker in monthpicker(alldatesdump)"      value="{{returnpicker.date}}">{{returnpicker.date  | date:'yyyy-MMM' }}</option> 
</select>
Run Code Online (Sandbox Code Playgroud)

使用ng-repeat,返回以下内容:

<select ng-click="monthpicker()">
  <!-- ngRepeat: returnpicker in monthpicker(alldatesdump) -->
  <option class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(alldatesdump)" value="2013-Nov">2013-Nov</option>
  <option class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(alldatesdump)" value="2013-Nov">2013-Nov</option>
  <option class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(alldatesdump)" value="2013-Nov">2013-Nov</option>
  <option class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(alldatesdump)" value="2013-Nov">2013-Nov</option>
  <option class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(alldatesdump)" value="2013-Nov">2013-Nov</option>
  <option class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(alldatesdump)" value="2013-Nov">2013-Nov</option>
  <option class="animate-repeat ng-scope ng-binding" ng-repeat="returnpicker in monthpicker(alldatesdump)" value="2013-Nov">2013-Nov</option>
  <option …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-ng-repeat

3
推荐指数
1
解决办法
4438
查看次数

从ng-repeat或ng-options返回对象?

好的,我有以下内容:

<select ng-model="item" ng-change="monthpickerclick()">
<option  class="animate-repeat" ng-repeat="returnpicker in monthpicker(singles)" value="{{returnpicker.date}}">{{returnpicker.date}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)

每个选项都有一个这样的对象:

returnpicker: Object
$$hashKey: "02O"
Year: 2014
dailyPrice: "165"
date: "January-2014"
minimumStay: 5
month: 0
monthlyPrice: "4000"
reserved: false
weeklyPrice: "880"
Run Code Online (Sandbox Code Playgroud)

从控制器中选择时,如何获取每个选项的对象值?目前这个:

scope.$watch('item', function(){
   console.log(scope.item);
});
Run Code Online (Sandbox Code Playgroud)

返回选项字符串值,但我需要在月份和年份获得?怎么样???

我也尝试过:

<select ng-model="item" ng-options="o.month as o.month for o in monthpicker(singles)" ng-click="monthpickerclick()">{{item}}</select>
Run Code Online (Sandbox Code Playgroud)

但是这会从选项中删除对象中的所有其他值.

angularjs

3
推荐指数
1
解决办法
6422
查看次数

从Angular JS ng-options/ng-repeat中删除重复项

我有以下内容:

$scope.jsonmarkers = [{
    "name": "Jeff",
        "type": "Organisation + Training Entity",
        "userID": "1"
}, {
    "name": "Fred",
        "type": "Organisation + Training Entity",
        "userID": "2"
}];
Run Code Online (Sandbox Code Playgroud)

这在我的HTML中:

<select id="typeselect"  multiple  ng-options="accnts.type for accnts in jsonmarkers" ng-model="accnt" ng-change="changeaccnt(accnt.type)"></select>
Run Code Online (Sandbox Code Playgroud)

我如何进行匹配类型,并且只在每次出现时回显一次ng-options

javascript angularjs

3
推荐指数
1
解决办法
1万
查看次数

AngularJS和$ document.height();?

好吧我试图设置一个画布高度使用$document.height(),只要它内部的内容不是在ng-repeat或任何指令中生成的angularJS ...我已经创建了一个plunker来基本说明我的观点在ng-repeat渲染后,画布应与文档具有相同的高度...

angular.module('ngAppDemo', [])
.controller('ngAppDemoController', function ($scope, $window, $document) {
    $scope.canvas = angular.element('#spiro')[0];
    $scope.ctx = $scope.canvas.getContext("2d");
    $scope.canvas.height = $document.height();


    $scope.friends = [
  {name:'John', age:25, gender:'boy'},
  {name:'Jessie', age:30, gender:'girl'},
  {name:'Johanna', age:28, gender:'girl'},
  {name:'Joy', age:15, gender:'girl'},
  {name:'Mary', age:28, gender:'girl'},
  {name:'Peter', age:95, gender:'boy'},
  {name:'Sebastian', age:50, gender:'boy'},
  {name:'Erika', age:27, gender:'girl'},
  {name:'Patrick', age:40, gender:'boy'},
  {name:'John', age:25, gender:'boy'},
  {name:'Jessie', age:30, gender:'girl'},
  {name:'Johanna', age:28, gender:'girl'},
  {name:'Joy', age:15, gender:'girl'},
  {name:'Mary', age:28, gender:'girl'},
  {name:'Peter', age:95, gender:'boy'},
  {name:'Sebastian', age:50, gender:'boy'},
  {name:'Erika', age:27, gender:'girl'},
  {name:'Patrick', age:40, …
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-ng-repeat

3
推荐指数
1
解决办法
5950
查看次数

按键字符串分组数组值?

好的,给定这个数据结构:

array(
         'name one' => 'fred',
         'desc one' => 'lorem ipsum'
         'name two' => 'charles',
         'desc two' => 'lorem ipsum'
);
Run Code Online (Sandbox Code Playgroud)

在PHP中我如何匹配分配给键ONE或TWO的数值并返回:

array(
           'one' => array('name' => 'fred', 'desc' => 'lorem ipsum'),
           'two' => array('name' => 'charles' , 'desc => 'lorem ipsum')
);
Run Code Online (Sandbox Code Playgroud)

php regex arrays

3
推荐指数
1
解决办法
1020
查看次数

观看ng-include活动?

谁能给我一个如何在ng-include上观察发射事件的例子?确切地说,我想在我的指令中观察$ includeContentLoaded事件......这是我的html:

<div class="page_container">
  <div ng-include="menu" class=""></div>
<section>
        <about  ng-click="loadpantone()">

        </about>
        <div class="pantone_wrapper">
            <div ng-include="template" tabindex="0" id="focus_force" ng-keydown="keypress($event.keyCode)" ng-class="PrevNext"  class="pantoneani remo pantonebg blue" ></div>
        </div>
</section>
<section class="right_side"><p>Build a Web doctor</p></section>
</div>
Run Code Online (Sandbox Code Playgroud)

指示:

'use strict';
/*global $:false */
angular.module('bawdApp')
  .directive('about', function () {
    return {
      templateUrl: 'views/pantone-inner.html',
      restrict: 'AE',
      link: function postLink($scope, element, $emit) {
                function border(valueWidth){
                  $('.page_cont_wrap').css('border', valueWidth+'px solid #aaFFFF');
                }
        $(element).css({'position': 'absolute'}).delay(200).animate({
                    'margin-left': '-160px',
                    'margin-top': '-233px',
                    'left': '50%',
                    'top': '50%'
                }, 200);
                $scope.loadpantone = …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-ng-include

2
推荐指数
1
解决办法
4802
查看次数