Jump to content

mpsn

Members
  • Posts

    264
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location
    Edmonton,AB

mpsn's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Hi, I'm trying to build a cell culture on a petri dish so I'm just starting off with just drawing 5 micro-organisms. After I generate the cell with Generate nodes button, I want to clear the canvas, currently I'm using naive way of just drawing a white rectange the size of my canvas, I'm guessing this is not efficient to overlap since memory required to store the covered over graphics or does it not matter? here is my index page: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <!--Note: canvas ALWAYS comes before the script since we need the canvas to draw on --> <canvas id="myCanvas" width="200" height="200" style="border:1px solid #c3c3c3;"> Your browser does not support the HTML5 canvas tag. </canvas> <script src="JS_CSS_testBox_1.js" type="text/javascript" ></script> <p id="prev_x">prev x: </p><!--this was just for debugging--> <p id="prev_y">prev y: </p><!--this was just for debugging--> <p id="cur_x">x: </p><!--this was just for debugging--> <p id="cur_y">y: </p><!--this was just for debugging--> <button id="gen_nodes" onclick="generate_nodes(id)">Generate nodes</button> <button id="empty_canvas" onclick="cls()">Clear screen</button> </body> </html> //global variables prev_x = 0; prev_y = 0; cur_x = 0; cur_y = 0; prev_x_arr = [0]; prev_y_arr = [0]; i = 0;//current available index in the parallel prev_x_y arr above item_no = 0;//draw up to 5 nodes var canvas = document.getElementById('myCanvas');//get the Canvas node var context = canvas.getContext('2d');//get the context object to work w/ actual drawings (Note: Each canvas element can only have one context) function pick_a_rand_num() { return Math.floor((Math.random()*40) + 1);//Note: JS's rand num fcn is equivalent to: int division of rand()%2 (returns 0 or 1) } function generate_nodes(id) { while ( id == "gen_nodes" && item_no < 5 ) { var rand = pick_a_rand_num(); var offset_x = pick_a_rand_num()/2; var offset_y = pick_a_rand_num()/2; cur_x = ( rand )/ 2 + offset_x;//x component of center of circle cur_y = ( rand )/ 2 + offset_y;//y component of center of circle var radius = 5; var startAngle = 0; var endAngle = 2 * Math.PI; var counterClockwise = false; document.getElementById("arr_size").innerHTML = "Size: " + prev_x_arr.length; document.getElementById("prev_x").innerHTML = "prev x: " + prev_x; document.getElementById("prev_y").innerHTML = "prev y: " + prev_y; document.getElementById("cur_x").innerHTML = "x: " + cur_x; document.getElementById("cur_y").innerHTML = "y: " + cur_y; //go thru parallel arr of prev_x_y to make sure we can draw new circle // so compare each point w/ current pt to ensure validity to draw new circle var tot_violations = 0;//assume no violation b/c prev_x, prev_y w/ cur_x, cur_y (so if @ least 1 violation, we don't draw the new circle!) for ( var j = 0; j < prev_x_arr.length; ++j )//if we find at least 1 pt that conflicts w/ cur_x, cur_y, don't draw, so need to go thru entire prev_arr { if ( Math.abs(cur_x - prev_x_arr[j] ) <= 2*radius && Math.abs(cur_y - prev_y_arr[j] ) <= 2*radius )//ensure no two circles overlap (so don't draw circles that overlap)' { tot_violations++; } } //after going thru entire prev_x, prev_y arr above, only draw when NO violations //ONLY update prev_x, prev_y if we have an acceptable center of new circle if ( tot_violations == 0 )//ensure no two circles overlap (so don't draw circles that overlap)' { context.beginPath();//Q: why do we need this? context.arc(cur_x, cur_y, radius, startAngle, endAngle, counterClockwise); context.lineWidth = 2; // line color context.fillStyle = 'blue'; context.fill(); context.strokeStyle = 'black'; context.stroke(); item_no++; prev_x = cur_x; prev_y = cur_y; //Note: these prev_x, prev_y arr below store ALL the x,y coordinates so far prev_x_arr[i] = cur_x; prev_y_arr[i] = cur_y; ++i; } }//END WHILE (draw 5 nodes only) } //[CL]ear [s]creen (paying homage to Windows Command Prompt command) //Problem here: how do I delete all the current drawings??? one way is draw a white rectange to overlap...what's better way??? (need to figure out) function cls() { prev_x = 0; prev_y = 0; cur_x = 0; cur_y = 0; prev_x_arr = [0]; prev_y_arr = [0]; i = 0;//current available index in the parallel prev_x_y arr above item_no = 0;//draw up to 5 nodes /*Naive way to clear screen, I'm just drawing a white rectange with same size as my canvas, what's more efficient way?*/ context.beginPath();//I guess always call beginPath for clarity, what other reason? context.rect(0,0,200,200); context.fillStyle = "white"; context.fill(); }
  2. I'm actually using WordPress form plugin and it takes in a regular expression only, so I can't tinker with the PHP files. I understand how to implement DD/MM/YYYY as: e.g. /\d{2}\/\d{2}\/\d{4}/ if all integers assuming
  3. Hi, how do I evaluate form validation for a date to be in format: MM/DD/YYYY and to be between 2 years and 6 years of age, it's for a daycare center.
  4. Hi, I need to look for a modern topic for my homework and do a presentation (anything circa 2000), it could be software, it could be hardware some ideas I looked into a bit but can't find any interest are: e-commerce GUI and user experience Any topics, please throw out. thanks
  5. Ok, I figured out my problem, it's because I float:left for my mainContent div, so I removed this and voila, the container that holds mainContent div "grows", but if I don't keep left float my mainContent and right float my sidebar, it means I have to hardcode with setting margin-left to get the two to divs (mainContent and sidebar) to be beside each other, but not touching... Unless there's another way...
  6. To be clear, the mainContent and sidebar divs go past the wrapper they are in:container, I do have padding for bottom of 900px, so why doesn't my container wrapper (that holds mainContent and sidebar div) "grow" appropriately as mainContent and sidebar get taller (more content added I mean). From my CSS and my HTML, it looks fine, I hope someone can help out.
  7. Here, please try out the following, this one you'll see the yellow div (mainContentItem) doesn't stay within its wrapper: container. My CSS: ===== .container /*ONLY MAIN BOX that holds contentBox(that holds content, sidebar) and needs margin-left and margin-right set to auto in order to be positioned in center of page*/ { width:1180px;/*1180px;*/ margin-left:auto; margin-right:auto; margin-top:10px;/*CSS Reminder:the main div 'container' is inside body so it will move 10px from the top of whatever box precedes it (here it's header div)*/ padding:10px 10px 900px 10px; background-color:grey; } /*================================CONTENT================================*/ .mainContentItem/*holds main content box itms*/ { float:left; width:870px; padding:2px 20px 2px 20px; word-wrap:break-word;/*CSS3*/ background-color:yellow; } /*inherited class selectors that are children of mainContentItem wrapper so they will be insde mainContentItem box*/ .mainContentItem h1/*text style for headings*/ { font:bold 25px Verdana, Arial, sans-serif; text-align:center; color:#FFF; background-color:black; } .mainContentItem h2/*text style for sub-headings*/ { font:italic 20px Verdana, Geneva, sans-serif; text-align:center; } .mainContentItem h3/*text style for paragraphs*/ { font:bold 14px "Trebuchet MS", Helvetica, sans-serif; background-color: #EEE8AA; } /*=============================SIDEBAR==============================*/ .sidebar/*WRAPPER that holds the indiv sidebar div itms*/ { /* float:right; width:240px; padding:10px 5px 400px 5px; background-color:#90EE90; border:1px solid black; */ } .sidebarItem/*holds itms inside the sidebar box: e.g. ticker, visual funds tracker*/ { float:right; width:240px; background-color:green; padding:5px; word-wrap:break-word;/*CSS3*/ border:1px solid black; } .sidebarItem h1/*text style for headings*/ { font:bold 25px Verdana, Arial, sans-serif; text-align:center; color:#FFF; background-color:black; } .sidebarItem h2/*text style for sub-headings*/ { font:italic 20px Verdana, Geneva, sans-serif; text-align:center; } .sidebarItem h3/*text style for paragraphs*/ { font:bold 14px "Trebuchet MS", Helvetica, sans-serif; background-color: #EEE8AA; } .clear/*to prevent any elems that come after sidebar box to float to right*/ { clear:both; } /*==============================FOOTER==========================*/ .footer { color:#000; width:1200px; margin-left:auto; margin-right:auto; margin-top:20px; padding:2px; text-align:center; border:1px solid black; background-color:#90EE90;/*#228B22;*/ } My HTML: ======== <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Yo</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="header"> ds </div><!-- END header--> <div class="container"><!--wrapper for contentBox which holds mainContent(holds mainContentItem boxes) and sidebar(holds sidebarItem boxes)--> <div class="mainContentItem"> <h1>sdf</h1> <h2>sdfdsfds</h2> <h3>sdfdsfdsfsdf sdfDDDDDDDDDDDDDDDDDDDDDDDDDDdddddddddddddddddddddddddddddddddddddddddffffffffffffffffffffffffffffffffffffffffffHelloHelow dsfdsfdsfsdfdsfsdfDDDDDDDDDD sdfdsfdsfdsfdsDDDDDDDDD sdfdsfsdfdsdsfsdDDDDDDDDDD sdfdsfdsfdsfsdfsdfDDDDDDDD sdf</h3> <h1>sdf</h1> <h2>sdfdsfds</h2> <h3>sdfdsfdsfsdfDDDDDDDDDDDDDD sdfDDDDDDDDDDDDDDDD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DDD sdfdsfdsfdsfsdfsdfDDDDDDDDDDDDDDDD sdf</h3> <h1>sdf</h1> <h2>sdfdsfds</h2> <h3>sdfdsfdsfsdf sdfDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD dsfdsfdsfsdfdsfsdfDDDDDDDDDDDDDDD sdfdsfdsfdsfdsDDDDDDDDDDDDDDD sdfdsfsdfdsdsfsdDDDDDDDDDDDDDDDD sdfdsfdsfdsfsdfsdf sdf</h3> <h1>sdf</h1> <h2>sdfdsfds</h2> <h3>sdfdsfdsfsdfDDDDDDDD sdfDDDDDDDDDDDDDDDDDDDDDDDDDDD dsfdsfdsfsdfdsfsdfDDDDDDDDDDDDD sdfdsfdsfdsfdsDDDDDDDDDDDDDDDDDDD sdfdsfsdfdsdsfsdDDDDDDDDDDDDDDDDDDDD sdfdsfdsfdsfsdfsdfDDDDDDDDDDD sdf</h3> <h1>sdf</h1> <h2>sdfdsfds</h2> <h3>sdfdsfdsfsdf sdfDDDDDDDDDDDDDDDDDDDDDDDDDDDD dsfdsfdsfsdfdsfsdfDDDDDDDDDDDDDDD sdfdsfdsfdsfdsDDDDDDDDDDDDD sdfdsfsdfdsdsfsd sdfdsfdsfdsfsdfsdf sdf</h3> </div><!-- END mainContentItem--> </div><!--END container div--> <div class="clear"></div> <div class="footer"> <h6>Site<em>powered by WordPress</em></H6> </div> </body> </html> Appreciate it.
  8. Hi, I thought the point of having a div within another div (or p for that matter) was to ensure that if the content inside the inner div gets too long, that the outer or wrapper div will "grow" as long it has padding bottom set to maintain that and no height set, so I don't get why my mainContentItem div which is inside my mainContent div are fine, but mainContent div relative to the wrapper contentBox causes mainContent div to go out of the contentBox div, when I assumed that since my mainContent div is embedded inside my contentBox div that the contentBox div would grow by 900px as mainContent div gets longer. My CSS: .container /*ONLY MAIN BOX that holds contentBox(that holds content, sidebar) and needs margin-left and margin-right set to auto in order to be positioned in center of page*/ { width:1180px; margin-left:auto; margin-right:auto; margin-top:10px;/*CSS Reminder:the main div 'container' is inside body so it will move 10px from the top of whatever box precedes it (here it's header div)*/ padding:10px 10px 900px 10px; background-color:#FFF; } /*================================CONTENT================================*/ .contentBox/*hold the main content box*/ { float:left; width:880px; padding:5px 15px 100px 15px; background-color:white; border:1px solid black; } .mainContentItem/*holds main content box itms*/ { padding:2px 20px 2px 20px; background-color:yellow; } /*inherited class selectors that are children of mainContentItem wrapper so they will be insde mainContentItem box*/ .mainContentItem h1/*text style for headings*/ { font:bold 25px Verdana, Arial, sans-serif; text-align:center; color:#FFF; background-color:black; } .mainContentItem h2/*text style for sub-headings*/ { font:italic 20px Verdana, Geneva, sans-serif; text-align:center; } .mainContentItem h3/*text style for paragraphs*/ { font:bold 14px "Trebuchet MS", Helvetica, sans-serif; background-color: #EEE8AA; } HTML: <html> <head></head> <body> <div class="container"><!-- this holds the mainContent and sidebar divs(which in turn holds sidebarItem)--> <div class="contentBox"> <div class="mainContentItem"> <h1>Heading</h1> <h2>Subheading</h2> <h3>This is a sentence, a sentence...etc etc etc</h3> </div> </div> </div> </body> </html>
  9. mpsn

    Preg stuff

    i'll try it out thx
  10. Hi, I have a sidebar div that holds my sidebarItem div, but I'm curious as to why the text doesn't wrap around if I decide to , meaning it should add a new line type in a long string of text w/o a break so I mean the black background color for my sidebarItem div should "grow",right? But doesn't and just goes out of my sidebarItem div and I had to meticulously change text length to ensure it doesn't go off the sidebarItem so specifically I have gibberish text and not sure why 977 goes out of my sidebarItem and consequently outside sidebar wrapper, shouldn't extra text just wrap around to make a new line (so black border I have has new line made to accomodate the 977 if the text is currently at the width of sidebarItem since sidebarItem's width is fixed inside sidebar div of width:240px My CSS: .sidebar/*WRAPPER that holds the indiv sidebar div itms*/ { float:right; width:240px; padding:10px 5px 400px 5px; background-color:#90EE90; border:1px solid black; } .sidebarItem/*holds itms inside the sidebar box: e.g. ticker, visual funds tracker*/ { background-color:green; padding:5px; border:1px solid black; } .sidebarItem h1/*text style for headings*/ { font:bold 25px Verdana, Arial, sans-serif; text-align:center; color:#FFF; background-color:black; } .sidebarItem h2/*text style for sub-headings*/ { font:italic 20px Verdana, Geneva, sans-serif; text-align:center; } .sidebarItem h3/*text style for paragraphs*/ { font:bold 14px "Trebuchet MS", Helvetica, sans-serif; background-color: #EEE8AA; } HTML <html> <head></head> <body> <div class="sidebar"> <div class="sidebarItem"> <h1>asfsdfsafsddd dd gg dddddddddddd977<!--Why doesn't the 977 wrap around so that the black background color of this sidebarItem div expand?--> d </h1> <h2>asfsdfsafsd asfsdfsafsdfsafsdas asfsdfsafsdasfsddas asfsdfsafsdasfsdfsd</h2> <h3>asfsdfsafsd asfsdfsafsd asfsdfsafsd asfsdfsafsd asfsdfsafsd asfsdfsafsd asfsdfsafsdasfsdfsafsd</h3> </div><!-- END sidebarItem--> </div><!-- END sidebar--> </body> </html>
  11. Hi, I was using a certain style for my menu navigation items and then when I switched to WordPress to build a client's website, I had to replace hardcoded HTML that referred to my stylesheet with wp_list_pages ( I know I should be using the newer wp_menu_nav I think it's called but for now anways), now my problem is: what if I decided I wanted to change the style selector name (something more meaningful for my sake), how would I do that and I know WordPress stores all the actual content in a database, so should I just go to the database and manually change it that way? I hope I am clear as to what I mean. eg: in my header.php <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title><?php bloginfo('name');?></title> <link href="<?php echo get_stylesheet_uri(); ?>" rel="stylesheet" type="text/css" /> </head> <body> <div class="header"> <img class="logo" src="<?php echo get_template_directory_uri(); ?>/images/logo.jpg"/> <img class="stock" src="<?php echo get_template_directory_uri(); ?>/images/stock_4.jpg" /> <div class="menuItems"> <?php wp_list_pages('title_li=&sort_column=menu_order'); ?><!--MY PROBLEM is HERE: HOW DO I CHANGE THE STYLE, DO I JUST--> <!-- MANUALLY GO INTO WORDPRESS DB????--> </div><!-- END menuItems--> </div><!-- END header--> <div class="container"><!--wrapper for content body (which in turn holds sidebar)--> <div class="contentBox"> <div class="content"> Currently I'm using localhost with XAMPP. Any help appreciated.
  12. Hi, I need some help with homework ques using the following function: <?php function getValue($x, $y, $z) { if ($x != 0) $y = 5; else $z = $z-$x; if ($z > 1) $z = $z/$x; else $z = $y; return $z; } ?> Here is the question: Provide a function, getValue(x y z), for the number of paths through the program in terms of x, y, and z. I'd appreciate any help, I think the ques is asking for a general formula, but I think the number of paths is just 4, b/c each if-statement can be: T to F, T to T, F to F, F to T. I don't know...
  13. Hi, i'm using a plugin: Fast Secure Contact Form and I want to set up my email to receive form submissions, but this is message I'm getting: SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (5) SMTP Error: Could not connect to SMTP host. If anyone uses this plugin or similar or very familar with WordPress/PHP, please let me know.
  14. mpsn

    Preg stuff

    so what am i doing wrong w. my approach for email validation: /[\da-zA-Z]+@[\da-zA-Z]+\.[a-ZA-Z]+/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.