Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #33013

Re: Javascripts and highlevel computer language programming of graphics

Newsgroups comp.lang.javascript
Date 2017-04-15 15:04 -0700
References <9fcf7c9e-a38d-4b45-bcfb-347c5d15d930@googlegroups.com> <mtr3fchnoeko3qn95hq9iup9ljcjmksb16@4ax.com> <03b9843f-a669-4e7b-b18d-bd2bd7240e16@googlegroups.com> <013aedad-faa3-4207-92bf-6c18ef764969@googlegroups.com> <0c29f9a4-2747-4e81-9847-516875a893a8@googlegroups.com>
Message-ID <55b2edf6-31de-43fa-bb07-ec0da6835f7d@googlegroups.com> (permalink)
Subject Re: Javascripts and highlevel computer language programming of graphics
From jonas.thornvall@gmail.com

Show all headers | View raw


Den lördag 15 april 2017 kl. 23:52:49 UTC+2 skrev jonas.t...@gmail.com:
> Den lördag 15 april 2017 kl. 21:04:37 UTC+2 skrev jonas.t...@gmail.com:
> > Den lördag 15 april 2017 kl. 20:52:19 UTC+2 skrev jonas.t...@gmail.com:
> > > Den lördag 15 april 2017 kl. 12:07:38 UTC+2 skrev John G Harris:
> > > > On Fri, 14 Apr 2017 11:49:16 -0700 (PDT), jonas.thornvall@gmail.com
> > > > wrote:
> > > > 
> > > > >High level computer programming of graphics seem to suffer from the fact that you can not tell what should be executed in the actual rendering algorithm.
> > > > >
> > > > >It is so wrong to have to check what should be written out within the actual render algorithm again and again.
> > > > >
> > > > >Why can't you send what algorithms to render to the pain function?
> > > > >
> > > > >Example, instead of checking what to render in the render algo again and agin why not use the individual function names to render as paramters to the render function.
> > > > >
> > > > >As far as i understand today you must check what to render within the render with in redraw where you render to canvas, and this happen as often you draw to the canvas.
> > > > >
> > > > >WHY can't one tell the redraw what functions/procedures to reder before it start?
> > > > >
> > > > >Is there a way to tell the rendering "redraw" from outside what functions that should be executed, i really would like an example. Right now i use booleans within the rendering "redraw" to tell what code should be executed and not. 
> > > > >
> > > > >But it seem fucking weird to me, so possibly i have not understood the principle, because these are checked every time when you redraw and that must be a waste of cpu cycles. So is there a way to avoid this in highlevel programming languages?
> > > > >My idea would be to tell the rendering what functions should be executed, so they become a parameter to the rendering, but maybe i totally missunderstood rendering?
> > > > 
> > > > This is where Object Oriented design can be so useful. You have an
> > > > object with a Draw method. Draw draws the entire picture. It does this
> > > > by using a sequence of objects with Draw methods. In each of these
> > > > objects Draw draws part of the picture by using a sequence of objects
> > > > with Draw methods, etc. Eventually you reach objects whose Draw method
> > > > draw a line, circle, rectangle, etc, using values remembered by the
> > > > objects.
> > > 
> > > You seem to say the objects know themself if they should be drawn or not?
> > > I mean the method itself just draw objects you tell it to draw.
> > > 
> > > Now the user interface is what steer the logic of the drawouts.
> > > 
> > > You seem to say it somehow can tell a group of objects if they should be drawn or not. And i am totally lost here, because as you see i have to poll what should be drawn within the drawmethod and that gives alot of overhead.
> > > 
> > > Could you direct me to "a short" "simple" example how it really should be done?
> > > 
> > > Also my script do rendering using mouse inputs, so then the graphic objects must take/listen input parameters from mouse, would not that cause even more overhead?
> > > 
> > > Of couse i must also poll what to be drawn out every redraw, and that is the main thing i want to get rid off. Say i have 15 function that do different parts of things to draw, that you can steer from the user interface.
> > > 
> > > Now that would be 15! cases to handle within programming, so that is not an option. I think i have 3 right now or so but it still 6 cases. 
> > > 
> > > My code is probably not suited to transform into objectoriented programming, but i still want a look how it could work.
> > > 
> > > What i really would like advice on is howto move the polling out of the redraw,  now i decide what to draw within redraw ***every time*** method is called.
> > > 
> > > I wanted to find a strategy/method where you set booleans for drawmethods, and check them once and somehow pass a bulk of what should be redrawn. 
> > > 
> > > I understand i could create cases with redraws, but that really does not seem to fit drawing.
> > 
> > Here is an example of my style of graphic rendering, and i understand it is wrong. As you can see the logic is within the draw method "animation" to offer live update of drag and drop, that all these booleans called every "x-th" millisec. While drawing. Some is always drawn and some other just drawn depending on settings of the UI. I probably can not change all the code into OO-programming i do not think i have the skill, nor knowledge. Right now i let the animation run all time and that ain't necessary i can fix that from UI, start and stop it on UI mouse and animation redraws. But howto move the booleans out of redraw i just do not get. But if you show me an example of how it is done with OO code i may be able to grasp it.
> > 
> > // Paint logic
> > function redraw() {
> >     // Clear canvas
> >     ctx.clearRect(0, 0, canvas.width, canvas.height);
> >     //  // Redraw canvas
> >     ctx.fillStyle = mybgcolor;
> >     ctx.fillRect(0, 0, canvas.width, canvas.height);
> >     if (grid==true) {graphBackground();}
> >     // Redraw graph
> >     paint_graph(arr);
> >     paint_message();
> > }
> > 
> > function paint_graph(arr) {
> >     ctx.lineWidth = 1;
> >     if (markarea == true) {
> >         markDraw();
> >     } else if (moveit == true) {
> >         moveDraw();
> >     } else if (reshape == true) {
> >         boundariesDraw();
> >     } else if (doreshape == true) {
> >         reshapeDraw();
> >     }
> >     graphDraw();
> >     if (handles==true){
> >       nodeDraw();
> >     }
> > }
> > 
> > 
> > function graphDraw() {
> >     for (var t = 0; t < arr.length; t++) {
> >         if (arr[t].print == true) {
> >             ctx.strokeStyle = arr[t].bcolor;
> >             var tempcolor=arr[t].bcolor;
> >             for (s = 0; s < arr[t].nodelinks.length; s++) {
> >                 var myvar = arr[t].nodelinks[s];
> >                 if (arr[t].BcurveX1[myvar] == undefined) {
> >                     ctx.beginPath();
> >                     ctx.moveTo(arr[t].rposX, arr[t].rposY);
> >                     ctx.lineTo(arr[myvar].rposX, arr[myvar].rposY);
> >                     ctx.stroke();
> >                 } else {
> >                 if (bhandles==true) { bezcontrol(t,myvar,tempcolor);ctx.strokeStyle=tempcolor;}
> >                     ctx.beginPath();
> >                     ctx.moveTo(arr[t].rposX, arr[t].rposY);
> >                     ctx.bezierCurveTo(arr[t].BcurveX1[myvar], arr[t].BcurveY1[myvar], arr[t].BcurveX2[myvar], arr[t].BcurveY2[myvar], arr[myvar].rposX, arr[myvar].rposY);
> >                     ctx.stroke();
> >                     if (holdbezier1==true){ moveBezierDraw1(); }
> >                     else if (holdbezier2==true){ moveBezierDraw2(); }
> >                 }
> >             }
> >         }
> >     }
> > }
> 
> Should i put the start animation redraw within each of these functions?
> 
> Or maybe even even on block level of things i draw, it seem the code lose structure?
> 
> That is why i wanted the functions as parameters passed to draw rather then start and stop redraw everywhere in the code?
> 
> But that is what you suggest, well with objects rather then my functions?
> 
> function paint_graph(arr) { 
>     ctx.lineWidth = 1; 
>     if (markarea == true) { 
>         markDraw(); 
>     } else if (moveit == true) { 
>         moveDraw(); 
>     } else if (reshape == true) { 
>         boundariesDraw(); 
>     } else if (doreshape == true) { 
>         reshapeDraw(); 
>     } 
>     graphDraw(); 
>     if (handles==true){ 
>       nodeDraw(); 
>     } 
> }

