Posts

java me - Clearing the canvas with J2ME -

i'm trying create program shows 2 images @ random locations , changes them every second. problem when image redrawn can still see image in previous position. i'm using wtk 2.52 if that's relevant. public void run() { while(true) { dvert = rand.nextint(136); dhorz = rand.nextint(120); rvert = 136 + rand.nextint(136); rhorz = 120 + rand.nextint(120); try { thread.sleep(1000); } catch (interruptedexception e) { system.out.println("error"); } repaint(); } } public void paint(graphics g) { int width = this.getwidth() / 2; int height = this.getheight() / 2; g.drawimage(imgr, rvert, rhorz, g.top | g.left); g.drawimage(imgd,dvert,dhorz,g.top | g.left); //g.drawstring(disp, width, 50, graphics.top | graphics.hcenter); //g.drawstring(centermsg,width, height, graphics.top | graphics.hcenter); system.out.println(wi...

Swift L-System Algae -

so i'm doing fun in ibm swift sandbox. did l-system algae in scala , though cool in swift see how language compares. https://github.com/i2obin/l-system-algorithms-and-fractals/blob/master/algae.scala that's scala 1 show i'm aiming for, , have in swift; /** * created t.hood on 26/01/16 * l-system algae * */ import foundation // mapping function string func stringmap(x: string) -> string { var str = x; // replace characters in string str = x.stringbyreplacingoccurrencesofstring("a", withstring: "ab") + str.stringbyreplacingoccurrencesofstring("b", withstring: "a"); // return mapped string; return str; } func lsys() { // declarations var iteration : int = 2; var x = 0; var lsystem: string = "a"; let chara: character = "a"; let charb: character = "b"; while(x != iteration) { print(lsystem) // iterate through characters in string chars in lsy...

jquery - Bouncing divs in their own place? -

i'm trying create simple bouncing effect divs. bouncing effect works in way don't why divs go under each-other when bounce not want. need divs bounce in own place. this fiddle and code: $(document).ready(function() { $(".balls").effect('bounce', { times: 3 }, 'slow'); }); the bouncing effect kicks in on page load. appreciated. the issue because library adding containing div element around each .balls element default display: block , hence each element pushed it's own line. when animation ends element removed , return sitting on same line. fix need add rule css: .ui-effects-wrapper { display: inline-block; } updated fiddle

javascript - Three.js - Questions about (the use of) THREE.BufferGeometry -

Image
as understood using buffer geometries increase performance , decrease memory usage because it reduces cost of passing data gpu . and understood from @westlangley post here: three.buffergeometry replacing three.geometry computationally more efficient. i using three.js - r72 . when draw geometries make meshes , add them scene see there 2 properties inside geomtries __directgeometry , _buffergeometry . here in three.boxgeometry : here in three.geometry : here in three.shapegeometry : my questions: what three.directgeometry , do? (i cannot seem find documentation on this) is three.buffergeometry stored in _buffergeometry automatically used? if not, can use instead of geometry boost performance? there conversion methods: three.buffergeometry has togeometry , three.geometry has tobuffergeometry . if convert normal geometries buffer geometries using method, give me same performance increase compared drawing them three.buffergeometry start? how , ...

Awk error message targeting a parentheses -

i'm running awk command cant find why keeps on telling me wrong, variables instantiated (i have replaced them string here show error, error same), braces closed, advice? key=$(echo "hello,there" | awk -f"," -v index=2 '{for(i=1; i<=nf; i++) if ($i ~ $index) print i}') i'm not perfect awk user, cant spot issue here advice? index built-in function (keyword) cannot use variable name. change to: awk -f"," -v idx=2 '{for(i=1; i<=nf; i++) if ($i ~ idx) print i}') the field specifier, $ , prefixing idx not correct, want use string is.

c++ - Compile error when using std::cout between if/elseif statements -

i wondering why compile error when try use std::cout in between, say, if statement , else if statement. example: if (condition) {body} std::cout << "hello world" << std::endl; else if (condition) {body} gives error error: 'else' without previous 'if' let me right first: want execute cout statement in between conditional no matter whether condition met or not, i.e. no matter whether body of if got executed or not. as previous commenters noted, cannot place between end of scope of if-block , else keyword. what approaching splitting if-else-if block 2 separate if-blocks: if (condition1) { body1 } cout << "hello world" << endl; if (!condition1 && condition2) { body2 }

angularjs - How to use ng-include from code? -

i want use ng-include directive code. var html = '<div ng-include="\'mytemplate.html\'"></div>'; $compile(html)($scope); angular.element(document.getelementbyid('mydiv')).append(html); but, 1 not working expected. can explain how achieve properly? if want include html webpage, should use ng-bing-html instead : html <div id="mydiv" ng-bind-html="template"></div> js .controller('name', function($scope, $http, $sce, ...) { $http.get('mytemplate.html').success(function(template) { $scope.template = $sce.trustashtml(template); }); });