I need some help with cfdg!

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
ozymandias360
Posts: 2
Joined: Thu Nov 03, 2022 6:52 am

I need some help with cfdg!

Post by ozymandias360 »

Hey guys, I'm a beginner in context free, actually I'm a beginner in coding, that's the first time that I use code language to do anything, and I'm trying to create a generative logo design using context free.

The logo is composed of three lines that randomically organize themselves in a 7x7 grid. To make this I use a LOT of shapes and paths, probably there exists an easier way to do it, but i don't know yet. Two of the three lines also had to trespass the other line at some point. Well the randomness works, but i don't know how to make the two lines trespass one at some point. I'd appreciate it if any of you guys could help me.

ps* The point of intersection between the lines don't have to be on the 7x7 grid

Examples where happened that they intersect each other:
https://imgur.com/gallery/dvuPGux

Examples where this did not happen:
https://imgur.com/gallery/OkcvXVd

Here is the GIANT code:

Code: Select all

 startshape grid

shape grid
{
	grid_structure []
    logo[]
}

shape logo 
{
	loop 3 [] RANDOM_LINES []
}

shape linha1
{
    linha1_base []
}

path linha1_base {
    MOVETO (0,0)
    LINETO (1, 6)
    STROKE(0.1)[]      
}

shape linha2
{
    linha2_base []
}

path linha2_base {
    MOVETO (0, 0)
    LINETO  (2, 6)
    STROKE(0.1)[]     
}

shape linha3    
{
    linha3_base []
}

path linha3_base {
    MOVETO (0, 0)
    LINETO  (3, 6)
    STROKE(0.1)[]      
}

shape linha4    
{
    linha4_base []
}

path linha4_base {
    MOVETO (0, 0)
    LINETO  (4, 6)
    STROKE(0.1)[]      
}

shape linha5    
{
    linha5_base []
}

