fibcurve

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

fibcurve

Message par compsystems » ven. avr. 27, 2018 2:31 pm

Hello, I am testing the fibcurve code in the xcas_python version but when plot the graph is not displayed

Code : Tout sélectionner

def fibword(n):
  if n == 0:
    return "0"
  elif n == 1:
    return "1"
  else:
    return fibword(n-1)+fibword(n-2):;
    
    
def fibcurve(n=9, dx=5, dy=0, x=100, y=100, c=255):
  word = fibword(n)
  res=[]
  for k in range(len(word)):
    if word[k] == "1":
      if k % 2:
        dx, dy = -dy, dx
      else:
        dx, dy = dy, -dx
    if dx == 0:
      if dy > 0:
        y1, y2 = y, y+dy+1
      else:
        y1, y2 = y+dy, y+1
      for y0 in range(y1, y2):
        res.append(pixon(x, y0, c))
      y += dy
    else:
      if dx > 0:
        x1, x2 = x, x+dx+1
      else:
        x1, x2 = x+dx, x+1
      for x0 in range(x1, x2):
        res.append(pixon(x0, y, c))
      x += dx
  return res:; 
fibword(9); "1011010110110101101011011010110110101101011011010110101"
fibcurve() empty plot


... also when placing:; I see that the code is displayed, it should show "Done"

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re:

Message par parisse » ven. avr. 27, 2018 2:53 pm

change the default color, for example to 1.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re:

Message par compsystems » lun. avr. 30, 2018 3:34 am

ok c=1, but pixon(x,y,RGB(r,g,b)), can accept RGB as a third parameter?
is possible that in the compilation it does not show the rewritten codes, that is to say that it is only "Done", I try to put :; at the end of each code

Code : Tout sélectionner

def fibword(n):
  if n == 0:
    return "0"
  elif n == 1:
    return "1"
  else:
    return fibword(n-1)+fibword(n-2):;
    
def fibword2(n):
    u,v="0","1"
    for j in range(2,n+1):
        u,v=v,v+u
    return v:;  
    
def fibcurve(n=9, dx=5, dy=0, x=100, y=100, c=0):
  word = fibword2(n)
  res=[]
  for k in range(len(word)):
    if word[k] == "1":
      if k % 2:
        dx, dy = -dy, dx
      else:
        dx, dy = dy, -dx
    if dx == 0:
      if dy > 0:
        y1, y2 = y, y+dy+1
      else:
        y1, y2 = y+dy, y+1
      for y0 in range(y1, y2):
        res.append(pixon(x, y0, c))
      y += dy
    else:
      if dx > 0:
        x1, x2 = x, x+dx+1
      else:
        x1, x2 = x+dx, x+1
      for x0 in range(x1, x2):
        res.append(pixon(x0, y, c))
      x += dx
  return res:;

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re:

Message par parisse » lun. avr. 30, 2018 6:04 am

Put each definition in a separate level.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re:

Message par compsystems » lun. avr. 30, 2018 12:55 pm

Hello BP, placing each function in each line shows "Done", if there are n functions, it is better to place them in a single line of editing, it may be that (:;) is not python syntax, but it would have the purpose of not showing the compilation.

On the other hand I want to carry the numworks codes to xcas, for this a new RGB command is required, please can you analyze the possibility of including it

https://workshop.numworks.com/python/hawkinja/pattern

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re:

Message par parisse » lun. avr. 30, 2018 1:49 pm

Run color(r,g,b)

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re:

Message par compsystems » lun. avr. 30, 2018 3:35 pm

I can not incorporate it in the previous code

Code : Tout sélectionner

def fibcurve(n=9, dx=5, dy=0, x=100, y=100, c=1):
  c=color(1,1,1) ...

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re:

Message par parisse » lun. avr. 30, 2018 6:42 pm

color(r,g,b) currently works only in Xcas for Firefox.

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: Re:

Message par compsystems » dim. mai 06, 2018 2:38 am

parisse a écrit :color(r,g,b) currently works only in Xcas for Firefox.
please BP consider incorporating in the PC version, that the online version already has advantages as a disadvantage

Répondre