Search Results

Search found 17342 results on 694 pages for 'custom draw'.

Page 79/694 | < Previous Page | 75 76 77 78 79 80 81 82 83 84 85 86  | Next Page >

  • efficient sort with custom comparison, but no callback function

    - by rob
    I have a need for an efficient sort that doesn't have a callback, but is as customizable as using qsort(). What I want is for it to work like an iterator, where it continuously calls into the sort API in a loop until it is done, doing the comparison in the loop rather than off in a callback function. This way the custom comparison is local to the calling function (and therefore has access to local variables, is potentially more efficient, etc). I have implemented this for an inefficient selection sort, but need it to be efficient, so prefer a quick sort derivative. Has anyone done anything like this? I tried to do it for quick sort, but trying to turn the algorithm inside out hurt my brain too much. Below is how it might look in use. // the array of data we are sorting MyData array[5000], *firstP, *secondP; // (assume data is filled in) Sorter sorter; // initialize sorter int result = sortInit (&sorter, array, 5000, (void **)&firstP, (void **)&secondP, sizeof(MyData)); // loop until complete while (sortIteration (&sorter, result) == 0) { // here's where we do the custom comparison...here we // just sort by member "value" but we could do anything result = firstP->value - secondP->value; }

    Read the article

  • Magento help with creating model in custom class

    - by dardub
    I'm trying to add some custom filter methods to my magento module. I though it would be simple but I can't figure out why it's not working. My model which extends the catalog/product class contains this: public function filterProdType($prod_id) { $this->addAttributeToFilter('attribute_set_id', $prod_id); } Then in my template I have this: $collection = Mage::getModel('configurator/product')->getCollection()->addAttributeToSelect('*'); $collection->filterProdType(50)->addAttributeToFilter('type_id', 'bundle'); foreach ($collection as $item){ echo $item->getName() . ', '; } Just to try things out. But I don't get any results, no error, and it doesn't finish rendering the page (missing footer). When I do this instead, it works: $collection = Mage::getModel('configurator/product')->getCollection()->addAttributeToSelect('*'); $collection->addAttributeToFilter('attribute_set_id', 50)->addAttributeToFilter('type_id', 'bundle'); foreach ($collection as $item){ echo $item->getName() . ', '; } I'm just wondering what I'm missing. UPDATE: I didn't realize error reporting was turned off, after turning it on I get the error: Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection::filterProdType() I assumed after instantiating $collection using my custom model, it would find my new method.

    Read the article

  • Adding custom UITableViewCell crashes the simulator.

    - by nevva
    Im trying to build my application using a custom UITableViewCell. This is the code in my UIViewController that adds the viewCell to the table: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"------- Tableview --------"); static NSString *MyIdentifier = @"MyIdentifier"; MyIdentifier = @"aCellIdentifier"; MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if(cell == nil) { NSArray *[[NSBundle mainBundle] loadNibNamed:@"tblCellView" owner:self options:nil]; cell = tblCell; } [cell setLabelText:[NSString stringWithFormat:@"indexpath.row: %d", indexPath.row]]; //cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MyIdentifier] autorelease]; return cell; } if i uncomment the line above "return cell" it returns a regular UITableViewCell without any errors, but as soon as i try to implement my custom cell it crashes with this error: ------- Tableview -------- 2010-04-23 11:17:33.163 SogetGolf[26935:40b] * Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-984.38/UITableView.m:4709 2010-04-23 11:17:33.164 SogetGolf[26935:40b] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' 2010-04-23 11:17:33.165 SogetGolf[26935:40b] Stack: ( ... I have configured the .xib file as one should with the proper outlets. And the identifier of the UITableViewCell corresponds with name im trying to load from NSBundle

    Read the article

  • Detecting when a cell's detail-disclosure button has been clicked (when using a custom cell XIB)

    - by Gloria
    1 if (cell == nil) 2 { 3 [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil]; 4 cell = tvCell; 5 self.tvCell = nil; 6 } There's some code from an Apple example of using your own "custom cell XIB" to create cells in a UITableView. It appears to work... but I think I would do better to actually UNDERSTAND what is being done there. Why isn't line #3 assigning the value TO something? cell = [[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil]; (In fact, cell and tvCell aren't being used at all.) Why is line #4 assigning using tvCell when nothing has been put it in at all, yet? Why is line #5 nulling out the tvCell that I need? Why is "@property (nonatomic, assign) IBOutlet UITableViewCell *tvCell;" using assign, not retain? About the only thing I can't get working correctly is when I put a disclosure-button on my custom cell XIB. Is there a way for me to detect when the user has clicked on it? (Hopefully, without using 100s of TAGs.)

    Read the article

  • Applying a function to a custom type in F#

    - by Frederik Wordenskjold
    On my journey to learning F#, I've run into a problem I cant solve. I have defined a custom type: type BinTree = | Node of int * BinTree * BinTree | Empty I have made a function which takes a tree, traverses it, and adds the elements it visits to a list, and returns it: let rec inOrder tree = seq{ match tree with | Node (data, left, right) -> yield! inOrder left yield data; yield! inOrder right | Empty -> () } |> Seq.to_list; Now I want to create a function, similar to this, which takes a tree and a function, traverses it and applies a function to each node, then returns the tree: mapInOrder : ('a -> 'b) -> 'a BinTree -> 'b BinTree This seems easy, and it probably is! But I'm not sure how to return the tree. I've tried this: let rec mapInOrder f tree = match tree with | Node(data, left, right) -> mapInOrder f left Node(f(data), left, right) mapInOrder f right | Empty -> () but this returns a unit. I havent worked with custom types before, so I'm probably missing something there!

    Read the article

  • vaadin custom layout setting a text area in a table with the location attribute

    - by user3717298
    I need to set a text area in the html template and use it as a custom component in vaadin the html snippet is as below <table> <tr> <td> JUNK SENTENCE </td> <td> <div location="HEADIN"></div> <div location="Details"></div> <div location="Attachment"></div> </td> <td> <p>School of more than 50 students univer versities.</p> </td> </tr> </table> All the place holders are working and displays data but the "details" holder should be a text area. as the text is a lot over there so I tried the below way but it just turned the place holder to text vaadin could not manipulate / identify the "Details" place holder. I tried the below way i set - in side the text area tag. <textarea rows="4" cols="50"> </textarea> and again i tried this way too which also did not work. <textarea rows="4" cols="50" location="Details"> </textarea> Any guidance would be appreciated to solve this I am setting the needed values from a formfeildfactory and these values are set by implementing the Vaadin Custom field class(in case it helps some more to identify)

    Read the article

  • Client-side user custom CSS single file for overriding multiple domains

    - by Cawas
    This is for using in Safari, though it could probably be used on Firefox as well. In Chrome you have to add a plugin anyway (which generally allow for custom CSS per domain), and Opera already allows this to be done without needing any CSS. But while it's for customizing on the client-side, it's also a pure CSS question. So I'm using no plugins here. So, again, I got a custom CSS code (easily) working for all domains. Now I want to get specify CSS code for each domain. All with just 1 CSS file that's being loaded by Safari. Over the web and googling, I've found two ways to supposedly do this, but none actually worked. They're both documented on userstyles.com: @-moz-document domain("your-domain.com") { }. This would be perfect, since I can have several tags like that and just choose which style will be loaded for which domain. It just doesn't work. @namespace is quite confusing and I've tried every variation I could think of. None worked.

    Read the article

  • Highlighting a custom UIButton

    - by Dan Ray
    The app I'm building has LOTS of custom UIButtons laying over top of fairly precisely laid out images. Buttonish, controllish images and labels and what have you, but with a clear custom-style UIButton sitting over top of it to handle the tap. My client yesterday says, "I want that to highlight when you tap it". Never mind that it immediately pushes on a new uinavigationcontroller view... it didn't blink, and so he's confused. Oy. Here's what I've done to address it. I don't like it, but it's what I've done: I subclassed UIButton (naming it FlashingUIButton). For some reason I couldn't just configure it with a background image on control mode highlighted. It never seemed to hit the state "highlighted". Don't know why that is. So instead I wrote: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self setBackgroundImage:[UIImage imageNamed:@"grey_screen"] forState:UIControlStateNormal]; [self performSelector:@selector(resetImage) withObject:nil afterDelay:0.2]; [super touchesBegan:touches withEvent:event]; } -(void)resetImage { [self setBackgroundImage:nil forState:UIControlStateNormal]; } This happily lays my grey_screen.png (a 30% opaque black box) over the button when it's tapped and replaces it with happy emptyness .2 of a second later. This is fine, but it means I have to go through all my many nibs and change all my buttons from UIButtons to FlashingUIButtons. Which isn't the end of the world, but I'd really hoped to address this as a UIButton category, and hit all birds with one stone. Any suggestions for a better approach than this one?

    Read the article

  • Live clock javascript starts from my custom time

    - by newworroo
    I was trying to create a live/dynamic clock is based on my custom time instead of system time. There are many scripts, but I couldn't find the clock starts from my custom time. Here is an example that I'm trying to modify. The problem is the seconds doesn't change, and it looks like I need to use ajax. Is there any way to do it without ajax? If not, help me to do it using ajax!!! The reason I don't like ajax method is that another page should be called and refreshed, so it will eat server ram. ex) http://www.javascriptkit.com/script/cut2.shtml Before: <script> function show(){ var Digital=new Date() var hours=Digital.getHours() var minutes=Digital.getMinutes() var seconds=Digital.getSeconds() ... ... After: <script> function show(){ var Digital=new Date() var hours=<?php echo $hr; ?>; var minutes=<?php echo $min; ?>; var seconds=<?php echo $sec; ?>; ... ...

    Read the article

  • jQuery trigger custom event synchronously?

    - by Miguel Angelo
    I am using the jQuery trigger method to call an event... but it behaves inconsistently. Sometimes it call the event, sometimes it does not. <a href="#" onclick=" $(this).trigger('custom-event'); window.location.href = 'url'; return false; ">text</a> The custom-event has lots of listeners added to it. It is as if the trigger method is not synchronous, allowing the window.location.href be changed before executing the events. And when window.location.href is changed a navigation occurs, interrupting everything. How can I trigger events synchronously? Using jQuery 1.8.1. Thanks! EDIT I have found that the event, when called has a stack trace like this: jQuery.fx.tick (jquery-1.8.1.js:9021) tick (jquery-1.8.1.js:8499) jQuery.Callbacks.self.fireWith (jquery-1.8.1.js:1082) jQuery.Callbacks.fire (jquery-1.8.1.js:974) jQuery.speed.opt.complete (jquery-1.8.1.js:8991) $.customEvent (myfile.js:28) This proves that jQuery trigger method is asynchronous. Oohhh my... =\

    Read the article

  • how to make custom ROMs for lesser-known Android devices (i.e., WellcoM A69)

    - by gonzobrains
    Hi, I have a WellcoM A69 Android phone I would like to start hacking. I bought it in Thailand (I think WellcoM is a Thai company). However, the docs don't explain how to get a recovery menu or anything like that. I would like to figure out how to make custom ROMs for it, because it doesn't have any Google Experience apps and I also want to change the boot screen. How can I go about doing this? If I can't do this, I want to at least be able to use the device in the Eclipse debugger. I select the debugging option under applications but the device still isn't recognized. Is this something that can be disabled by the manufacturer? In any case, I would like to re-enable it if a custom ROM can allow this. If this cannot be done at all, please at least point me in the direction of where I can start writing/building my own ROMs for the G1? I figured that would be a good starting point for learning. Thanks, Jeff

    Read the article

  • how to set custom tab in jquery ui and use with rails

    - by Katyal
    I'm using jqueryUI for tabs on a page. I initialize it like below: $("#tabs").tabs(); <div id="tabs"> <ul> <li><a href="#tabs-4">Part A</a></li> <li><a href="#tabs-2">Part B</a></li> <li><a href="#tabs-5">Part C</a></li> </ul> <div id="tabs-4"> ..... </div> <div id="tabs-2"> .... </div> <div id="tabs-5"> .... </div> </div> I have 2 questions. How do I set the tab to be custom. say I want second tab to be shown first. $('#tabs').tabs(2) does not work. i got that from this link Let say I click on a button inside tab1. Clicking on the button takes control back to an action and then control comes back to this page. When the control comes back...then is it possible to set a custom tab?. For example. in tab 1 I click something...go back to the action...and then I want to come back to tab 2.

    Read the article

  • Building a custom textbox in GTK

    - by CommuSoft
    I want to make my own GTK# Textbox, the textbox should draw the text and it's cursor on a special way. However keyboard and mouse-handling is quite complex and is also influenced by for instance the operating system (for instance the use of dead keys) Is there a way to build such a control without having to worry about keyboard input? I assume I have to make a textbox control that inherits the original textbox control. How can I handle drawing requests and mouse movements?

    Read the article

  • How do I draw an OpenGL point sprite using libgdx for Android?

    - by nbolton
    Here's a few snippets of what I have so far... void create() { renderer = new ImmediateModeRenderer(); tiles = Gdx.graphics.newTexture( Gdx.files.getFileHandle("res/tiles2.png", FileType.Internal), TextureFilter.MipMap, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); } void render() { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); Gdx.gl.glClearColor(0.6f, 0.7f, 0.9f, 1); } void renderSprite() { int handle = tiles.getTextureObjectHandle(); Gdx.gl.glBindTexture(GL.GL_TEXTURE_2D, handle); Gdx.gl.glEnable(GL.GL_POINT_SPRITE); Gdx.gl11.glTexEnvi(GL.GL_POINT_SPRITE, GL.GL_COORD_REPLACE, GL.GL_TRUE); renderer.begin(GL.GL_POINTS); renderer.vertex(pos.x, pos.y, pos.z); renderer.end(); } create() is called once when the program starts, and renderSprites() is called for each sprite (so, pos is unique to each sprite) where the sprites are arranged in a sort-of 3D cube. Unfortunately though, this just renders a few white dots... I suppose that the texture isn't being bound which is why I'm getting white dots. Also, when I draw my sprites on anything other than 0 z-axis, they do not appear -- I read that I need to crease my zfar and znear, but I have no idea how to do this using libgdx (perhaps it's because I'm using ortho projection? What do I use instead?). I know that the texture is usable, since I was able to render it using a SpriteBatch, but I guess I'm not using it properly with OpenGL.

    Read the article

  • GDI RoundRect on Compact Framework: make rounded rectangle's outside transparent.

    - by VansFannel
    Hello! I'm using the RoundRect GDI function to draw a rounded rectangle following this example: .NET CF Custom Control: RoundedGroupBox Because all controls are square, it also draw the corners outside of the rounded rectangle. How can I make this space left outside the rectangle transparent? The OnPaint method is: protected override void OnPaint(PaintEventArgs e) { int outerBrushColor = HelperMethods.ColorToWin32(m_outerColor); int innerBrushColor = HelperMethods.ColorToWin32(this.BackColor); IntPtr hdc = e.Graphics.GetHdc(); try { IntPtr hbrOuter = NativeMethods.CreateSolidBrush(outerBrushColor); IntPtr hOldBrush = NativeMethods.SelectObject(hdc, hbrOuter); NativeMethods.RoundRect(hdc, 0, 0, this.Width, this.Height, m_diametro, m_diametro); IntPtr hbrInner = NativeMethods.CreateSolidBrush(innerBrushColor); NativeMethods.SelectObject(hdc, hbrInner); NativeMethods.RoundRect(hdc, 0, 18, this.Width, this.Height, m_diametro, m_diametro); NativeMethods.SelectObject(hdc, hOldBrush); NativeMethods.DeleteObject(hbrOuter); NativeMethods.DeleteObject(hbrInner); } finally { e.Graphics.ReleaseHdc(hdc); } if (!string.IsNullOrEmpty(m_roundedGroupBoxText)) { Font titleFont = new Font("Tahoma", 9.0F, FontStyle.Bold); Brush titleBrush = new SolidBrush(this.BackColor); try { e.Graphics.DrawString(m_roundedGroupBoxText, titleFont, titleBrush, 14.0F, 2.0F); } finally { titleFont.Dispose(); titleBrush.Dispose(); } } base.OnPaint(e); } An the OnPaintBackground is: protected override void OnPaintBackground(PaintEventArgs e) { if (this.Parent != null) { SolidBrush backBrush = new SolidBrush(this.Parent.BackColor); try { e.Graphics.FillRectangle(backBrush, 0, 0, this.Width, this.Height); } finally { backBrush.Dispose(); } } } Thank you!

    Read the article

  • How can I reduce draw calls when using glBufferSubData and DYNAMIC_DRAW?

    - by Kronos
    At first I had the problem where I had about 150 rectangles rendered every tick. I only used STATIC_DRAW and glBufferData. I added support for DYNAMIC_DRAW and glBufferSubData and now I have a very good result... but the number of draw calls (glDrawArrays) is the same. Best practices from Mozilla Dev website said it should be reduced, but how? Every rectangle has a method render() in which I do following (shortend): _gl.bindBuffer(WebGL.ARRAY_BUFFER, vertexBuffer); _gl.enableVertexAttribArray(a_position); _gl.vertexAttribPointer(a_position, 2, WebGL.FLOAT, false, 0, 0); _gl.bufferSubData(WebGL.ARRAY_BUFFER, 0, vertices); _gl.bindBuffer(WebGL.ARRAY_BUFFER, texCoordBuffer); _gl.enableVertexAttribArray(a_texCoordLocation); _gl.vertexAttribPointer(a_texCoordLocation, 2, WebGL.FLOAT, false, 0, 0); _gl.bufferSubData(WebGL.ARRAY_BUFFER, 0, texVertices); _gl.uniform2fv(_utranslation, _translation); _gl.uniform2fv(_urotation, _rotation); _gl.uniform2f(_location, Dart2D.WIDTH, Dart2D.HEIGHT); _gl.drawArrays(WebGL.TRIANGLES, 0, 6); So every rectangle calls drawArrays in every frame...

    Read the article

  • JSF 2.0: java based custom component + html table + facelets = data model not updated

    - by mikic
    Hi, I'm having problems getting the data model of a HtmlDataTable to be correctly updated by JSF 2.0 and Facelets. I have created a custom Java-based component that extends HtmlDataTable and dynamically adds columns in the encodeBegin method. @Override public void encodeBegin(FacesContext context) throws IOException { if (this.findComponent("c0") == null) { for (int i = 0; i < 3; i++) { HtmlColumn myNewCol = new HtmlColumn(); myNewCol.setId("c" + i); HtmlInputText myNewText = new HtmlInputText(); myNewText.setId("t" + i); myNewText.setValue("#{row[" + i + "]}"); myNewCol.getChildren().add(myNewText); this.getChildren().add(myNewCol); } } super.encodeBegin(context); } My test page contains the following <h:form id="fromtb"> <test:MatrixTest id="tb" var="row" value="#{MyManagedBean.model}"> </test:MatrixTest> <h:commandButton id="btn" value="Set" action="#{MyManagedBean.mergeInput}"/> </h:form> <h:outputText id="mergedInput" value="#{MyManagedBean.mergedInput}"/> My managed bean class contains the following @ManagedBean(name="MyManagedBean") @SessionScoped public class MyManagedBean { private List model = null; private String mergedInput = null; public MyManagedBean() { model = new ArrayList(); List myFirst = new ArrayList(); myFirst.add(""); myFirst.add(""); myFirst.add(""); model.add(myFirst); List mySecond = new ArrayList(); mySecond.add(""); mySecond.add(""); mySecond.add(""); model.add(mySecond); } public String mergeInput() { StringBuffer myMergedInput = new StringBuffer(); for (Object object : model) { myMergedInput.append(object); } setMergedInput(myMergedInput.toString()); return null; } public List getModel() { return model; } public void setModel(List model) { this.model = model; } public String getMergedInput() { return mergedInput; } public void setMergedInput(String mergedInput) { this.mergedInput = mergedInput; } When invoked, the page is correctly rendered with a table made of 3 columns (added at runtime) and 2 rows (as my data model has 2 rows). However when the user enter some data in the input fields and then click the submit button, the model is not correctly updated and therefore the mergeInput() method creates a sequence of empty strings which is rendered on the same page. I have added some logging to the decode() method of my custom component and I can see that the parameters entered by the user are being posted back with the request, however these parameters are not used to update the data model. If I update the encodeBegin() method of my custom component as follow @Override public void encodeBegin(FacesContext context) throws IOException { super.encodeBegin(context); } and I update the test page as follow <test:MatrixTest id="tb" var="row" value="#{MyManagedBean.model}"> <h:column id="c0"><h:inputText id="t0" value="#{row[0]}"/></h:column> <h:column id="c1"><h:inputText id="t1" value="#{row[1]}"/></h:column> <h:column id="c2"><h:inputText id="t2" value="#{row[2]}"/></h:column> </test:MatrixTest> the page is correctly rendered and this time when the user enters data and submits the form, the underlying data model is correctly updated and the mergeInput() method creates a sequence of strings with the user data. Why does the test case with columns declared in the facelet page works correctly (ie the data model is correctly updated by JSF) where the same does not happen when the columns are created at runtime using the encodeBegin() method? Is there any method I need to invoke or interface I need to extend in order to ensure the data model is correctly updated? I am using this test case to address the issue that is appearing in a much more complex component, therefore I can't achieve the same functionality using a facelet composite component. Please note that this has been done using NetBeans 6.8, JRE 1.6.0u18, GlassFish 3.0. Thanks for your help.

    Read the article

  • Scripting custom drawing in Delphi application with IF/THEN/ELSE statements?

    - by Jerry Dodge
    I'm building a Delphi application which displays a blueprint of a building, including doors, windows, wiring, lighting, outlets, switches, etc. I have implemented a very lightweight script of my own to call drawing commands to the canvas, which is loaded from a database. For example, one command is ELP 1110,1110,1290,1290,3,8388608 which draws an ellipse, parameters are 1110x1110 to 1290x1290 with pen width of 3 and the color 8388608 converted from an integer to a TColor. What I'm now doing is implementing objects with common drawing routines, and I'd like to use my scripting engine, but this calls for IF/THEN/ELSE statements and such. For example, when I'm drawing a light, if the light is turned on, I'd like to draw it yellow, but if it's off, I'd like to draw it gray. My current scripting engine has no recognition of such statements. It just accepts simple drawing commands which correspond with TCanvas methods. Here's the procedure I've developed (incomplete) for executing a drawing command on a canvas: function DrawCommand(const Cmd: String; var Canvas: TCanvas): Boolean; type TSingleArray = array of Single; var Br: TBrush; Pn: TPen; X: Integer; P: Integer; L: String; Inst: String; T: String; Nums: TSingleArray; begin Result:= False; Br:= Canvas.Brush; Pn:= Canvas.Pen; if Assigned(Canvas) then begin if Length(Cmd) > 5 then begin L:= UpperCase(Cmd); if Pos(' ', L)> 0 then begin Inst:= Copy(L, 1, Pos(' ', L) - 1); Delete(L, 1, Pos(' ', L)); L:= L + ','; SetLength(Nums, 0); X:= 0; while Pos(',', L) > 0 do begin P:= Pos(',', L); T:= Copy(L, 1, P - 1); Delete(L, 1, P); SetLength(Nums, X + 1); Nums[X]:= StrToFloatDef(T, 0); Inc(X); end; Br.Style:= bsClear; Pn.Style:= psSolid; Pn.Color:= clBlack; if Inst = 'LIN' then begin Pn.Width:= Trunc(Nums[4]); if Length(Nums) > 5 then begin Br.Style:= bsSolid; Br.Color:= Trunc(Nums[5]); end; Canvas.MoveTo(Trunc(Nums[0]), Trunc(Nums[1])); Canvas.LineTo(Trunc(Nums[2]), Trunc(Nums[3])); Result:= True; end else if Inst = 'ELP' then begin Pn.Width:= Trunc(Nums[4]); if Length(Nums) > 5 then begin Br.Style:= bsSolid; Br.Color:= Trunc(Nums[5]); end; Canvas.Ellipse(Trunc(Nums[0]),Trunc(Nums[1]),Trunc(Nums[2]),Trunc(Nums[3])); Result:= True; end else if Inst = 'ARC' then begin Pn.Width:= Trunc(Nums[8]); Canvas.Arc(Trunc(Nums[0]),Trunc(Nums[1]),Trunc(Nums[2]),Trunc(Nums[3]), Trunc(Nums[4]),Trunc(Nums[5]),Trunc(Nums[6]),Trunc(Nums[7])); Result:= True; end else if Inst = 'TXT' then begin Canvas.Font.Size:= Trunc(Nums[2]); Br.Style:= bsClear; Pn.Style:= psSolid; T:= Cmd; Delete(T, 1, Pos(' ', T)); Delete(T, 1, Pos(',', T)); Delete(T, 1, Pos(',', T)); Delete(T, 1, Pos(',', T)); Canvas.TextOut(Trunc(Nums[0]), Trunc(Nums[1]), T); Result:= True; end; end else begin //No space found, not a valid command end; end; end; end; What I'd like to know is what's a good lightweight third-party scripting engine I could use to accomplish this? I would hate to implement parsing of IF, THEN, ELSE, END, IFELSE, IFEND, and all those necessary commands. I need simply the ability to tell the scripting engine if certain properties meet certain conditions, it needs to draw the object a certain way. The light example above is only one scenario, but the same solution needs to also be applicable to other scenarios, such as a door being open or closed, locked or unlocked, and draw it a different way accordingly. This needs to be implemented in the object script drawing level. I can't hard-code any of these scripting/drawing rules, the drawing needs to be controlled based on the current state of the object, and I may also wish to draw a light a certain shade or darkness depending on how dimmed the light is.

    Read the article

  • How do I draw a point sprite using OpenGL ES on Android?

    - by nbolton
    Edit: I'm using the GL enum, which is incorrect since it's not part of OpenGL ES (see my answer). I should have used GL10, GL11 or GL20 instead. Here's a few snippets of what I have so far... void create() { renderer = new ImmediateModeRenderer(); tiles = Gdx.graphics.newTexture( Gdx.files.getFileHandle("res/tiles2.png", FileType.Internal), TextureFilter.MipMap, TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); } void render() { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); Gdx.gl.glClearColor(0.6f, 0.7f, 0.9f, 1); } void renderSprite() { int handle = tiles.getTextureObjectHandle(); Gdx.gl.glBindTexture(GL.GL_TEXTURE_2D, handle); Gdx.gl.glEnable(GL.GL_POINT_SPRITE); Gdx.gl11.glTexEnvi(GL.GL_POINT_SPRITE, GL.GL_COORD_REPLACE, GL.GL_TRUE); renderer.begin(GL.GL_POINTS); renderer.vertex(pos.x, pos.y, pos.z); renderer.end(); } create() is called once when the program starts, and renderSprites() is called for each sprite (so, pos is unique to each sprite) where the sprites are arranged in a sort-of 3D cube. Unfortunately though, this just renders a few white dots... I suppose that the texture isn't being bound which is why I'm getting white dots. Also, when I draw my sprites on anything other than 0 z-axis, they do not appear -- I read that I need to crease my zfar and znear, but I have no idea how to do this using libgdx (perhaps it's because I'm using ortho projection? What do I use instead?). I know that the texture is usable, since I was able to render it using a SpriteBatch, but I guess I'm not using it properly with OpenGL.

    Read the article

  • Possible to draw a select portion of a render target? (in XNA)

    - by TheBroodian
    I'm going to try to do this in reverse fashion and skip straight to the punch line, and then give the back story afterward: Is it possible to, after drawing a scene to a RenderTarget2D, only draw a select portion of the RenderTarget2D, if I don't want the entire thing? I'm using xTile to manage world data in my game (it's a great piece of work, colinvella [xTile's author] has made an amazing product), and for the most part it works great. xTile supports parallax effects in its layers to add some wonderful depth to 2d scenes, which was great, until I implemented a dynamic split-screen system into my game. Wanted to make a co-op game that wouldn't require players to be in close proximity to each other, so I made it so that if the players separate too far apart, the singular full-screen viewport 'snaps-apart', and is replaced by two split-screen viewports, which then smoothly transition to their respective player targets. The effect is pretty smooth aside from the part where the parallax backgrounds become skewed once the viewports split, because xTile's ratio for handling parallax effects is dependent upon viewport size. This is unfortunate, because the effect would otherwise be really snazzy, but the backgrounds become pretty heavily affected when the game goes from single-viewport to multi-viewport. So, Colinvella suggests using rendertargets to record the scene at full viewport size, and then only drawing a portion of it. But as far as I can tell, that isn't even possible? That being said, I've never even used render targets before, so I'm still learning, hence the question here.

    Read the article

  • How do I draw a 2d plane and rotate camara (To be a board) in a 3d XNA game?

    - by Mech0z
    I am trying to create a simple board game, but the 3d part of this is really killing me. From what I can gather I have created a plane, but it never moves even though I turn the camara, but that partially makes sense as I only turn the camara with a 3d model, but in my head that makes 0 sense, in my head if I turn the camara it should affect ALL my models? But with this code the camara only "cares" about the 3d cylinder, the plane is just completely still private void OnDraw(object sender, GameTimerEventArgs e) { SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue); foreach (ModelMesh mesh in cylinderModel.Meshes) { foreach (BasicEffect effect in mesh.Effects) { //effect.World = Matrix.CreateRotationX((float)e.TotalTime.TotalSeconds * 2); effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up); effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000.0f); effect.EnableDefaultLighting(); } mesh.Draw(); } //cameraPosition.Z -= 5.0f; _effect.World = Matrix.CreateRotationZ((MathHelper.ToRadians(((float)e.TotalTime.Milliseconds / 2) % 360))); foreach (EffectPass pass in _effect.CurrentTechnique.Passes) { pass.Apply(); SharedGraphicsDeviceManager.Current.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, _vertices, 0, 1, VertexPositionColor.VertexDeclaration); } } Is there a way to get the camara to affect all models?

    Read the article

  • how to set custom interval to horizontal axis in Flex Charts

    - by Ali Syed
    Hello folks, I am trying to set custom step (interval) to my Line Chart's horizontal axis. The chart gets its data from a grid. The grid has a lot of data and it is displayed accurately but because there are so many data points the horizontal axis is screwed up. I wanted to set a step on horizontal axis so that you get an idea when you see the graph without hovering the mouse on a data point! thanks for any help! -Ali Flexi Comment Box

    Read the article

< Previous Page | 75 76 77 78 79 80 81 82 83 84 85 86  | Next Page >