It probably is a good idea to start animation within the functions that handle the graphics output, but it seem a bit unorganised.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-14 11:49 -0700
  Re: Javascripts and highlevel computer language programming of graphics John G Harris <niam@jghnorth.org.uk.invalid> - 2017-04-15 11:07 +0100
    Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-15 11:52 -0700
      Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-15 12:04 -0700
        Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-15 14:52 -0700
          Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-15 15:04 -0700
            Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-16 00:09 +0200
              Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-15 15:18 -0700
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-16 11:27 +0200
                Re: Javascripts and highlevel computer language programming of graphics <cyber@2trom.com> - 2017-04-16 15:08 +0000
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-16 20:47 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-17 10:02 -0700
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-17 23:46 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-18 17:39 -0700
                Re: Javascripts and highlevel computer language programming of graphics Andrew Poulos <ap_prog@hotmail.com> - 2017-04-19 11:25 +1000
                Re: Javascripts and highlevel computer language programming of graphics Bob Martin <bob.martin@excite.com> - 2017-04-19 07:30 +0100
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-19 12:13 +0200
                Re: Javascripts and highlevel computer language programming of graphics Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-19 13:58 +0200
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-19 17:20 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-19 10:00 -0700
                Re: Javascripts and highlevel computer language programming of graphics <cyber@2trom.com> - 2017-04-20 12:33 +0000
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-20 11:39 -0700
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-20 21:24 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-21 11:57 -0700
                Re: Javascripts and highlevel computer language programming of graphics Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-21 18:37 +0200
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-19 12:00 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-19 10:03 -0700
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-20 00:07 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-19 17:21 -0700
                Re: Javascripts and highlevel computer language programming of graphics Andrew Poulos <ap_prog@hotmail.com> - 2017-04-20 15:54 +1000
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-20 08:46 +0200
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-20 08:43 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-20 11:42 -0700
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-20 21:37 +0200
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-21 03:23 -0700
                Re: Javascripts and highlevel computer language programming of graphics Andrew Poulos <ap_prog@hotmail.com> - 2017-04-22 16:21 +1000
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-22 12:15 +0200
                Re: Javascripts and highlevel computer language programming of graphics Gene Wirchenko <genew@telus.net> - 2017-04-21 11:58 -0700
                Re: Javascripts and highlevel computer language programming of graphics <cyber@2trom.com> - 2017-04-17 13:01 +0000
                Re: Javascripts and highlevel computer language programming of graphics Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-17 20:28 +0200
                Re: Javascripts and highlevel computer language programming of graphics bit-naughty@hotmail.com - 2017-04-19 23:50 -0700
                Re: Javascripts and highlevel computer language programming of graphics Andrew Poulos <ap_prog@hotmail.com> - 2017-04-20 19:02 +1000
                Re: Javascripts and highlevel computer language programming of graphics "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-20 11:24 +0200
            Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-15 15:14 -0700
              Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-15 15:24 -0700
        Re: Javascripts and highlevel computer language programming of graphics John G Harris <niam@jghnorth.org.uk.invalid> - 2017-04-17 10:49 +0100
          Re: Javascripts and highlevel computer language programming of graphics RobG <rgqld@iinet.net.au> - 2017-04-23 08:39 +1000
            Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-22 15:46 -0700
              Re: Javascripts and highlevel computer language programming of graphics John G Harris <niam@jghnorth.org.uk.invalid> - 2017-04-23 15:29 +0100
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-23 09:47 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-23 09:57 -0700
                Re: Javascripts and highlevel computer language programming of graphics John G Harris <niam@jghnorth.org.uk.invalid> - 2017-04-24 11:09 +0100
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 05:26 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 05:32 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 05:36 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 05:44 -0700
                Re: Javascripts and highlevel computer language programming of graphics John G Harris <niam@jghnorth.org.uk.invalid> - 2017-04-24 15:12 +0100
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 10:12 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-23 09:49 -0700
                Re: Javascripts and highlevel computer language programming of graphics John G Harris <niam@jghnorth.org.uk.invalid> - 2017-04-24 11:10 +0100
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 12:07 -0700
                Re: Javascripts and highlevel computer language programming of graphics Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-24 21:24 +0100
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 13:32 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 13:41 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 13:56 -0700
                Re: Javascripts and highlevel computer language programming of graphics John G Harris <niam@jghnorth.org.uk.invalid> - 2017-04-25 10:41 +0100
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-26 12:15 -0700
                Re: Javascripts and highlevel computer language programming of graphics jonas.thornvall@gmail.com - 2017-04-24 13:27 -0700

csiph-web