path linha5_base {
    MOVETO (0, 0)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha6    
{
    linha6_base []
}

path linha6_base {
    MOVETO (0, 0)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha7    
{
    linha7_base []
}

path linha7_base {
    MOVETO (0, 0)
    LINETO  (6, 5)
    STROKE(0.1)[]      
}

shape linha8    
{
    linha8_base []
}

path linha8_base {
    MOVETO (0, 0)
    LINETO  (6, 4)
    STROKE(0.1)[]      
}

shape linha9    
{
    linha9_base []
}

path linha9_base {
    MOVETO (0, 0)
    LINETO  (6, 3)
    STROKE(0.1)[]      
}

shape linha10    
{
    linha10_base []
}

path linha10_base {
    MOVETO (0, 0)
    LINETO  (6, 2)
    STROKE(0.1)[]      
}

shape linha11    
{
    linha11_base []
}

path linha11_base {
    MOVETO (0, 0)
    LINETO  (6, 1)
    STROKE(0.1)[]      
}
 
shape linha12    
{
    linha12_base []
}

path linha12_base {
    MOVETO (1, 0)
    LINETO  (0, 6)
    STROKE(0.1)[]      
}

shape linha13   
{
    linha13_base []
}

path linha13_base {
    MOVETO (1, 0)
    LINETO  (2, 6)
    STROKE(0.1)[]      
}

shape linha14    
{
    linha14_base []
}

path linha14_base {
    MOVETO (1, 0)
    LINETO  (3, 6)
    STROKE(0.1)[]  
}

shape linha15    
{
    linha15_base []
}

path linha15_base {
    MOVETO (1, 0)
    LINETO  (4, 6)
    STROKE(0.1)[]  
}

shape linha16    
{
    linha16_base []
}

path linha16_base {
    MOVETO (1, 0)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha17    
{
    linha17_base []
}

path linha17_base {
    MOVETO (1, 0)
    LINETO  (6, 6)
    STROKE(0.1)[]    
}

shape linha18    
{
    linha18_base []
}

path linha18_base {
    MOVETO (1, 0)
    LINETO  (6, 5)
    STROKE(0.1)[]   
}

shape linha19   
{
    linha19_base []
}

path linha19_base {
    MOVETO (1, 0)
    LINETO  (6, 4)
    STROKE(0.1)[]     
}

shape linha20    
{
    linha20_base []
}

path linha20_base {
    MOVETO (1, 0)
    LINETO  (6, 3)
    STROKE(0.1)[]   
}

shape linha21    
{
    linha21_base []
}

path linha21_base {
    MOVETO (1, 0)
    LINETO  (6, 2)
    STROKE(0.1)[]     
}

shape linha22    
{
    linha22_base []
}

path linha22_base {
    MOVETO (1, 0)
    LINETO  (6, 1)
    STROKE(0.1)[]   
}

shape linha23    
{
    linha23_base []
}

path linha23_base {
    MOVETO (2, 0)
    LINETO  (0, 6)
    STROKE(0.1)[]   
}

shape linha24    
{
    linha24_base []
}

path linha24_base {
    MOVETO (2, 0)
    LINETO  (1, 6)
    STROKE(0.1)[]   
}

shape linha25    
{
    linha25_base []
}

path linha25_base {
    MOVETO (2, 0)
    LINETO  (3, 6)
    STROKE(0.1)[]   
}

shape linha26    
{
    linha26_base []
}

path linha26_base {
    MOVETO (2, 0)
    LINETO  (4, 6)
    STROKE(0.1)[]   
}

shape linha27    
{
    linha27_base []
}

path linha27_base {
    MOVETO (2, 0)
    LINETO  (5, 6)
    STROKE(0.1)[]   
}

shape linha28    
{
    linha28_base []
}

path linha28_base {
    MOVETO (2, 0)
    LINETO  (6, 6)
    STROKE(0.1)[]   
}

shape linha29    
{
    linha29_base []
}

path linha29_base {
    MOVETO (2, 0)
    LINETO  (6, 5)
    STROKE(0.1)[]    
}

shape linha30    
{
    linha30_base []
}

path linha30_base {
    MOVETO (2, 0)
    LINETO  (6, 4)
    STROKE(0.1)[] 
}

shape linha31    
{
    linha31_base []
}

path linha31_base {
    MOVETO (2, 0)
    LINETO  (6, 3)
    STROKE(0.1)[] 
}

shape linha32    
{
    linha32_base []
}

path linha32_base {
    MOVETO (2, 0)
    LINETO  (6, 2)
    STROKE(0.1)[] 
}

shape linha33    
{
    linha33_base []
}

path linha33_base {
    MOVETO (2, 0)
    LINETO  (6, 1)
    STROKE(0.1)[] 
}

shape linha34    
{
    linha34_base []
}

path linha34_base {
    MOVETO (3, 0)
    LINETO  (0, 6)
    STROKE(0.1)[]   
}

shape linha35  
{
    linha35_base []
}

path linha35_base {
    MOVETO (3, 0)
    LINETO  (1, 6)
    STROKE(0.1)[]   
}

shape linha36    
{
    linha36_base []
}

path linha36_base {
    MOVETO (3, 0)
    LINETO  (2, 6)
    STROKE(0.1)[]   
}

shape linha37    
{
    linha37_base []
}

path linha37_base {
    MOVETO (3, 0)
    LINETO  (4, 6)
    STROKE(0.1)[]   
}

shape linha38    
{
    linha38_base []
}

path linha38_base {
    MOVETO (3, 0)
    LINETO  (5, 6)
    STROKE(0.1)[]     
}

shape linha39    
{
    linha39_base []
}

path linha39_base {
    MOVETO (3, 0)
    LINETO  (6, 6)
    STROKE(0.1)[]   
}

shape linha40    
{
    linha40_base []
}

path linha40_base {
    MOVETO (3, 0)
    LINETO  (6, 5)
    STROKE(0.1)[]     
}

shape linha41    
{
    linha41_base []
}

path linha41_base {
    MOVETO (3, 0)
    LINETO  (6, 4)
    STROKE(0.1)[]        
}

shape linha42    
{
    linha42_base []
}

path linha42_base {
    MOVETO (3, 0)
    LINETO  (6, 3)
    STROKE(0.1)[]     
}

shape linha43    
{
    linha43_base []
}

path linha43_base {
    MOVETO (3, 0)
    LINETO  (6, 2)
    STROKE(0.1)[]      
}

shape linha44    
{
    linha44_base []
}

path linha44_base {
    MOVETO (3, 0)
    LINETO  (6, 1)
    STROKE(0.1)[]     
}

shape linha45    
{
    linha45_base []
}

path linha45_base {
    MOVETO (4, 0)
    LINETO  (1, 6)
    STROKE(0.1)[]     
}

shape linha46    
{
    linha46_base []
}

path linha46_base {
    MOVETO (4, 0)
    LINETO  (2, 6)
    STROKE(0.1)[]    
}

shape linha47    
{
    linha47_base []
}

path linha47_base {
    MOVETO (4, 0)
    LINETO  (3, 6)
    STROKE(0.1)[]      
}

shape linha48    
{
    linha48_base []
}

path linha48_base {
    MOVETO (4, 0)
    LINETO  (5, 6)
    STROKE(0.1)[]     
}

shape linha49    
{
    linha49_base []
}

path linha49_base {
    MOVETO (4, 0)
    LINETO  (6, 6)
    STROKE(0.1)[]        
}

shape linha50    
{
    linha50_base []
}

path linha50_base {
    MOVETO (5, 0)
    LINETO  (0, 6)
    STROKE(0.1)[]        
}

shape linha51    
{
    linha51_base []
}

path linha51_base {
    MOVETO (5, 0)
    LINETO  (1, 6)
    STROKE(0.1)[]        
}

shape linha52    
{
    linha52_base []
}

path linha52_base {
    MOVETO (5, 0)
    LINETO  (2, 6)
    STROKE(0.1)[]        
}

shape linha53    
{
    linha53_base []
}

path linha53_base {
    MOVETO (5, 0)
    LINETO  (3, 6)
    STROKE(0.1)[]        
}

shape linha54    
{
    linha54_base []
}

path linha54_base {
    MOVETO (5, 0)
    LINETO  (4, 6)
    STROKE(0.1)[]        
}

shape linha55    
{
    linha55_base []
}

path linha55_base {
    MOVETO (5, 0)
    LINETO  (6, 6)
    STROKE(0.1)[]            
}

shape linha56    
{
    linha56_base []
}

path linha56_base {
    MOVETO (5, 0)
    LINETO  (6, 5)
    STROKE(0.1)[]       
}

shape linha57    
{
    linha57_base []
}

path linha57_base {
    MOVETO (5, 0)
    LINETO  (6, 4)
    STROKE(0.1)[]     
}

shape linha58    
{
    linha58_base []
}

path linha58_base {
    MOVETO (5, 0)
    LINETO  (6, 3)
    STROKE(0.1)[]       
}

shape linha59    
{
    linha59_base []
}

path linha59_base {
    MOVETO (5, 0)
    LINETO  (6, 2)
    STROKE(0.1)[]    
}

shape linha60    
{
    linha60_base []
}

path linha60_base {
    MOVETO (5, 0)
    LINETO  (6, 1)
    STROKE(0.1)[]     
}

shape linha61    
{
    linha61_base []
}

path linha61_base {
    MOVETO (6, 0)
    LINETO  (0, 6)
    STROKE(0.1)[]        
}

shape linha62    
{
    linha62_base []
}

path linha62_base {
    MOVETO (6, 0)
    LINETO  (1, 6)
    STROKE(0.1)[]        
}

shape linha63    
{
    linha63_base []
}

path linha63_base {
    MOVETO (6, 0)
    LINETO  (2, 6)
    STROKE(0.1)[]        
}

shape linha64    
{
    linha64_base []
}

path linha64_base {
    MOVETO (6, 0)
    LINETO  (3, 6)
    STROKE(0.1)[]        
}

shape linha65    
{
    linha65_base []
}

path linha65_base {
    MOVETO (6, 0)
    LINETO  (4, 6)
    STROKE(0.1)[]       
}

shape linha66    
{
    linha66_base []
}

path linha66_base {
    MOVETO (6, 0)
    LINETO  (5, 6)
    STROKE(0.1)[]       
}

shape linha67    
{
    linha67_base []
}

path linha67_base {
    MOVETO (6, 0)
    LINETO  (0, 5)
    STROKE(0.1)[]    
}

shape linha68    
{
    linha68_base []
}

path linha68_base {
    MOVETO (6, 0)
    LINETO  (0, 4)
    STROKE(0.1)[]       
}

shape linha69    
{
    linha69_base []
}

path linha69_base {
    MOVETO (6, 0)
    LINETO  (0, 3)
    STROKE(0.1)[]        
}

shape linha70    
{
    linha70_base []
}

path linha70_base {
    MOVETO (6, 0)
    LINETO  (0, 2)
    STROKE(0.1)[] 
}

shape linha71    
{
    linha71_base []
}

path linha71_base {
    MOVETO (6, 0)
    LINETO  (0, 1)
    STROKE(0.1)[]       
}

shape linha72    
{
    linha72_base []
}

path linha72_base {
    MOVETO (5, 0)
    LINETO  (0, 5)
    STROKE(0.1)[]       
}
shape linha73    
{
    linha73_base []
}

path linha73_base {
    MOVETO (5, 0)
    LINETO  (0, 4)
    STROKE(0.1)[]        
}

shape linha74    
{
    linha74_base []
}

path linha74_base {
    MOVETO (5, 0)
    LINETO  (0, 3)
    STROKE(0.1)[]   
}

shape linha75    
{
    linha75_base []
}

path linha75_base {
    MOVETO (5, 0)
    LINETO  (0, 2)
    STROKE(0.1)[]  
}

shape linha76    
{
    linha76_base []
}

path linha76_base {
    MOVETO (5, 0)
    LINETO  (0, 1)
    STROKE(0.1)[]    
}

shape linha77    
{
    linha77_base []
}

path linha77_base {
    MOVETO (4, 0)
    LINETO  (0, 5)
    STROKE(0.1)[]      
}

shape linha78    
{
    linha78_base []
}

path linha78_base {
    MOVETO (4, 0)
    LINETO  (0, 4)
    STROKE(0.1)[]      
}

shape linha79    
{
    linha79_base []
}

path linha79_base {
    MOVETO (4, 0)
    LINETO  (0, 3)
    STROKE(0.1)[]      
}

shape linha80    
{
    linha80_base []
}

path linha80_base {
    MOVETO (4, 0)
    LINETO  (0, 2)
    STROKE(0.1)[]        
}

shape linha81    
{
    linha81_base []
}

path linha81_base {
    MOVETO (4, 0)
    LINETO  (0, 1)
    STROKE(0.1)[]       
}

shape linha82    
{
    linha82_base []
}

path linha82_base {
    MOVETO (3, 0)
    LINETO  (0, 5)
    STROKE(0.1)[]          
}

shape linha83    
{
    linha83_base []
}

path linha83_base {
    MOVETO (3, 0)
    LINETO  (0, 4)
    STROKE(0.1)[]               
}

shape linha84    
{
    linha84_base []
}

path linha84_base {
    MOVETO (3, 0)
    LINETO  (0, 3)
    STROKE(0.1)[]        
}
shape linha85    
{
    linha85_base []
}

path linha85_base {
    MOVETO (3, 0)
    LINETO  (0, 2)
    STROKE(0.1)[]             
}

shape linha86    
{
    linha86_base []
}

path linha86_base {
    MOVETO (3, 0)
    LINETO  (0, 1)
    STROKE(0.1)[]        
}

shape linha87    
{
    linha87_base []
}

path linha87_base {
    MOVETO (2, 0)
    LINETO  (0, 5)
    STROKE(0.1)[]          
}

shape linha88    
{
    linha88_base []
}

path linha88_base {
    MOVETO (2, 0)
    LINETO  (0, 4)
    STROKE(0.1)[]        
}

shape linha89    
{
    linha89_base []
}

path linha89_base {
    MOVETO (2, 0)
    LINETO  (0, 3)
    STROKE(0.1)[]        
}

shape linha90    
{
    linha90_base []
}

path linha90_base {
    MOVETO (2, 0)
    LINETO  (0, 1)
    STROKE(0.1)[]            
}

shape linha91    
{
    linha91_base []
}

path linha91_base {
    MOVETO (1, 0)
    LINETO  (0, 5)
    STROKE(0.1)[]          
}

shape linha92    
{
    linha92_base []
}

path linha92_base {
    MOVETO (1, 0)
    LINETO  (0, 4)
    STROKE(0.1)[]    
}

shape linha93    
{
    linha93_base []
}

path linha93_base {
    MOVETO (1, 0)
    LINETO  (0, 3)
    STROKE(0.1)[]         
}

shape linha94    
{
    linha94_base []
}

path linha94_base {
    MOVETO (1, 0)
    LINETO  (0, 2)
    STROKE(0.1)[]     
}

shape linha95    
{
    linha95_base []
}

path linha95_base {
    MOVETO (0, 1)
    LINETO  (6, 6)
    STROKE(0.1)[]   
}

shape linha96    
{
    linha96_base []
}

path linha96_base {
    MOVETO (0, 1)
    LINETO  (5, 6)
    STROKE(0.1)[]   
}
shape linha97    
{
    linha97_base []
}

path linha97_base {
    MOVETO (0, 1)
    LINETO  (4, 6)
    STROKE(0.1)[]        
}

shape linha98    
{
    linha98_base []
}

path linha98_base {
    MOVETO (0, 1)
    LINETO  (3, 6)
    STROKE(0.1)[]   
}

shape linha99    
{
    linha99_base []
}

path linha99_base {
    MOVETO (0, 1)
    LINETO  (2, 6)
    STROKE(0.1)[]    
}

shape linha100    
{
    linha100_base []
}

path linha100_base {
    MOVETO (0, 1)
    LINETO  (1, 6)
    STROKE(0.1)[]        
}

shape linha101    
{
    linha101_base []
}

path linha101_base {
    MOVETO (0, 2)
    LINETO  (6, 6)
    STROKE(0.1)[]         
}

shape linha102    
{
    linha102_base []
}

path linha102_base {
    MOVETO (0, 2)
    LINETO  (5, 6)
    STROKE(0.1)[]    
}

shape linha103    
{
    linha103_base []
}

path linha103_base {
    MOVETO (0, 2)
    LINETO  (4, 6)
    STROKE(0.1)[]        
}

shape linha104    
{
    linha104_base []
}

path linha104_base {
    MOVETO (0, 2)
    LINETO  (3, 6)
    STROKE(0.1)[]     
}

shape linha105    
{
    linha105_base []
}

path linha105_base {
    MOVETO (0, 2)
    LINETO  (2, 6)
    STROKE(0.1)[]         
}

shape linha106    
{
    linha106_base []
}

path linha106_base {
    MOVETO (0, 2)
    LINETO  (1, 6)
    STROKE(0.1)[]     
}

shape linha107    
{
    linha107_base []
}

path linha107_base {
    MOVETO (0, 3)
    LINETO  (6, 6)
    STROKE(0.1)[]     
}

shape linha108    
{
    linha108_base []
}

path linha108_base {
    MOVETO (0, 3)
    LINETO  (5, 6)
    STROKE(0.1)[]     
}

shape linha109    
{
    linha109_base []
}

path linha109_base {
    MOVETO (0, 3)
    LINETO  (4, 6)
    STROKE(0.1)[]     
}

shape linha110    
{
    linha110_base []
}

path linha110_base {
    MOVETO (0, 3)
    LINETO  (3, 6)
    STROKE(0.1)[]     
}

shape linha111    
{
    linha111_base []
}

path linha111_base {
    MOVETO (0, 3)
    LINETO  (2, 6)
    STROKE(0.1)[]     
}

shape linha112    
{
    linha112_base []
}

path linha112_base {
    MOVETO (0, 3)
    LINETO  (1, 6)
    STROKE(0.1)[]     
}

shape linha113
{
    linha113_base []
}

path linha113_base {
    MOVETO (0, 4)
    LINETO  (6, 6)
    STROKE(0.1)[]     
}

shape linha115 
{
    linha115_base []
}

path linha115_base {
    MOVETO (0, 4)
    LINETO  (5, 6)
    STROKE(0.1)[]     
}

shape linha116    
{
    linha116_base []
}

path linha116_base {
    MOVETO (0, 4)
    LINETO  (4, 6)
    STROKE(0.1)[] 
}

shape linha117    
{
    linha117_base []
}

path linha117_base {
    MOVETO (0, 4)
    LINETO  (3, 6)
    STROKE(0.1)[] 
}

shape linha118
{
    linha118_base []
}

path linha118_base {
    MOVETO (0, 4)
    LINETO  (2, 6)
    STROKE(0.1)[] 
}

shape linha119 
{
    linha119_base []
}

path linha119_base {
    MOVETO (0, 4)
    LINETO  (1, 6)
    STROKE(0.1)[] 
}

shape linha120
{
    linha120_base []
}

path linha120_base {
    MOVETO (0, 5)
    LINETO  (6, 6)
    STROKE(0.1)[]     
}

shape linha121 
{
    linha121_base []
}

path linha121_base {
    MOVETO (0, 5)
    LINETO  (5, 6)
    STROKE(0.1)[]     
}

shape linha122  
{
    linha122_base []
}

path linha122_base {
    MOVETO (0, 5)
    LINETO  (4, 6)
    STROKE(0.1)[]     
}

shape linha123
{
    linha123_base []
}

path linha123_base {
    MOVETO (0, 5)
    LINETO  (3, 6)
    STROKE(0.1)[]     
}

shape linha124
{
    linha124_base []
}

path linha124_base {
    MOVETO (0, 5)
    LINETO  (2, 6)
    STROKE(0.1)[]    
}

shape linha125 
{
    linha125_base []
}

path linha125_base {
    MOVETO (0, 0)
    LINETO  (1, 5)
    STROKE(0.1)[]    
}

shape linha126   
{
    linha126_base []
}

path linha126_base {
    MOVETO (0, 6)
    LINETO  (6, 5)
    STROKE(0.1)[]   
}

shape linha127   
{
    linha127_base []
}

path linha127_base {
    MOVETO (0, 0)
    LINETO  (6, 5)
    STROKE(0.1)[]   
}
shape linha128    
{
    linha128_base []
}

path linha128_base {
    MOVETO (0, 4)
    LINETO  (6, 5)
    STROKE(0.1)[]   
}

shape linha129    
{
    linha129_base []
}

path linha129_base {
    MOVETO (0, 3)
    LINETO  (6, 5)
    STROKE(0.1)[]    
}

shape linha130    
{
    linha130_base []
}

path linha130_base {
    MOVETO (0, 2)
    LINETO  (6, 5)
    STROKE(0.1)[]   
}

shape linha131    
{
    linha131_base []
}

path linha131_base {
    MOVETO (0, 1)
    LINETO  (6, 5)
    STROKE(0.1)[]   
}

shape linha132    
{
    linha132_base []
}

path linha132_base {
    MOVETO (0, 6)
    LINETO  (6, 4)
    STROKE(0.1)[]   
}

shape linha133    
{
    linha133_base []
}

path linha133_base {
    MOVETO (0, 5)
    LINETO  (6, 4)
    STROKE(0.1)[]   
}

shape linha134    
{
    linha134_base []
}

path linha134_base {
    MOVETO (0, 0)
    LINETO  (6, 4)
    STROKE(0.1)[]    
}

shape linha135    
{
    linha135_base []
}

path linha135_base {
    MOVETO (0, 3)
    LINETO  (6, 4)
    STROKE(0.1)[]   
}

shape linha136    
{
    linha136_base []
}

path linha136_base {
    MOVETO (0, 2)
    LINETO  (6, 4)
    STROKE(0.1)[]         
}

shape linha137    
{
    linha137_base []
}

path linha137_base {
    MOVETO (0, 1)
    LINETO  (6, 4)
    STROKE(0.1)[]   
}

shape linha138    
{
    linha138_base []
}

path linha138_base {
    MOVETO (0, 6)
    LINETO  (6, 3)
    STROKE(0.1)[]   
}

shape linha139    
{
    linha139_base []
}

path linha139_base {
    MOVETO (0, 5)
    LINETO  (6, 3)
    STROKE(0.1)[]   
}

shape linha140    
{
    linha140_base []
}

path linha140_base {
    MOVETO (0, 4)
    LINETO  (6, 3)
    STROKE(0.1)[]   
}

shape linha141    
{
    linha141_base []
}

path linha141_base {
    MOVETO (0, 0)
    LINETO  (6, 3)
    STROKE(0.1)[]   
}

shape linha142    
{
    linha142_base []
}

path linha142_base {
    MOVETO (0, 2)
    LINETO  (6, 3)
    STROKE(0.1)[]    
}

shape linha143    
{
    linha143_base []
}

path linha143_base {
    MOVETO (0, 1)
    LINETO  (6, 3)
    STROKE(0.1)[]   
}

shape linha144
{
    linha144_base []
}

path linha144_base {
    MOVETO (0, 6)
    LINETO  (6, 2)
    STROKE(0.1)[]   
}

shape linha145 
{
    linha145_base []
}

path linha145_base {
    MOVETO (0, 5)
    LINETO  (6, 2)
    STROKE(0.1)[]   
}

shape linha146    
{
    linha146_base []
}

path linha146_base {
    MOVETO (0, 4)
    LINETO  (6, 2)
    STROKE(0.1)[]   
}

shape linha147    
{
    linha147_base []
}

path linha147_base {
    MOVETO (0, 3)
    LINETO  (6, 2)
    STROKE(0.1)[]   
}

shape linha148
{
    linha148_base []
}

path linha148_base {
    MOVETO (0, 0)
    LINETO  (6, 2)
    STROKE(0.1)[]   
}

shape linha149 
{
    linha149_base []
}

path linha149_base {
    MOVETO (0, 1)
    LINETO  (6, 2)
    STROKE(0.1)[]   
}

shape linha150
{
    linha150_base []
}

path linha150_base {
    MOVETO (0, 6)
    LINETO  (6, 1)
    STROKE(0.1)[]   
}

shape linha151 
{
    linha151_base []
}

path linha151_base {
    MOVETO (0, 5)
    LINETO  (6, 1)
    STROKE(0.1)[]   
}

shape linha152  
{
    linha152_base []
}

path linha152_base {
    MOVETO (0, 4)
    LINETO  (6, 1)
    STROKE(0.1)[]   
}

shape linha153
{
    linha153_base []
}

path linha153_base {
    MOVETO (0, 3)
    LINETO  (6, 1)
    STROKE(0.1)[]   
}

shape linha154
{
    linha154_base []
}

path linha154_base {
    MOVETO (0, 2)
    LINETO  (6, 1)
    STROKE(0.1)[]   
}

shape linha155 
{
    linha155_base []
}

path linha155_base {
    MOVETO (0, 0)
    LINETO  (6, 1)
    STROKE(0.1)[]   
}

shape linha156
{
    linha156_base []
}

path linha156_base {
    MOVETO (1,1)
    LINETO (0, 6)
    STROKE(0.1)[]      
}

shape linha157
{
    linha157_base []
}

path linha157_base {
    MOVETO (1, 1)
    LINETO  (2, 6)
    STROKE(0.1)[]     
}

shape linha158    
{
    linha158_base []
}

path linha158_base {
    MOVETO (1, 1)
    LINETO  (3, 6)
    STROKE(0.1)[]      
}

shape linha159    
{
    linha159_base []
}

path linha159_base {
    MOVETO (1, 1)
    LINETO  (4, 6)
    STROKE(0.1)[]      
}

shape linha160    
{
    linha160_base []
}

path linha160_base {
    MOVETO (1, 1)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha161
{
    linha161_base []
}

path linha161_base {
    MOVETO (1, 1)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha162
{
    linha162_base []
}

path linha162_base {
    MOVETO (1, 2)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha163
{
    linha163_base []
}

path linha163_base {
    MOVETO (1, 2)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha164
{
    linha164_base []
}

path linha164_base {
    MOVETO (1, 2)
    LINETO  (4, 6)
    STROKE(0.1)[]      
}

shape linha165
{
    linha165_base []
}

path linha165_base {
    MOVETO (1, 2)
    LINETO  (3, 6)
    STROKE(0.1)[]      
}

shape linha166
{
    linha166_base []
}

path linha166_base {
    MOVETO (5, 1)
    LINETO  (1, 5)
    STROKE(0.1)[]      
}

shape linha167
{
    linha167_base []
}

path linha167_base {
    MOVETO (1, 3)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha168
{
    linha168_base []
}

path linha168_base {
    MOVETO (1, 3)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha169
{
    linha169_base []
}

path linha169_base {
    MOVETO (1, 3)
    LINETO  (4, 6)
    STROKE(0.1)[]      
}

shape linha170
{
    linha170_base []
}

path linha170_base {
    MOVETO (1, 3)
    LINETO  (2, 6)
    STROKE(0.1)[]      
}

shape linha171
{
    linha171_base []
}

path linha171_base {
    MOVETO (0, 3)
    LINETO  (1, 6)
    STROKE(0.1)[]      
}

shape linha172
{
    linha172_base []
}

path linha172_base {
    MOVETO (1, 4)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha173
{
    linha173_base []
}

path linha173_base {
    MOVETO (1, 4)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha174
{
    linha174_base []
}

path linha174_base {
    MOVETO (1, 4)
    LINETO  (3, 6)
    STROKE(0.1)[]      
}

shape linha175
{
    linha175_base []
}

path linha175_base {
    MOVETO (1, 4)
    LINETO  (2, 6)
    STROKE(0.1)[]      
}

shape linha176
{
    linha176_base []
}

path linha176_base {
    MOVETO (1, 4)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha177
{
    linha177_base []
}

path linha177_base {
    MOVETO (2, 1)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha178
{
    linha178_base []
}

path linha178_base {
    MOVETO (1, 1)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha179
{
    linha179_base []
}

path linha179_base {
    MOVETO (3, 1)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha180
{
    linha180_base []
}

path linha180_base {
    MOVETO (2,1)
    LINETO (5, 6)
    STROKE(0.1)[]      
}

shape linha181
{
    linha181_base []
}

path linha181_base {
    MOVETO (2, 1)
    LINETO  (4, 6)
    STROKE(0.1)[]     
}

shape linha182    
{
    linha182_base []
}

path linha182_base {
    MOVETO (2, 1)
    LINETO  (1, 6)
    STROKE(0.1)[]      
}

shape linha183    
{
    linha183_base []
}

path linha183_base {
    MOVETO (2, 1)
    LINETO  (0, 6)
    STROKE(0.1)[]      
}

shape linha184    
{
    linha184_base []
}

path linha184_base {
    MOVETO (3, 1)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha185
{
    linha185_base []
}

path linha185_base {
    MOVETO (3, 1)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha186
{
    linha186_base []
}

path linha186_base {
    MOVETO (3, 2)
    LINETO  (4, 6)
    STROKE(0.1)[]      
}

shape linha187
{
    linha187_base []
}

path linha187_base {
    MOVETO (3, 2)
    LINETO  (2, 6)
    STROKE(0.1)[]      
}

shape linha188
{
    linha188_base []
}

path linha188_base {
    MOVETO (3, 2)
    LINETO  (1, 6)
    STROKE(0.1)[]      
}

shape linha189
{
    linha189_base []
}

path linha189_base {
    MOVETO (3, 2)
    LINETO  (0, 6)
    STROKE(0.1)[]      
}

shape linha190
{
    linha190_base []
}

path linha190_base {
    MOVETO (4, 2)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha191
{
    linha191_base []
}

path linha191_base {
    MOVETO (4, 2)
    LINETO  (5, 6)
    STROKE(0.1)[]      
}

shape linha192
{
    linha192_base []
}

path linha192_base {
    MOVETO (4, 2)
    LINETO  (3, 6)
    STROKE(0.1)[]      
}

shape linha193
{
    linha193_base []
}

path linha193_base {
    MOVETO (4, 2)
    LINETO  (2, 6)
    STROKE(0.1)[]      
}

shape linha194
{
    linha194_base []
}

path linha194_base {
    MOVETO (4, 2)
    LINETO  (1, 6)
    STROKE(0.1)[]      
}

shape linha195
{
    linha195_base []
}

path linha195_base {
    MOVETO (4, 3)
    LINETO  (0, 6)
    STROKE(0.1)[]      
}

shape linha196
{
    linha196_base []
}

path linha196_base {
    MOVETO (5, 3)
    LINETO  (6, 6)
    STROKE(0.1)[]      
}

shape linha197
{
    linha197_base []
}

path linha197_base {
    MOVETO (5, 3)
    LINETO  (4, 6)
    STROKE(0.1)[]      
}

shape linha198
{
    linha198_base []
}

path linha198_base {
    MOVETO (5, 3)
    LINETO  (4, 6)
    STROKE(0.1)[]      
}

shape linha199
{
    linha199_base []
}

path linha199_base {
    MOVETO (5, 3)
    LINETO  (3, 6)
    STROKE(0.1)[]      
}

shape linha200
{
    linha200_base []
}

path linha200_base {
    MOVETO (5, 4)
    LINETO  (2, 6)
    STROKE(0.1)[]      
}

shape RANDOM_LINES
rule { linha1 []}
rule { linha2 []}
rule { linha3 []}
rule { linha4 []}
rule { linha5 []}
rule { linha6 []}
rule { linha7 []}
rule { linha8 []}
rule { linha9 []}
rule { linha10[]}
rule { linha12[]}
rule { linha13[]}
rule { linha14[]}
rule { linha15[]}
rule { linha16[]}
rule { linha17[]}
rule { linha18[]}
rule { linha19[]}
rule { linha20[]}
rule { linha21[]}
rule { linha22[]}
rule { linha23[]}
rule { linha24[]}
rule { linha24[]}
rule { linha25[]}
rule { linha26[]}
rule { linha27[]}
rule { linha28[]}
rule { linha29[]}
rule { linha30[]}
rule { linha31[]}
rule { linha32[]}
rule { linha33[]}
rule { linha34[]}
rule { linha35[]}
rule { linha36[]}
rule { linha37[]}
rule { linha38[]}
rule { linha39[]}
rule { linha40[]}
rule { linha41[]}
rule { linha42[]}
rule { linha43[]}
rule { linha44[]}
rule { linha45[]}
rule { linha46[]}
rule { linha47[]}
rule { linha48[]}
rule { linha49[]}
rule { linha50[]}
rule { linha51 []}
rule { linha52 []}
rule { linha53 []}
rule { linha54 []}
rule { linha55 []}
rule { linha56 []}
rule { linha57 []}
rule { linha58 []}
rule { linha59 []}
rule { linha60 []}
rule { linha61 []}
rule { linha62 []}
rule { linha63 []}
rule { linha64 []}
rule { linha65 []}
rule { linha66 []}
rule { linha67 []}
rule { linha68 []}
rule { linha69 []}
rule { linha70 []}
rule { linha71 []}
rule { linha72 []}
rule { linha73 []}
rule { linha74 []}
rule { linha75 []}
rule { linha76 []}
rule { linha77 []}
rule { linha78 []}
rule { linha79 []}
rule { linha80 []}
rule { linha81 []}
rule { linha82 []}
rule { linha83 []}
rule { linha84 []}
rule { linha85 []}
rule { linha86 []}
rule { linha87 []}
rule { linha88 []}
rule { linha89 []}
rule { linha90 []}
rule { linha91 []}
rule { linha92 []}
rule { linha93 []}
rule { linha94 []}
rule { linha95 []}
rule { linha96 []}
rule { linha97 []}
rule { linha98 []}
rule { linha99 []}
rule { linha100 []}
rule { linha101 []}
rule { linha102 []}
rule { linha103 []}
rule { linha104 []}
rule { linha105 []}
rule { linha106 []}
rule { linha107 []}
rule { linha108 []}
rule { linha109 []}
rule { linha110 []}
rule { linha111 []}
rule { linha112 []}
rule { linha113 []}
rule { linha115 []}
rule { linha116 []}
rule { linha117 []}
rule { linha118 []}
rule { linha119 []}
rule { linha120 []}
rule { linha121 []}
rule { linha122 []}
rule { linha123 []}
rule { linha124 []}
rule { linha125 []}
rule { linha126 []}
rule { linha127 []}
rule { linha128 []}
rule { linha129 []}
rule { linha130 []}
rule { linha131 []}
rule { linha132 []}
rule { linha133 []}
rule { linha134 []}
rule { linha135 []}
rule { linha136 []}
rule { linha100 []}
rule { linha137 []}
rule { linha138 []}
rule { linha139 []}
rule { linha140 []}
rule { linha141 []}
rule { linha142 []}
rule { linha143 []}
rule { linha144 []}
rule { linha145 []}
rule { linha146 []}
rule { linha147 []}
rule { linha148 []}
rule { linha149 []}
rule { linha150 []}
rule { linha151 []}
rule { linha152 []}
rule { linha153 []}
rule { linha154 []}
rule { linha155 []}
rule { linha156 []}
rule { linha157 []}
rule { linha158 []}
rule { linha159 []}
rule { linha160 []}
rule { linha161 []}
rule { linha162 []}
rule { linha163 []}
rule { linha164 []}
rule { linha165 []}
rule { linha166 []}
rule { linha167 []}
rule { linha168 []}
rule { linha169 []}
rule { linha170 []}
rule { linha171 []}
rule { linha172 []}
rule { linha173 []}
rule { linha174 []}
rule { linha175 []}
rule { linha176 []}
rule { linha178 []}
rule { linha179 []}
rule { linha180 []}
rule { linha181 []}
rule { linha182 []}
rule { linha183 []}
rule { linha184 []}
rule { linha185 []}
rule { linha186 []}
rule { linha187 []}
rule { linha188 []}
rule { linha189 []}
rule { linha190 []}
rule { linha191 []}
rule { linha192 []}
rule { linha193 []}
rule { linha194 []}
rule { linha195 []}
rule { linha196 []}
rule { linha197 []}
rule { linha198 []}
rule { linha199 []}
rule { linha200 []}

shape grid_structure
{
	loop 7 [y 1] grid_row [] 
}

shape grid_row
{
	loop 7 [x 1] GRID_DOT []
}

shape GRID_DOT
{ 
CIRCLE [s 0.10 0.10] 
}


User avatar
MtnViewJohn
Site Admin
Posts: 880
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: I need some help with cfdg!

Post by MtnViewJohn »

You are going to need to learn how to use Context Free as a functional programming language. Here is a programatic version of your logo design. It is 31 lines long, compared to 1874 lines for your non-programatic version.

Code: Select all

startshape grid

vector2 edgepoint() = 
  select(randint(4), 
         (0, randint(7)), 
         (6, randint(7)),
         (randint(7), 0),
         (randint(7), 6))
  


vector4 edgepair() = 
  let(p1 = edgepoint(); p2 = edgepoint();
      if(p1[0] == p2[0] || p1[1] ==p2[1],
         edgepair(), (p1[0], p1[1], p2[0], p2[1])))
         
path line {
  pair = edgepair()
  MOVETO(pair[0,2])
  LINETO(pair[2,2])
  STROKE(0.1)[]
}

shape grid {
  loop 7 [y 1]
    loop 7 [x 1]
      CIRCLE[s 0.1]
  line[]
  line[]
  line[]
}
The edgepoint() function returns a two-element vector that is a random point on one of the 4 edges of the 7x7 grid. The edgepair() function calls edgepoint() twice and checks whether the line between those two points is vertical or horizontal. If it is then edgepair() calls itself recursively to try to find another pair of points. Otherwise it returns the two points as a 4-element vector. The line path calls the edgepair() function to get the line end points and draws the line between them.

So what you need to do is write a function that calls the edgepair() function three times to get three lines. Then it will perform some geometric calculation to see if the lines meet your intersection requirement. If the lines meet your intersection requirement then return them as a 12-element vector and draw the three lines. Otherwise, your function calls itself recursively to try to find another three lines.

ozymandias360
Posts: 2
Joined: Thu Nov 03, 2022 6:52 am

Re: I need some help with cfdg!

Post by ozymandias360 »

MtnViewJohn wrote:
Mon Nov 07, 2022 11:23 pm
You are going to need to learn how to use Context Free as a functional programming language. Here is a programatic version of your logo design. It is 31 lines long, compared to 1874 lines for your non-programatic version.

Code: Select all

startshape grid

vector2 edgepoint() = 
  select(randint(4), 
         (0, randint(7)), 
         (6, randint(7)),
         (randint(7), 0),
         (randint(7), 6))
  


vector4 edgepair() = 
  let(p1 = edgepoint(); p2 = edgepoint();
      if(p1[0] == p2[0] || p1[1] ==p2[1],
         edgepair(), (p1[0], p1[1], p2[0], p2[1])))
         
path line {
  pair = edgepair()
  MOVETO(pair[0,2])
  LINETO(pair[2,2])
  STROKE(0.1)[]
}

shape grid {
  loop 7 [y 1]
    loop 7 [x 1]
      CIRCLE[s 0.1]
  line[]
  line[]
  line[]
}
The edgepoint() function returns a two-element vector that is a random point on one of the 4 edges of the 7x7 grid. The edgepair() function calls edgepoint() twice and checks whether the line between those two points is vertical or horizontal. If it is then edgepair() calls itself recursively to try to find another pair of points. Otherwise it returns the two points as a 4-element vector. The line path calls the edgepair() function to get the line end points and draws the line between them.

So what you need to do is write a function that calls the edgepair() function three times to get three lines. Then it will perform some geometric calculation to see if the lines meet your intersection requirement. If the lines meet your intersection requirement then return them as a 12-element vector and draw the three lines. Otherwise, your function calls itself recursively to try to find another three lines.
Thanks for that, it helped me a lot.

Post Reply