有人可以举例说明如何在Java中动态创建图像,在其上绘制线条等,然后绘制图像,以便未绘制的区域在绘制过程中保持透明?
我现在正在使用backbonejs mvc javascript库开发一个死的简单应用程序.只是为了表明这里的简单是html
<div class="container">
<div>
<label>
Name:
<input id="txtName" type="text" title="Type your name please" /></label>
<button id="btnSubmit" type="button" value="Submit">
Submit</button>
</div>
<div id="names">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这就是我想要的应用程序.
用户键入名称(或一些字母数字字符串)并单击提交.
验证后的值(他们称之为模型我认为)将被发送到宁静的服务.
Service将返回相同的字符串以及数据库保存操作的状态.
我现在很困惑click事件将在哪里处理(在模型中?),之后应该在何处调用render方法?(在视图中).下面你会找到我迄今为止管理的脚本
//store a global reference to model
window["model"] = Backbone.Model.extend({
defaults: { name: "Type your name"
},
validate: function () {
}
});
Run Code Online (Sandbox Code Playgroud)
//store a global reference to view
window["view"] = Backbone.View.extend({});
Run Code Online (Sandbox Code Playgroud)
在视图中没有任何说法:(
//when every thing is ready kick of the application
$(document).ready(function () { …Run Code Online (Sandbox Code Playgroud) 我正在构建一个小的Backbone.js应用程序并在其中一个模型中添加了一些自定义getter(名称getter返回一个连接的名字和姓氏):
PersonModel = Backbone.Model.extend({
get: function (attr) {
if (typeof this[attr] == 'function') {
return this[attr]();
}
return Backbone.Model.prototype.get.call(this, attr);
},
name: function() {
return firstName + " " + lastName;
}
})
Run Code Online (Sandbox Code Playgroud)
我现在可以使用它person.get("name")来检索名称,很好.但是,当我调用toJSON模型时,这些值不包括在内(我认为这是有意义的).问题是我用它来渲染我的观点:
this.template({people: this.collection.toJSON()});
Run Code Online (Sandbox Code Playgroud)
在Backbone.js中执行此操作的最佳方法是什么?使用覆盖的getter手动创建JSON?
谢谢!
我想将我的scrollview的屏幕外内容渲染为图像.
但是下面的代码只在屏幕上呈现内容,即使它应该呈现整个scrollView内容.
有人可以提供帮助吗?
提前致谢!
UIImage *image = nil;
UIGraphicsBeginImageContextWithOptions(scrollView.contentSize, false, 0.0);
{
CGPoint savedContentOffset = scrollView.contentOffset;
CGRect savedFrame = scrollView.frame;
scrollView.contentOffset = CGPointMake(0.0, 0.0);
scrollView.frame = CGRectMake(0, 0.0, scrollView.contentSize.width, scrollView.contentSize.height);
NSLog(@"%.2f",scrollView.contentSize.height);
[scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
scrollView.contentOffset = savedContentOffset;
scrollView.frame = savedFrame;
}
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud) 我很好奇你如何指定使用glDrawElements()渲染时使用的着色器.它是使用绑定的最后一个着色器吗?或者你必须使用其他命令.
总结一下:当我使用glDrawElements()时,如何指定使用哪个着色器,即将在我渲染的VBO中的三角形上使用的着色器.
我刚开始使用PyGame。在这里,我试图绘制一个矩形,但未渲染。
这是整个程序。
import pygame
from pygame.locals import *
import sys
import random
pygame.init()
pygame.display.set_caption("Rafi's Game")
clock = pygame.time.Clock()
screen = pygame.display.set_mode((700, 500))
class Entity():
def __init__(self, x, y):
self.x = x
self.y = y
class Hero(Entity):
def __init__(self):
Entity.__init__
self.x = 0
self.y = 0
def draw(self):
pygame.draw.rect(screen, (255, 0, 0), ((self.x, self.y), (50, 50)), 1)
hero = Hero()
#--------------Main Loop-----------------
while True:
hero.draw()
keysPressed = pygame.key.get_pressed()
if keysPressed[K_a]:
hero.x = hero.x - 3
if keysPressed[K_d]:
hero.x = hero.x + …Run Code Online (Sandbox Code Playgroud) 我有一个JSF表单,其中包含一些JavaScript.当特定输入更改为值> = 10时,selectOneMenu需要动态更改其选项(是或否).
我的jQuery:
if ($("input[id*='inputBox']").val() >= 10) {
$("select[id*='selectOneMenu']").val("No");
} else {
$("select[id*='selectOneMenu']").val("Yes");
}
Run Code Online (Sandbox Code Playgroud)
当我调试时,selectOneMenu中的值被正确更改,但UI组件不会更改其选项.如何告诉selectOneMenu更新其渲染值?
如果没有必要以远程形式响应如何处理它?
错误是
ActionView::MissingTemplate (Missing template carts/search_book_by_sn, application/search_book_by_sn with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee, :haml]}. Searched in:
Run Code Online (Sandbox Code Playgroud)
我的控制器中的代码.因为
如果会话[:loaded_books] .include?@ book.id
是错误结果的条件,所以我不想执行任何Javascript.保持原点与原点相同
respond_to do |format|
# format.js
if session[:loaded_books].include? @book.id
format.js
else
ap("Add into Array")
session[:loaded_books] << @book.id
ap(session[:loaded_books])
format.js { render :action => 'add_to_cart'}
end
end
Run Code Online (Sandbox Code Playgroud)
提前致谢
假设我有三角网格,那么我在三角形之间有很多重复的位置,在这种情况下索引缓冲区可能变得非常方便.
但是如果我也需要法线,那么就没有增益,因为所有三角形都有不同的法线.所以元组{position,normal}是唯一的.如果添加纹理坐标和其他功能,那么我不明白为什么需要索引缓冲区?
我需要创建一个Rectangle用颜色填充的函数.该方法看起来像这样
public void fillRect(Rectangle rect, int color)
{
int red = color;
int green = color;
int blue = color;
g.setColor(new Color(red, green, blue));
g.fillRect(rect.getX(), rect.getY(), rect.getW(), rect.getH());
}
Run Code Online (Sandbox Code Playgroud)
我想使用整数作为参数,例如200100150
,这将导致200红色的值(仅三个第一个数字).
是否可以做这个宽度java?
render ×10
backbone.js ×2
draw ×2
java ×2
opengl ×2
cgcontext ×1
directx ×1
getter ×1
image ×1
index-buffer ×1
integer ×1
ios ×1
ipad ×1
javascript ×1
jsf ×1
json ×1
model ×1
primefaces ×1
pygame ×1
python ×1
rect ×1
rectangles ×1
shader ×1
templates ×1
transparency ×1
uiscrollview ×1
view ×1